2011 Jul 26 2:58 PM
HI All
There is a way to create data dynamically if i have in parameter field length
like char10 or KUNNR or char25.
Thanks,
Joy
2011 Jul 26 3:18 PM
field-symbol: <fs_dyn_wa> TYPE ANY.
loop at lt_tab INTO ls_tab.
CREATE DATA kunnr TYPE (ls_tab-fieldname).
or if you have a fixed strucutre for the fields in the internal table, define the workarea and use the below code to push the values
MOVE ls_tab-fieldname TO ls_fieldname.
ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_dyn_wa> TO <fs_val>.
endloop.
Edited by: ssm on Jul 26, 2011 7:51 PM
HI All
There is a way to create data dynamically if i have in parameter field length
like char10 or KUNNR or char25.
Thanks,
Joy
2011 Jul 26 3:00 PM
DATA: lv_kunnr TYPE kunnr.
DATA: kunnr TYPE REF TO data.
field-symbols: <fs_kunnr> TYPE ANY.
CREATE DATA kunnr TYPE kunnr.
lv_kunnr = '123'.
ASSIGN kunnr->* TO <fs_kunnr>.
move lv_kunnr to <fs_kunnr>.
write: <fs_kunnr>.
Edited by: ssm on Jul 26, 2011 7:30 PM
Edited by: ssm on Jul 26, 2011 7:34 PM
2011 Jul 26 3:08 PM
HI SSM,
thanks ,
but i have table itab like as follows
and i want to create the data dynamic
Field name type
SORTL 000010
PSTLZ 000010
MCOD3 000025
MCOD1 000025
KUNNR 000010Thanks,
Joy
2011 Jul 26 3:05 PM
you can use the field symbol <fs_kunnr> further with the abve example
2011 Jul 26 3:10 PM
Check the Forums for RTTS and RTTC , this will help you in the issue .
2011 Jul 26 3:13 PM
https://wiki.sdn.sap.com/wiki/display/Snippets/StepstoCreateTypeDynamically
Please check this link
2011 Jul 26 3:12 PM
Do you have any fixed structure for these fields which you have in our internal tbale?
2011 Jul 26 3:13 PM
You can create data using dynamic reference or type/length
* Common data
DATA dref TYPE REF TO data.
FIELD-SYMBOLS <fs> TYPE ANY.
*
DATA name TYPE TYPE c LENGTH 10.
CREATE DATA dref TYPE (name). " from the body part of your post
* OR
DATA: integer TYPE I.
CREATE DATA dref TYPE 'c' LENGTH integer. " from the header of your post
* Assign to a field symbol
ASSIGN dref->* TO <fs>.Regards,
Raymond
2011 Jul 26 3:18 PM
field-symbol: <fs_dyn_wa> TYPE ANY.
loop at lt_tab INTO ls_tab.
CREATE DATA kunnr TYPE (ls_tab-fieldname).
or if you have a fixed strucutre for the fields in the internal table, define the workarea and use the below code to push the values
MOVE ls_tab-fieldname TO ls_fieldname.
ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_dyn_wa> TO <fs_val>.
endloop.
Edited by: ssm on Jul 26, 2011 7:51 PM