Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Filling dynamic internal table

Former Member
0 Likes
783

Hi,

I have a requirement where I have to display randomly generated columns ( Run time). So I hv created a dynamic internal table.

Structure of that table :-

it1 --> Field(fix) field2(Fix) CC1 CC2 ..........etc. ( From CC1, thiese fields cab be up to any no).

I have my dynamically created interal no and work area.But I am not able to fill this internal table as it's column is defined randomly.

Can you guy pls thorw some light on this issue.

Thanks in Advanced..!!

Rgds,

Aks

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
592

Indeed you can't access these columns statically (by just writting work area and component name) as they might not be included in the table structure, however you can easily access them dynamically (by providing this component name as a variable). For this you need a field symbol and the approach like


data l_field type string.
field-symbols <field> type any.

l_field = 'FIELD1'.
ASSIGN COMPONENT l_field OF STRUCTURE l_dyn_work_area TO <FIELD>.
<FIELD> = "now put your required value here to fill the 'FIELD1' in your strcture

If still not clear just do search around ASSIGN COMPONENT

Regards

Marcin

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
592

Search this forum with keyword "assign component" you can find lot of threads related how to fill dynamic IT.

a®

Read only

MarcinPciak
Active Contributor
0 Likes
593

Indeed you can't access these columns statically (by just writting work area and component name) as they might not be included in the table structure, however you can easily access them dynamically (by providing this component name as a variable). For this you need a field symbol and the approach like


data l_field type string.
field-symbols <field> type any.

l_field = 'FIELD1'.
ASSIGN COMPONENT l_field OF STRUCTURE l_dyn_work_area TO <FIELD>.
<FIELD> = "now put your required value here to fill the 'FIELD1' in your strcture

If still not clear just do search around ASSIGN COMPONENT

Regards

Marcin

Read only

Former Member
0 Likes
592

Hi,

Here dynamically colums will be create and internal table created for that LFA1 table otherwise.

You can declare the types declaration.

TYPES:BEGIN OF TY_DATA,

LIFNR TYPE LIFNR,

END OF TY_DATA.

DATA: pannnn_ref TYPE REF TO data,

pnnnn_str TYPE REF TO cl_abap_structdescr,

pannnn_wa_ref TYPE REF TO data.

FIELD-SYMBOLS :<psnnnn> TYPE STANDARD TABLE,

<pannnn_wa> TYPE ANY,

<pacccc_wa> TYPE c,

<value> TYPE ANY.

data:dbtab type string value 'LFA1'.

CREATE DATA pannnn_ref TYPE STANDARD TABLE OF (dbtab). "TY_DATA that also we can give

ASSIGN pannnn_ref->* TO <psnnnn>.

CREATE DATA pannnn_wa_ref TYPE (dbtab).

ASSIGN pannnn_wa_ref->* TO <pannnn_wa>.

ASSIGN <pannnn_wa> TO <pacccc_wa> CASTING.

regards.

muralii