‎2008 Mar 25 4:05 AM
hi everyone,
i generated a internal table dynamically,the output is in fied symbol,i want to create a internal table using the field symbol sturture,how to create that????
plz tell me how to create a internal table referencing field symbol structure........
very urgent plz help.........
thanks in advance....
regards,
balaji.s
‎2008 Mar 25 4:08 AM
HI,
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY .
Data:it_fieldcat TYPE lvc_t_fcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = dyn_table.
ASSIGN dyn_table->* TO <dyn_table>.
CREATE DATA dyn_line LIKE LINE OF <dyn_table>.
ASSIGN dyn_line->* TO <dyn_wa>.
IT_FIELDCAT is a strucure.
<dyn_table> is internal table
<dyn_wa> is work area of the table <dyn_table>
Reward if helpful
Regards
Vodka.
‎2008 Mar 25 4:10 AM
Hai.
check the example codes..
Dynamic internal table is internal table that we create on the fly with flexible column numbers.
For sample code, please look at this code tutorial. Hopefully it can help you
Check this link:
http://www.saptechnical.com/Tutorials/ABAP/DynamicInternaltable/DynamicInternalTable.htm
Sample code:
DATA: l_cnt(2) TYPE n,
l_cnt1(3) TYPE n,
l_nam(12),
l_con(18) TYPE c,
l_con1(18) TYPE c,
lf_mat TYPE matnr.
SORT it_bom_expl BY bom_comp bom_mat level.
CLEAR: l_cnt1, <fs_dyn_wa>.
Looping the component internal table
LOOP AT it_bom_expl INTO gf_it_bom_expl.
CLEAR: l_cnt1.
AT NEW bom_comp.
CLEAR: l_cnt, <fs_dyn_wa>, lf_mat.
For every new bom component the material data is moved to
temp material table which will be used for assigning the levels
checking the count
it_mat_temp[] = it_mat[].
Component data is been assigned to the field symbol which is checked
against the field of dynamic internal table and the value of the
component number is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_comp_list OF STRUCTURE <fs_dyn_wa> TO
<fs_check>.
<fs_check> = gf_it_bom_expl-bom_comp.
ENDAT.
AT NEW bom_mat.
CLEAR l_con.
ENDAT.
lf_mat = gf_it_bom_expl-bom_mat.
Looping the temp internal table and looping the dynamic internal table
*by reading line by line into workarea, the materialxxn is been assigned
to field symbol which will be checked and used.
LOOP AT it_mat_temp.
l_nam = c_mat.
l_cnt1 = l_cnt1 + 1.
CONCATENATE l_nam l_cnt1 INTO l_nam.
LOOP AT <fs_dyn_table2> ASSIGNING <fs_dyn_wa2>.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa2> TO <fs_xy>.
ENDLOOP.
IF <fs_xy> = lf_mat.
CLEAR lf_mat.
l_con1 = l_con.
ENDIF.
Checking whether the material exists for a component and if so it is
been assigned to the field symbol which is checked against the field
of dynamic internal table and the level of the component number
against material is been passed to the dynamic internal table field
value.
IF <fs_xy> = gf_it_bom_expl-bom_mat.
ASSIGN COMPONENT l_nam OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
CLEAR l_con.
MOVE gf_it_bom_expl-level TO l_con.
CONCATENATE c_val_l l_con INTO l_con.
CONDENSE l_con NO-GAPS.
IF l_con1 NE space.
CONCATENATE l_con1 l_con INTO l_con SEPARATED BY c_comma.
CLEAR l_con1.
l_cnt = l_cnt - 1.
ENDIF.
<fs_check> = l_con.
l_cnt = l_cnt + 1.
ENDIF.
ENDLOOP.
AT END OF bom_comp.
At end of every new bom component the count is moved to the field
symbol which is checked against the field of dynamic internal table
and the count is been passed to the dynamic internal table field
value.
ASSIGN COMPONENT c_count OF STRUCTURE <fs_dyn_wa> TO <fs_check>.
<fs_check> = l_cnt.
INSERT <fs_dyn_wa> INTO TABLE <fs_dyn_table>.
ENDAT.
ENDLOOP.
-
Select-options: s_bukrs for t001-bukrs,
s_pfolio for ztab-pfolio.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pfolio-low.
PERFORM f4_for_portfolios.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_pfolio-high.
PERFORM f4_for_portfolios.
FORM f4_for_portfolios.
l_dynpro = sy-repid.
l_dynnar = sy-dynnr.
for parameters/one single value(low/high) of select-option this is OK,
If i give 'S_BUKRS' it is giving dump.
it_dynpfields-fieldname = 'S_BUKRS-LOW'.
APPEND it_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = l_dynpro
dynumb = l_dynnar " '1000'
translate_to_upper = 'X'
TABLES
dynpfields = it_dynpfields.
READ TABLE it_dynpfields INDEX 1.
REFRESH r_bukrs.
IF NOT it_dynpfields-fieldvalue IS INITIAL.
r_bukrs-low = it_dynpfields-fieldvalue.
r_bukrs-sign = 'I'.
r_bukrs-option = 'EQ'.
APPEND r_bukrs.
ENDIF.
SELECT abukrs aportfolio b~xportb
INTO TABLE it_plo
FROM ( zlt_mandate AS a
INNER JOIN twpob AS b
ON abukrs = bbukrs
AND aportfolio = brportb )
WHERE a~bukrs IN r_bukrs . "= it_dynpfields-fieldvalue.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'PORTFOLIO'
dynpprog = l_dynpro
dynpnr = l_dynnar
dynprofield = 'S_PFOLIO-LOW'
value_org = 'S'"C
display = 'F'
TABLES
value_tab = it_plo.
ENDFORM. "get_portfolios
regards.
sowjanya.b
‎2008 Mar 25 4:23 AM
Hi,
See this code, i think it may help u.
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.
FIELD-SYMBOLS: <ITAB> TYPE ANY TABLE, " used to store dynamic tables
<WA> TYPE ANY, " used to store record data
<WA1> TYPE ANY . " used to store field data
LV_DBTAB1 = 'MARA'.
data: it_mara like mara occurs 0 with header line.
CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN DREF->* TO <ITAB> .
selects all data
SELECT * FROM (LV_DBTAB1) INTO TABLE <ITAB> .
LOOP AT <ITAB> ASSIGNING <WA>.
APPEND <WA> TO IT_MARA.
ENDLOOP.
Cheers,
vasavi.