Move Field symbol data to Internal table
Dear All,
Please suggest how to move field symbol data to internal table. The requirement is I have dynamic data in Field symbol which to move to table parameter of a function module.
Thanks in Advance
Rams.
Dear All,
In need to pass tabular data i.e. multiple entries from field symbol to the table parameter of the custom function module.
Field symbol is declared as below:
FIELD-SYMBOLS: <FS_EXCEL_TAB> TYPE STANDARD TABLE,
<FS_TABLE_HEADER> .
DATA WA_PD LIKE PRICE_DOWNLOAD.
APPEND <FS_TABLE_HEADER> TO <FS_EXCEL_TAB>.
CLEAR <FS_TABLE_HEADER>.
WA_PD-VKORG = <FS_EXCEL_TAB>-VKORG.u201D Problem while using this statement
APPEND WA_PD TO PRICE_DOWNLOAD.
CLEAR WA_PD.
Field symbol <FS_EXCEL_TAB> is populated like this.
VKORG | KUNNR_SH | KUNNR_SP |
0015 | 102105 | 102105 |
Now I need to move this data to table in tables parameter of custom fucntion module.
Thanks in advance,
Rams
Similar Messages
-
Data from field symbol into an internal table or workarea
Hi Experts,
I have field symbol in which i get the data. I want to get this data into an internal table of type any or into an work area. How is this possible.
My declaration for field symbol is as follow:
FIELD-SYMBOLS: <l_t_data> TYPE any.
DATA l_r_data TYPE REF TO data.
CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
ASSIGN l_r_data->* TO <l_t_data>.
I get the data in this field symbol <l_t_data>. by passing into a funtion module. and I get the data into it. Now i have to assign the values of this field symbol to any internal table or to a work are how do i do it. Please help.
Regards,
Prashant.Not exactly sure what you need here, but.....
FIELD-SYMBOLS: <l_t_data> TYPE TABLE. "<<-- Change this
FIELD-SYMBOLS: <l_s_data> TYPE ANY. "<<---Add This
DATA l_r_data TYPE REF TO data.
CREATE DATA l_r_data type STANDARD TABLE OF (l_local_tab).
ASSIGN l_r_data->* TO <l_t_data>.
Loop at <l_t_data> assigning <l_s_data>.
* Do what ever using <l_s_data>
Endloop.
Regards,
Rich Heilman
Edited by: Rich Heilman on Feb 28, 2008 2:42 PM -
Are field symbols and Dynamic internal tables consistant?
Hi,
Are field symbols and Dynamic internal tables
always consistent?
In my program I m creating a dynamic itab and assignig values to it using <FS>, sometimes the program fails to execute assign <Fs> statement...
this happens once in 3 to 4 runs
any solution...
I have proper clear and refresh statements in program.
Thanks,
HardikAnurag,
Thanks for a quick reply. Here I am sending a small piece of my code.
MOVE-CORRESPONDING OUTTAB TO DYNTAB.
CLEAR IT_UDATE.
CLEAR : T_KBETR .
READ TABLE IT_UDATE WITH KEY UDATE = OUTTAB-UDATE.
CONCATENATE 'DYNTAB-KBETR' IT_UDATE-CO_POS INTO T_KBETR.
ASSIGN (T_KBETR) TO <FS> .
SUBRC5 = SY-SUBRC .
IF SUBRC5 = 0 .
<FS> = OUTTAB-KBETR .
ENDIF .
read statement will always return CO_POS .
while debuging this code a few times
<b>ASSIGN (T_KBETR) TO <FS> .</b>
returns sy-subrc = 4
and that was leading the program to short dump earlier.
now, as I have a check DYNTAB-KBETR holds no value on display.
this happens very few times. (most of the times report is displaying desired output)
Thanks,
Hardik -
How to Copy data from field symbol to Dynamic Internal Table
Hi,
I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
REPORT ztest.
DATA:
gd_dref TYPE REF TO data,
gd_dref1 TYPE REF TO data.
FIELD-SYMBOLS: <fs1> TYPE any,
<fs_wa> TYPE any,
<field> TYPE any,
<fs_wa1> TYPE ANY TABLE. * Contains data from p_src
*Copy data from p_src to p_dest*
PARAMETERS: p_src LIKE dd02l-tabname . * Name of Dynamic Internal table *
p_dest LIKE dd02l-tabname . * Name of Dynamic Internal table*
*DATA : lt_csks LIKE p_dest WITH HEADER LINE.
START-OF-SELECTION.
CREATE DATA gd_dref TYPE (p_src).
CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
ASSIGN gd_dref->* TO <fs_wa>.
ASSIGN gd_dref1->* TO <fs_wa1>.
SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
*Write out data from FIELD SYMBOLS TO Table.
loop at <fs_wa1> into <fs_wa>.
do.
assign component sy-index
of structure <fs_wa> to <field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <field>.
else.
write: / <field>.
endif.
enddo.
endloop.
*Need Logic To Copy the Data to p_dest table from <fs_wa1>.
*p_dest is a table having a similar structure to table p_src .
*Need Logic To Copy the Data to p_dest table from <fs_wa1>.
EXIT.
Thanks in Advance.try this...
I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
Cheers...
report ztest.
data:
gd_dref type ref to data,
gd_dref1 type ref to data,
gd_dref_str type ref to data,
gd_dref_tab type ref to data.
field-symbols:
<fs1> type any,
<fs_wa> type any,
<fs1_dest_str> type any,
<fs_dest_tab> type any table,
<field> type any,
<fs_wa1> type any table.
* contains data from p_src
*Copy data from p_src to p_dest*
parameters: p_src like dd02l-tabname default 'vbak',
* name of dynamic internal table *
p_dest like dd02l-tabname default 'vbap'.
* name of dynamic internal table*
*data : lt_csks like p_dest with header line.
start-of-selection.
create data gd_dref type (p_src).
create data gd_dref1 type table of (p_src).
assign gd_dref->* to <fs_wa>.
assign gd_dref1->* to <fs_wa1>.
select * from (p_src) into corresponding fields of table <fs_wa1>
up to 3 rows
where vbeln ne space.
create data gd_dref_str type (p_dest).
create data gd_dref_tab type standard table of (p_dest).
assign gd_dref_str->* to <fs1_dest_str>.
assign gd_dref_tab->* to <fs_dest_tab>.
*write out data from field symbols to table.
loop at <fs_wa1> into <fs_wa>.
" break-point here - can see vbeln/waers/create date/ etc move over to new structure
" the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
" explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
break-point.
move-corresponding <fs_wa> to <fs1_dest_str>.
insert <fs1_dest_str> into table <fs_dest_tab>.
** do.
** assign component sy-index
** of structure <fs_wa> to <field>.
** if sy-subrc <> 0.
** exit.
** endif.
** if sy-index = 1.
** write:/ <field>.
** else.
** write: / <field>.
** endif.
** enddo.
endloop.
" write out some dest data from the dest table build from previous loop
loop at <fs_dest_tab> assigning <fs1_dest_str>.
do.
assign component sy-index of structure <fs_wa> to <field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <field>.
else.
write: / <field>.
endif.
enddo.
endloop. -
Accessing the variable in field symbol of nested internal table
Hi,
I am unable to access the variable in field symbol.
The data in field symbol has nested structure. We need to access a variable in nested structure.
Please find the code below:
LOOP AT <i_fincorp> into <fs_fincorp>.
l_madefor = <FS_FINCORP>-data_UI-ZZ0010.
ENDLOOP.
datatype of <i_fincorp> is type any table and <fs_fincorp> is type any.
there is a structure 'data_ui' in <i_fincorp> and we need value of field 'ZZ0010' in data_ui structure.
But, we are getting syntax error for statement in loop stating "There is no component like 'data_ui' in <fs_fincorp>".
Can anyone please help me solving this issue.
Regards,
SantoshSo simply access it dynamically
data: nested_field type c length 50.
field-symbols <nested_field> type any.
"build the nested field name dynamically
concatenate
'DATA_UI' "first give structure name
'ZZ0010' "then give field name (all in uppercase!)
into nested_field
separated by '-'. "now you have DATA_UI-ZZ0010
"so assing this nested field
LOOP AT <i_fincorp> into <fs_fincorp>.
assign component (nested_field) of structure <fs_fincorp> into <nested_field>.
ENDLOOP.
Regards
Marcin -
Field symbols and delete internal table.
Hi,
I wish to implement <fs> in this case:
LOOP AT intable ASSIGNING <fs> WHERE condition
IF condition1.
DELETE intable
ANDLOOP
I know that if the condition1 is verified, the <fs> will be unassigned but in this case I lose the loop.
Any Idea? ... Or is it impossible to handle?
Thanks in advance.
Regards,
GiovanniIf you know the standard table name in the start routine , then you can create a dynamic structure after adding a field flag, then you can use that as
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = p_table
changing
ct_fieldcat = i_fcat
exceptions
others = 1.
if sy-subrc = 0.
loop at i_fcat assigning <fcat>.
<fcat>-tabname = p_table.
<fcat>-fieldname = 'FLAG'
.... " after giving other attributes for the flag field
append <fcat> to i_fcat.
endloop.
call function 'LVC_FIELDCAT_COMPLETE'
changing
ct_fieldcat = i_fcat
exceptions
others = 1.
endif.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = i_fcat
importing
ep_table = i_content.
if sy-subrc = 0.
assign i_content->* to <fs>.
endif.
a® -
How to move field symbol internal table to internal table with header line?
Dear all,
hi...hereby i would like to ask how i can move field symbol internal table to a internal table?
as i know field symbol internal table is without header line..
so, may i know how to do this....to move field symbol internal table to internal table which consist of header line and field and record will same as field symbol internal table...in additional, my field symbol internal table is dynamic table mean everytime will have flexible columns..?
Please advise...
Thanks
Regard,
ToToRo.
Edited by: @ToToRo@ on Aug 20, 2009 6:16 AMHello,
Try this way:
If both the type of internal tables are same then you can directly assign dynamic internal table to static internal table.
itab = <itab>.
Suppose you have field symbol internal table <itab> which is different in structure from ITAB.
Now, you can create <wa> as follow:
FIELD-SYMBOLS <wa>.
DATA wa TYPE REF TO DATA.
CREATE DATA wa TYPE LINE OF <itab>.
ASSIGN wa->* to <wa>.
This way your work area is read.
Using [ASSIGN COMPONENT|http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3923358411d1829f0000e829fbfe/content.htm] syntax you can read required component of <wa>.
Finally you can use that value to load static internal table.
You can also refer to my thread on [Dynamic table|Re: Creating Dynamic table].
Hope this helps!
Thanks,
Augustin.
Edited by: Augustarian on Aug 20, 2009 10:06 AM -
Moving field-symbol data to an internal table
Hi
I have defined a field-symbol
field-symbols: <fs_table> type standard table.
Dynamically, I have populated some records in this <fs_table> & now I would like to copy this data into another internal table. I would like to know the best method to declare/create this internal table & to copy the records from <fs_table> to this internal table.
Thanks,
Sanjayif you know the structure of the reuslt in the first place, instead of dynamic itab you would have created a normal itab.
do you want the new itab to be same as <l_table> ?
then that also needs to be dynamically created.
the best thing possible in you case is.
field-symbols: <newtab> type any table.
if <l_table> is assinged.
assign <l_table> to <newtab>.
endif .
if you tell us why you want to move the <l_table> records to another similar itab, may be could come up with suggestion which dosesnt require you to move the data at all
Raja -
Pass Date from Internal table to Date field of Deadline(in expression tab)
Hello,
I need to set deadline in workflow according to dates in Internal table. So please guide how to achieve this.Thanks Rick for taking interest in my issue.
Business scenario:-
--> when PO is created delivery date is given in PO.
--> Now all materials in PO can be delivered on same date or on different dates.
-->Their can be same delivery date or different delivery dates.
--> So for example:- For a PO their are 4 materials-
MATERIAL NAME DELIVERY DATE
Material1 10.11.2011
Material2 20.11.2011
Material3 20.11.2011
Material4 10.11.2011
Now Material2 and Material3 will be delivered on 20.11.2011 and Material1 and Material4 will be delivered on 10.11.2011.
Now a reminder mail should go to Vendor of that PO before 2 days of delivery date mean on 08.11.2011 and 18.11.2011.
So to store 2 dates I require internal table.
Now I am able to trigger reminder mail for 2 dates by using multiline element in miscellaneous tab of activity.
But as I discussed in previous post that if I add multiline element in Date field of Requested start deadline then it gives error(plz check prev. post to see exact error). So I tried to used internal table(container in workflow) in deadline which is filled from a task in activity, but it is also not working means mail is triggered as soon as worflow is executed.
So the main problem is deadline is not created based on dates in internal table and other all the things are working perfectly.
As I am very new to workflow area, I might be going wrong somewhere.
So please guide how to set deadline for multiple dates(according to my scenario).
Thanks in advance.
Regards,
Mihir -
Error in uploading excel sheet data into internal table
Dear all,
i am facing problem when uploading data from excel. i used KD_GET_FILENAME_ON_F4.i select the file and pass on to ALSM_EXCEL_INTO_INTERNAL_TABLE.and i get the ERROR....
Illegal type when transferring an internal table to a FORM. this is my code .
types : begin of ty_mm01,
matnr like rmmg1-matnr,
mbrsh like rmmg1-mbrsh,
mtart like rmmg1-mtart,
maktx like makt-maktx,
meins like mara-meins,
matkl like mara-matkl,
bismt like mara-bismt,
spart like mara-spart,
mtpos like mara-mtpos_mara,
end of ty_mm01.
data : tt_mm01 type standard table of ty_mm01,
wa_mm01 like TT_MM01.
data : t_bdcdata like standard table of bdcdata,
t_bdcmsgcoll like standard table of bdcmsgcoll.
constants: begcol TYPE i value 1 ,
begrow TYPE i value 1,
endcol TYPE i value 100,
endrow TYPE i value 32000.
selection-screen : begin of block bdc with frame.
parameter : tfile like rlgrap-filename obligatory.
selection-screen : end of block bdc.
at selection-screen on value-request for tfile.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
PROGRAM_NAME = 'ZMM_MAT_MAS_BASIC_DATA'
DYNPRO_NUMBER = '1000'
FIELD_NAME = 'TFILE'
STATIC = 'X'
MASK = ',*.xls,'
CHANGING
FILE_NAME = tfile
start-of-selection.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = tfile
I_BEGIN_COL = begcol
I_BEGIN_ROW = begrow
I_END_COL = endcol
I_END_ROW = endrow
TABLES
INTERN = tt_mm01
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks in advanceHi,
Check these FM : KCD_EXCEL_OLE_TO_INT_CONVERT
Report ZPSP_TEST.
data: bdc_DATA like bdcdata occurs 0 with header line,
mess_tab like bdcmsgcoll occurs 0 with header line.
DATA: BEGIN OF ITAB OCCURS 0 ,
tcnt TYPE i, "Table Counter &H0D
WERKS LIKE T001W-WERKS,
BNFPO LIKE EBAN-BNFPO,
MATNR LIKE MARA-MATNR,
MENGE LIKE EBAN-MENGE,
END OF ITAB.
start-of-selection.
PERFORM upload_data.
loop at itab.
perform bdc_dynpro using 'SAPMM06B' '0100'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-BSART'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-BSART'
'NB'.
perform bdc_field using 'RM06B-LPEIN'
'T'.
perform bdc_field using 'EBAN-WERKS'
ITAB-WERKS.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RM06B-EKGRP'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RM06B-BNFPO'
ITAB-BNFPO.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE(01)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-MATNR(01)'
ITAB-MATNR.
perform bdc_field using 'EBAN-MENGE(01)'
ITAB-MENGE.
perform bdc_dynpro using 'SAPMM06B' '0102'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'RM06B-EEIND'
record-EEIND_010.
*perform bdc_field using 'RM06B-LPEIN'
record-LPEIN_011.
*perform bdc_field using 'EBAN-EKGRP'
record-EKGRP_012.
*perform bdc_field using 'EBAN-BADAT'
record-BADAT_013.
*perform bdc_field using 'EBAN-FRGDT'
record-FRGDT_014.
*perform bdc_field using 'EBAN-PREIS'
record-PREIS_015.
*perform bdc_field using 'EBAN-WAERS'
record-WAERS_016.
*perform bdc_field using 'EBAN-PEINH'
record-PEINH_017.
*perform bdc_field using 'EBAN-REPOS'
record-REPOS_018.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE(02)'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'RM06B-BNFPO'
record-BNFPO_019.
*perform bdc_field using 'EBAN-MATNR(02)'
record-MATNR_02_020.
*perform bdc_field using 'EBAN-MENGE(02)'
record-MENGE_02_021.
perform bdc_dynpro using 'SAPMM06B' '0102'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
*perform bdc_field using 'EBAN-MENGE'
ITAB-MENGE_023.
*perform bdc_field using 'RM06B-EEIND'
record-EEIND_024.
*perform bdc_field using 'RM06B-LPEIN'
record-LPEIN_025.
*perform bdc_field using 'EBAN-EKGRP'
record-EKGRP_026.
*perform bdc_field using 'EBAN-BADAT'
record-BADAT_027.
*perform bdc_field using 'EBAN-FRGDT'
record-FRGDT_028.
*perform bdc_field using 'EBAN-PREIS'
record-PREIS_029.
*perform bdc_field using 'EBAN-WAERS'
record-WAERS_030.
*perform bdc_field using 'EBAN-PEINH'
record-PEINH_031.
*perform bdc_field using 'EBAN-REPOS'
record-REPOS_032.
perform bdc_field using 'EBAN-TXZ01'
'BEARING 2"X2"'.
perform bdc_field using 'EBAN-MENGE'
'65'.
perform bdc_field using 'RM06B-EEIND'
'2005/01/03'.
perform bdc_field using 'RM06B-LPEIN'
'D'.
perform bdc_field using 'EBAN-EKGRP'
'M11'.
perform bdc_field using 'EBAN-BADAT'
'2005/01/03'.
perform bdc_field using 'EBAN-FRGDT'
'2005/01/03'.
perform bdc_field using 'EBAN-PREIS'
' 1,120.00'.
perform bdc_field using 'EBAN-WAERS'
'EUR'.
perform bdc_field using 'EBAN-PEINH'
'1'.
perform bdc_field using 'EBAN-REPOS'
'X'.
perform bdc_dynpro using 'SAPMM06B' '0102'.
perform bdc_field using 'BDC_CURSOR'
'EBAN-MENGE'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'EBAN-TXZ01'
'DRILLING PIPE 10"'.
perform bdc_field using 'EBAN-MENGE'
'75'.
perform bdc_field using 'RM06B-EEIND'
'2005/01/03'.
perform bdc_field using 'RM06B-LPEIN'
'D'.
perform bdc_field using 'EBAN-EKGRP'
'M11'.
perform bdc_field using 'EBAN-BADAT'
'2005/01/03'.
perform bdc_field using 'EBAN-FRGDT'
'2005/01/03'.
perform bdc_field using 'EBAN-PREIS'
' 0.53'.
perform bdc_field using 'EBAN-WAERS'
'EUR'.
perform bdc_field using 'EBAN-PEINH'
'1'.
perform bdc_field using 'EBAN-REPOS'
'X'.
perform bdc_dynpro using 'SAPMM06B' '0106'.
perform bdc_field using 'BDC_CURSOR'
'RM06B-BNFPO'
perform bdc_field using 'BDC_OKCODE'
'&H3DBU'.
*perform bdc_field using 'RM06B-BNFPO'
CALL TRANSACTION 'ME51' USING BDC_DATA MODE 'A'.
endLOOP.
FORM upload_data.
*local variable declaration
DATA : lv_index TYPE i,
l_count TYPE i.
*local constants declaration
CONSTANTS:
lc_start_col TYPE i VALUE '1' ,
lc_start_row TYPE i VALUE '2' ,
lc_end_col TYPE i VALUE '256' ,
lc_end_row TYPE i VALUE '65536'.
*local field symbol declaration
FIELD-SYMBOLS : <lf_s>.
*loacal internal table declaration
DATA : li_intern TYPE kcde_cells OCCURS 0 WITH HEADER LINE.
*refresh internal table for each loop
CLEAR: li_intern,
l_count .
REFRESH li_intern.
to upload the data in excel on the presentation server this function
module converts the data from excel file into an internal table
containing row no col no and value
CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'
EXPORTING
filename &H3D 'Give file location here'
i_begin_col &H3D lc_start_col
i_begin_row &H3D lc_start_row
i_end_col &H3D lc_end_col
i_end_row &H3D lc_end_row
TABLES
intern &H3D li_intern
EXCEPTIONS
inconsistent_parameters &H3D 1
upload_ole &H3D 2.
checking for data in internal table
CHECK NOT li_intern[] IS INITIAL.
sorting internal table
SORT li_intern BY row col.
collecting data into an internal table
LOOP AT li_intern.
MOVE: li_intern-col TO lv_index.
lv_index &H3D lv_index + 1.
ASSIGN COMPONENT lv_index OF STRUCTURE itab TO <lf_s>.
MOVE : li_intern-value TO <lf_s>.
AT END OF row.
l_count &H3D l_count + 1.
itab &H3D l_count.
APPEND itab.
ENDAT. " at end of row
ENDLOOP. " loop at li_intern
Reg,
Siva
Edited by: Siva Prasad on Jun 1, 2009 8:41 AM
Edited by: Siva Prasad on Jun 1, 2009 4:25 PM -
Moving data from internal table to Dynamic internal table
Hello All,
I am facing a problem i moving the data from a internal table data to Dyn. internal table.
My code is as follows
*******Declartion**************************************
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.
DATA: IT_OUTTAB TYPE STANDARD TABLE OF ZVTEST.
DATA: WA_OUTTAB TYPE ZVTEST.
DATA: LV_LINE LIKE SY-TABIX,
COUNT TYPE I.
FIELD-SYMBOLS: <NEW_TABLE> TYPE REF TO DATA.
FIELD-SYMBOLS: <L_TABLE> TYPE ANY TABLE,
<L_LINE> TYPE ANY.
FIELD-SYMBOLS: <L_FIELD> TYPE ANY.
FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
<FS_1> TYPE ANY TABLE,
<FS_2>,
<FS_3>.
DATA: NEW_LINE TYPE REF TO DATA.
DATA: LT_DATA TYPE REF TO DATA.
ASSIGN LT_DATA TO <FS_DATA>.
Create a new Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT
IMPORTING
EP_TABLE = <FS_DATA>
EXCEPTIONS
GENERATE_SUBPOOL_DIR_FULL = 1
OTHERS = 2.
IF SY-SUBRC = 0.
ASSIGN <FS_DATA>->* TO <FS_1>.
CREATE DATA NEW_LINE LIKE LINE OF <FS_1>.
A field-symbol to access that work area
ASSIGN NEW_LINE->* TO <FS_2>.
LOOP AT IT_OUTTAB INTO WA_OUTTAB.
MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.
ENDLoop.
But when I am using MOVE-CORRESPONDING WA_OUTTAB TO <FS_1>.
I am getting the error like
"<FS_1>" is not a structure or internal table with header line.
Please check the code and tell where I am making the mistake.
Regards,
VasanthHello Rich ,
My is code is as below..
Declaration:
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
IS_FIELDCAT LIKE LINE OF IT_FIELDCAT.
DATA: BEGIN OF IT_OUTTAB OCCURS 0,
PSPID LIKE PROJ-PSPID, "Projektdefinition
POSID LIKE PRPS-POSID, "PSP-Element
POST1 LIKE PRPS-POST1, "Kurzbeschreibung
STTXT_INT LIKE CNJ_STAT-STTXT_INT, "Systemstatus
STTXT_EXT LIKE CNJ_STAT-STTXT_EXT, "Anwenderstatus
END OF IT_OUTTAB.
DATA: WA_OUTTAB LIKE IT_OUTTAB.
DATA: LV_LINES LIKE SY-TABIX,
COUNT TYPE I.
FIELD-SYMBOLS: type any.
DATA: NEW_LINE TYPE REF TO DATA.
DATA: LT_DATA TYPE REF TO DATA.
G_R_DISP_VARIANT-REPORT = SY-REPID.
G_R_DISP_VARIANT-VARIANT = PA_VAR.
CALL FUNCTION 'REUSE_ALV_VARIANT_SELECT'
EXPORTING
I_DIALOG = 'N'
I_USER_SPECIFIC = 'A'
I_DEFAULT = 'X'
IT_DEFAULT_FIELDCAT = G_T_FIELDCAT
I_LAYOUT = G_R_LAYOUT
IMPORTING
ET_FIELDCAT = G_T_FIELDCAT
et_sort = l_tab_sort
et_filter = l_tab_filter
ES_LAYOUT = G_R_LAYOUT
CHANGING
CS_VARIANT = G_R_DISP_VARIANT
EXCEPTIONS
ERROR_MESSAGE = 4
OTHERS = 4.
LOOP AT G_T_FIELDCAT INTO G_R_FIELDCAT WHERE NO_OUT IS INITIAL
AND TECH IS INITIAL.
MOVE-CORRESPONDING G_R_FIELDCAT TO IS_FIELDCAT.
IS_FIELDCAT-FIELDNAME = G_R_FIELDCAT-FIELDNAME.
IS_FIELDCAT-INTTYPE = G_R_FIELDCAT-INTTYPE.
IS_FIELDCAT-OUTPUTLEN = G_R_FIELDCAT-OUTPUTLEN.
IS_FIELDCAT-REF_FIELD = G_R_FIELDCAT-FIELDNAME.
IS_FIELDCAT-REF_TABLE = G_R_FIELDCAT-REF_TABNAME.
APPEND IS_FIELDCAT TO IT_FIELDCAT.
ENDLOOP.
DATA: WA_LISTE LIKE P_T_LISTE.
CLEAR:IT_OUTTAB.
REFRESH: IT_OUTTAB.
LOOP AT P_T_LISTE INTO WA_LISTE.
WA_OUTTAB-PSPID = WA_LISTE-PSPID .
WA_OUTTAB-POSID = WA_LISTE-POSID.
WA_OUTTAB-POST1 = WA_LISTE-POST1.
WA_OUTTAB-STTXT_INT = WA_LISTE-STTXT_INT.
WA_OUTTAB-STTXT_EXT = WA_LISTE-STTXT_EXT.
APPEND WA_OUTTAB TO IT_OUTTAB.
ENDLOOP.
**dynamic table creation for data
ASSIGN LT_DATA TO .
Create a new Table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT
IMPORTING
EP_TABLE = .
A field-symbol to access that work area
ASSIGN NEW_LINE->* TO = WA_OUTTAB-PSPID.
ASSIGN COMPONENT 'POSID' OF STRUCTURE WA_OUTTAB TO <FS_3>.
ASSIGN COMPONENT 'POSID' OF STRUCTURE = WA_OUTTAB-POSID.
ASSIGN COMPONENT 'POST1' OF STRUCTURE WA_OUTTAB TO <FS_3>.
ASSIGN COMPONENT 'POST1' OF STRUCTURE .
<FS_5> = <FS_3>.
= WA_OUTTAB-POST1.
ASSIGN COMPONENT 'STTXT_INT' OF STRUCTURE WA_OUTTAB TO <FS_3>.
ASSIGN COMPONENT 'STTXT_INT' OF STRUCTURE TO P_FILE.
ENDLOOP.
ELSE.
MESSAGE E041(S9) WITH P_FILE.
ENDIF.
CLOSE DATASET P_FILE.
Here my problem is ´´, I am not able to use move corresponding statement.
So I am not getting the exact values to the fields of the dynamic table...
Please check it and give me a solution,
Regards,
Vasanth -
Moving data in internal tables
hi
I have defined an internal table(say itab_master) and one of its field is table name which will store name of some other internal table(say itab2, itab3..etc).
now i want to move data into the tables(itab2, itab3..etc) selected as per row of itab1_master.
kindly suggest me way of doing it.
thnkshi there,
FIrst you declare :
FIELD-SYMBOLS <fs> TYPE ANY TABLE.
ASSIGN itab_temp <fs>.
Note : If itab2 ,itab3..... are having the same structure there is now problem
Else you have to use FIELD-GROUPS.
Doc...
Defining an Extract
To define an extract, you must first declare the individual records and then define their structure.
Declaring Extract Records as Field Groups
An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type. You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.
FIELD-GROUPS <fg>.
This statement defines a field group <fg>. A field group combines several fields under one name. For clarity, you should declare your field groups at the end of the declaration part of your program.
A field group does not reserve storage space for the fields, but contains pointers to existing fields. When filling the extract dataset with records, these pointers determine the contents of the stored records.
You can also define a special field group called HEADER:
FIELD-GROUPS HEADER.
This group is automatically placed before any other field groups when you fill the extract. This means that a record of a field group <fg> always contains the fields of the field group HEADER. When sorting the extract dataset, the system uses these fields as the default sort key.
Defining the Structure of a Field Group
To define the structure of a record, use the following statement to add the required fields to a field group:
INSERT <f1>... <f n> INTO <fg>.
This statement defines the fields of field group <fg>. Before you can assign fields to a field group, you must define the field group <fg> using the FIELD-GROUPS statement. The fields in the field group must be global data objects in the ABAP program. You cannot assign a local data object defined in a procedure to a field group.
The INSERT statement, just as the FIELD-GROUPS statement, neither reserves storage space nor transfers values. You use the INSERT statement to create pointers to the fields <f i > in the field group <fg>, thus defining the structures of the extract records.
When you run the program, you can assign fields to a field group up to the point when you use this field group for the first time to fill an extract record. From this point on, the structure of the record is fixed and may no longer be changed. In short, as long as you have not used a field group yet, you can still extend it dynamically.
The special field group HEADER is part of every extract record. Consequently, you may not change HEADER once you have filled the first extract record.
A field may occur in several field groups; however, this means unnecessary data redundancy within the extract dataset. You do not need to define the structure of a field group explicitly with INSERT. If the field group HEADER is defined, an undefined field group consists implicitly of the fields in HEADER, otherwise, it is empty.
NODES: SPFLI, SFLIGHT.
FIELD-GROUPS: HEADER, FLIGHT_INFO, FLIGHT_DATE.
INSERT: SPFLI-CARRID SPFLI-CONNID SFLIGHT-FLDATE
INTO HEADER,
SPFLI-CITYFROM SPFLI-CITYTO
INTO FLIGHT_INFO.
The program is linked to the logical database F1S. The NODES statement declares the corresponding interface work areas.
There are three field groups. The INSERT statement assigns fields to two of the field groups.
Filling an Extract with Data
Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
EXTRACT <fg>.
When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. If you do not explicitly specify a field group <fg>, the
EXTRACT
statement is a shortened form of the statement
EXTRACT HEADER.
When you extract the data, the record is filled with the current values of the corresponding fields.
As soon as the system has processed the first EXTRACT statement for a field group <fg>, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups <fg> and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
Assume the following program is linked to the logical database F1S.
REPORT demo_extract_extract.
NODES: spfli, sflight.
FIELD-GROUPS: header, flight_info, flight_date.
INSERT: spfli-carrid spfli-connid sflight-fldate
INTO header,
spfli-cityfrom spfli-cityto
INTO flight_info.
START-OF-SELECTION.
GET spfli.
EXTRACT flight_info.
GET sflight.
EXTRACT flight_date.
There are three field groups. The INSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group FLIGHT_INFO consist of five fields: SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE, SPFLI-CITYFROM, and SPFLI-CITYTO. The first three fields belong to the prefixed field group HEADER. The records of the field group FLIGHT_DATE consist only of the three fields of field group HEADER. The following figure shows the structure of the extract dataset:
Reading an Extract
Like internal tables, you can read the data in an extract dataset using a loop.
LOOP.
[AT FIRST | AT <fgi> WITH <fg j> | AT LAST.
ENDAT.]
ENDLOOP.
When the LOOP statement occurs, the system stops creating the extract dataset, and starts a loop through the entries in the dataset. One record from the extract dataset is read in each loop pass. The values of the extracted fields are placed in the corresponding output fields within the loop. You can use several loops one after the other, but they cannot be nested. It is also no longer possible to use further EXTRACT statements within or after the loop. In both cases, a runtime error occurs.
In contrast to internal tables, extract datasets do not require a special work area or field symbol as an interface. Instead, you can process each record of the dataset within the loop using its original field names.
Loop control
If you want to execute some statements for certain records of the dataset only, use the control statements AT and ENDAT.
The system processes the statement blocks between the control statements for the different options of AT as follows:
AT FIRST
The system executes the statement block once for the first record of the dataset.
AT <fgi> WITH <fgj>
The system processes the statement block, if the record type of the currently read extract record was defined using the field group <fg i >. When using the WITH <fg j > option, in the extract dataset, the currently read record of field group <fg i > must be immediately followed by a record of field group <fg j >.
AT LAST
The system executes the statement block once for the last record of the dataset.
You can also use the AT and ENDAT statements for control level processing.
Assume the following program is linked to the logical database F1S.
REPORT DEMO.
NODES: SPFLI, SFLIGHT.
FIELD-GROUPS: HEADER, FLIGHT_INFO, FLIGHT_DATE.
INSERT: SPFLI-CARRID SPFLI-CONNID SFLIGHT-FLDATE
INTO HEADER,
SPFLI-CITYFROM SPFLI-CITYTO
INTO FLIGHT_INFO.
START-OF-SELECTION.
GET SPFLI.
EXTRACT FLIGHT_INFO.
GET SFLIGHT.
EXTRACT FLIGHT_DATE.
END-OF-SELECTION.
LOOP.
AT FIRST.
WRITE / 'Start of LOOP'.
ULINE.
ENDAT.
AT FLIGHT_INFO WITH FLIGHT_DATE.
WRITE: / 'Info:',
SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE,
SPFLI-CITYFROM, SPFLI-CITYTO.
ENDAT.
AT FLIGHT_DATE.
WRITE: / 'Date:',
SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE.
ENDAT.
AT LAST.
ULINE.
WRITE / 'End of LOOP'.
ENDAT.
ENDLOOP.
The extract dataset is created and filled in the same way as shown in the example for Filling an Extract with Data. The data retrieval ends before the END-OF-SELECTION event, in which the dataset is read once using a loop.
The control statements AT FIRST and AT LAST instruct the system to write one line and one underscore line in the list, once at the beginning of the loop and once at the end.
The control statement AT <fg i > tells the system to output the fields corresponding to each of the two record types. The WITH FLIGHT_DATE option means that the system only displays the records of field group FLIGHT_INFO if at least one record of field group FLIGHT_DATE follows; that is, if the logical database passed at least one date for a flight.
The beginning of the output list looks like this:
The contents of the field SFLIGHT-FLDATE in the HEADER part of record type FLIGHT_INFO are displayed as pound signs (#). This is because the logical database fills all of the fields at that hierarchy level with the value HEX 00 when it finishes processing that level. This feature is important for sorting and for processing control levels in extract datasets.
rewards would be appreciated. -
Populating data into internal table created dynamically
Hi all,
I have created an internal table dynamically using the method
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT2[]
IMPORTING
EP_TABLE = L_TABLE.
ASSIGN L_TABLE->* TO <IT_TABLE>.
CREATE DATA wa_table LIKE LINE OF <it_table>.
ASSIGN wa_table->* TO <wa_table1>.
when I tried to append data into the internal table <it_table>
as below
ex : <wa_table1>-prueflos = wa_item-prueflos.
it is giving the error as 'The data object <wa_table1> has no structure therefore no component called prueflos'.
can anybody tell me how to append data into a dynamically created internal table.
Thanks,
SudheerHi Sudheer,
You need to use the ASSIGN COMPONENT command for this purpose. Check this code:
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, u201C Dynamic internal table name
<fs_dyntable>, u201C Field symbol to create work area
<fs_fldval> type any. u201C Field symbol to assign values
* Assume your internal table has fields COL1, COL2, COL3 etc
DO p_cols TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL'
wa_colno
INTO wa_flname.
* Set up fieldvalue
CONCATENATE 'VALUE' index INTO
fieldvalue.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDDO.
Hope this solves your problem!
Cheers,
Shailesh. -
What is the best way to declare field length 500 in internal table?
Hi all,
what is the best way to declare field length 500(constant value allways) in internal table?
I am trying to send data from internal table to file format, and I have a field in internal table with 500 length (constant value always). So how do I can declare and append this field value to table?
Thanks
MuraliHi. Please see the following example program, notice how I am filling the field with the constant value.
report zrich_0001.
* CLASS lcl_main DEFINITION
class lcl_main definition.
public section.
types: begin of ttab,
fld1(500) type c,
end of ttab.
data: itab type table of ttab.
data: xtab type ttab.
methods: constructor,
write_itab.
endclass.
* CLASS lcl_main IMPLEMENTATION
class lcl_main implementation.
method constructor.
<b>
xtab-fld1 =
'This is one part of the total string which needs to be really' &
' long and this is a constant and we need to move it to a work' &
' area and then append it to the internal table which has a' &
' field with a length of five hundred characters'.
append xtab to itab.</b>
endmethod.
method write_itab.
loop at itab into xtab.
write:/ xtab-fld1.
endloop.
endmethod.
endclass.
data: o_main type ref to lcl_main.
start-of-selection.
create object o_main.
call method o_main->write_itab.
Regards,
Rich Heilman -
Getting field names of an internal table
Hi all,
Does anyone know if exists a statement, function module or method that gets the field names of an internal table ?
Thanks in advance,
DavidHi,
See this
REPORT typedescr_test.
TYPES:
BEGIN OF my_struct,
comp_a type i,
comp_b type f,
END OF my_struct.
DATA:
my_data TYPE my_struct,
descr_ref TYPE ref to cl_abap_structdescr.
FIELD-SYMBOLS:
<comp_wa> TYPE abap_compdescr.
START-OF-SELECTION.
descr_ref ?= cl_abap_typedescr=>describe_by_data( my_data ).
WRITE: / 'Typename :', descr_ref->absolute_name.
WRITE: / 'Kind :', descr_ref->type_kind.
WRITE: / 'Length :', descr_ref->length.
WRITE: / 'Decimals :', descr_ref->decimals.
WRITE: / 'Struct Kind :', descr_ref->struct_kind.
WRITE: / 'Components'.
WRITE: / 'Name Kind Length Decimals'.
LOOP AT descr_ref->components ASSIGNING <comp_wa>.
WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
<comp_wa>-length, <comp_wa>-decimals.
ENDLOOP.
Maybe you are looking for
-
The new entries made in /etc/hosts file is not picked up by Weblogic.
Hi All, I have come across a scenario where i have changed the IP address of a particular host name (which was already present in etc/hosts) to point to a new IP address. After i did this change, when i do a telnet test to the same hostname, i can se
-
C2-03 Hugely disappointed - very poor phone
Having struggled with a Samsung D780 for several years because Nokia did not produce a dual SIM I waited months for the C2-03 to become available in UK. I finally and eagerly got one from Singapore and what a disappointment it is. I do not want a s
-
Prevent macbook air to sleep when lid closed
Hi All I would like to know since I've already tried to configure it but it still do not work, I am trying to prevent my macbook air to sleep while the lid is closed and on power adaptor. I went to energy and preferences but i couldn't find any setti
-
Sending ringtones to Nokia Surge as picture messag...
So, I just got the Surge without the data plan (for now). On my old phone, I was able to go to mobile17.com, make a ringtone and send it as a picture message and walla! - ringtone on my phone. However, with the Surge it doesn't give me the option to
-
I had to reinstall my hard drive and now my iphoto is gone
when I reinstalled my hard drive i realized that a few of the apps that came with my laptop are now gone. Does anyone know how to get iPhoto back? thats the only one I care about and I dont feel as though I should have to purchase it if it came with