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

Dynamic Internal Table Filling

Former Member
0 Likes
823

Hi Friends,

this is a test code.

DO 4 TIMES.
  index = sy-index.

  MOVE sy-index TO wa_colno.

  CONCATENATE 'COL' wa_colno INTO wa_fldname.


  CONCATENATE 'VALUE' index INTO fieldvalue.

  CONDENSE fieldvalue NO-GAPS.
  CLEAR <fs_dyntable>.
  ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.

  <fs_fldval> = fieldvalue.

  APPEND <fs_dyntable> TO <t_dyntable>.

ENDDO.

*the output of this code is like this *

col1--col2--col3----col4

-value1

-


value2

-


value3

-


value4

I like to have the output like

col1--col2--col3----col4

value1 value2 value3 value4

could u please help me with the modified code.

thanks ,

Kat.

Edited by: kat k on Feb 5, 2009 3:52 PM

Edited by: kat k on Feb 5, 2009 3:53 PM

Edited by: Matt on Feb 5, 2009 4:01 PM - added tags

Hi Friends,

this is a test code.

DO 4 TIMES.
  index = sy-index.

  MOVE sy-index TO wa_colno.

  CONCATENATE 'COL' wa_colno INTO wa_fldname.


  CONCATENATE 'VALUE' index INTO fieldvalue.

  CONDENSE fieldvalue NO-GAPS.
  CLEAR <fs_dyntable>.
  ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.

  <fs_fldval> = fieldvalue.

  APPEND <fs_dyntable> TO <t_dyntable>.

ENDDO.

*the output of this code is like this *

col1--col2--col3----col4

-value1

-


value2

-


value3

-


value4

I like to have the output like

col1--col2--col3----col4

value1 value2 value3 value4

could u please help me with the modified code.

thanks ,

Kat.

Edited by: kat k on Feb 5, 2009 3:52 PM

Edited by: kat k on Feb 5, 2009 3:53 PM

Edited by: Matt on Feb 5, 2009 4:01 PM - added tags

6 REPLIES 6
Read only

Former Member
0 Likes
802

!

Edited by: riki frisky on Feb 5, 2009 3:55 PM

Read only

0 Likes
802

This appends only last record i.e only value is added to 1st row last column

col1-col2col3--col4

-


value4

and any more tricks

Edited by: kat k on Feb 5, 2009 4:01 PM

Read only

0 Likes
802

try.

DO 4 TIMES.
index = sy-index.
l_tabix = 1.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL' wa_colno INTO wa_fldname.
CONCATENATE 'VALUE' index INTO fieldvalue.
CONDENSE fieldvalue NO-GAPS.
CLEAR <fs_dyntable>.
ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
Modify  <t_dyntable> from <fs_dyntable> index l_tabix.
ENDDO.

Edited by: riki frisky on Feb 5, 2009 4:04 PM

Read only

matt
Active Contributor
0 Likes
802
DO 4 TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL' wa_colno INTO wa_fldname.
CONCATENATE 'VALUE' index INTO fieldvalue.
CONDENSE fieldvalue NO-GAPS.
* CLEAR <fs_dyntable>. " You don't need this statement
ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDDO.
 
APPEND <fs_dyntable> TO <t_dyntable>. " This needs to be outside the DO loop
Read only

faisalatsap
Active Contributor
0 Likes
802

Hi,

Do like following my solve out your problem,

DO 4 TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL' wa_colno INTO wa_fldname.
CONCATENATE 'VALUE' index INTO fieldvalue.
CONDENSE fieldvalue NO-GAPS.
"CLEAR <fs_dyntable>.  as MATT says no need of this line
ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDDO.

APPEND <fs_dyntable> TO <t_dyntable>.

try to following too,

DO 4 TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL' wa_colno INTO wa_fldname.
CONCATENATE 'VALUE' index INTO fieldvalue.
CONDENSE fieldvalue NO-GAPS.
CLEAR <fs_dyntable>.
ASSIGN COMPONENT wa_fldname OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
INSERT <fs_dyntable> TO <t_dyntable> index 1. " i change here
ENDDO.

Kind Regards,

Faisal

Edited by: Faisal Altaf on Feb 5, 2009 8:02 PM

Edited by: Faisal Altaf on Feb 5, 2009 8:22 PM

Read only

Former Member
0 Likes
802

steps:

it_final[] = it_itab[].

loop at it_tab.

loop at it_final.

assign component stmt.

endloop.

endloop.