Application Development 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: 

dynamic internal table

Former Member
0 Kudos

hello experts...

i am creating a dynamic internal table.

how can i move the fields from i_tab into the dynamic table <dyn_tab>?

thank you.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

DATA: lw_fieldvalue(40) TYPE c,

lw_fieldname(30) TYPE c.

gwa_output TYPE REF TO data.

FIELD-SYMBOLS: <gwa_output> TYPE ANY.

FIELD-SYMBOLS: <l_fvalue> TYPE ANY.

*---Create a pointer to store the workarea of the final output table.

CREATE DATA gwa_output LIKE LINE OF <git_output>.(this is the output table)

*---Assign it to a fieldsymbol which will be used in populating the

*---final output table.

ASSIGN gwa_output->* TO <gwa_output>.

Loop at i_tab into wa_tab.

move wa_tab-field1 to v_fieldvalue. (moving the first field value into field value variable).

CONDENSE v_fieldvalue NO-GAPS. (Condense the output).

CLEAR: <gwa_output>.

ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <gwa_output> TO <l_fvalue>.

<l_fvalue> = V_fieldvalue.

<b>Repeat the same with other fields</b>

*---Append the current record to final output table.

APPEND <gwa_output> TO <git_output>.

endloop.

Regards,

Bharat.

4 REPLIES 4

Former Member
0 Kudos

Hi,

DATA: lw_fieldvalue(40) TYPE c,

lw_fieldname(30) TYPE c.

gwa_output TYPE REF TO data.

FIELD-SYMBOLS: <gwa_output> TYPE ANY.

FIELD-SYMBOLS: <l_fvalue> TYPE ANY.

*---Create a pointer to store the workarea of the final output table.

CREATE DATA gwa_output LIKE LINE OF <git_output>.(this is the output table)

*---Assign it to a fieldsymbol which will be used in populating the

*---final output table.

ASSIGN gwa_output->* TO <gwa_output>.

Loop at i_tab into wa_tab.

move wa_tab-field1 to v_fieldvalue. (moving the first field value into field value variable).

CONDENSE v_fieldvalue NO-GAPS. (Condense the output).

CLEAR: <gwa_output>.

ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <gwa_output> TO <l_fvalue>.

<l_fvalue> = V_fieldvalue.

<b>Repeat the same with other fields</b>

*---Append the current record to final output table.

APPEND <gwa_output> TO <git_output>.

endloop.

Regards,

Bharat.

0 Kudos

Thank you.

This could be of help.

naimesh_patel
Active Contributor
0 Kudos

You need to assign the component of table <dyn_Tab> to field symbol and than give value to that field symbol.

Like:

ASSIGN COMPONENT FLD1 OF STRUCTURE <DYN_TAB> TO <FS>.

<FS> = I_TAB-FLD1.

Regards,

Naimesh Patel

0 Kudos

Thank you!