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 internal table dynamically

former_member188829
Active Contributor
0 Likes
870

Hi All,

I have a internal table with fields F1, V1, F2, V2, F3, V3, F4, V4, F5, V5.

For example, if the internal table is having fields and values like below:

 Fields:   F1       V1       F2      V2     F3    V3     F4     V4     F5     V5
  Values:  A        10        B        20   C     30      D      40     E      50 

I want the output as:

Fields: F1       V1       F2      V2     F3    V3
 Values: C      30         D      40      E     50

I always want field values C, D and E only. and F4 V4 F5 V5 fields as empty.

For example, if the internal table is having fields and values like below:

 Fields:   F1       V1       F2      V2     F3    V3     F4     V4     F5     V5 
  Values:  A        10                                                                                ---->Row1
                              B       20                                                                              ---->Row2
                                           C     30                                                                  ---->Row3
                                                           D      40                                                 ---->Row4
                                                                          E      50 ---->Row5

I want the output as:

Fields: F1       V1       F2      V2     F3    V3
 Values: C      30         D      40      E     50

I always want field values C, D and E only. and F4 V4 F5 V5 fields as empty.

Thanks in Advance.

With Regards,

Vishnu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
725

Hi, why don't you filter all the entires you want and delete the entries you do not want. LOOP over internal table and do a DELETE table INDEX sy-tabix for the entries you do not want. Or is this to simple? Succes

4 REPLIES 4
Read only

Former Member
0 Likes
726

Hi, why don't you filter all the entires you want and delete the entries you do not want. LOOP over internal table and do a DELETE table INDEX sy-tabix for the entries you do not want. Or is this to simple? Succes

Read only

rthoodi
Active Participant
0 Likes
725

Hello,

Understabd the following code to populate the dynamic internal table

call method cl_alv_table_create=>create_dynamic_table

exporting

it_fieldcatalog = y_i_fcat

importing

ep_table = y_i_dyn.

assign y_i_dyn->* to <y_i_dyn>.

create data y_wa_dyn like line of <y_i_dyn>.

assign y_wa_dyn->* to <y_wa_dyn>.

*Move data from Final table to dynamic table <y_i_dyn>

loop at y_i_final into y_wa_final.

assign component 'VBELN' of structure <y_wa_dyn> to <y_v_fld>.

<y_v_fld> = y_wa_final-vbeln.

y_lv_cntr = y_lv_cntr + 1.

concatenate 'PARVW' '-' y_lv_cntr into y_lv_parvw.

assign component y_lv_parvw of structure <y_wa_dyn> to <y_v_fld>.

<y_v_fld> = y_wa_final-parvw.

concatenate 'KUNNR' '-' y_lv_cntr into y_lv_kunnr.

assign component y_lv_kunnr of structure <y_wa_dyn> to <y_v_fld>.

<y_v_fld> = y_wa_final-kunnr.

concatenate 'ADRNR' '-' y_lv_cntr into y_lv_adrnr.

assign component y_lv_adrnr of structure <y_wa_dyn> to <y_v_fld>.

<y_v_fld> = y_wa_final-adrnr.

at end of vbeln.

append <y_wa_dyn> to <y_i_dyn>.

free: <y_wa_dyn>,<y_v_fld>.

clear y_lv_cntr.

endat.

endloop.

Regards

RK

Read only

Former Member
0 Likes
725

hi,

Try this :-

ITAB-f1 = 'A'.

ITAB-f2 = 'B'.

ITAB-f3 = 'C'.

ITAB-f4 = 'D'.

ITAB-f5 = 'E'.

ITAB-V1 = '10'.

ITAB-V2 = '20'.

ITAB-V3 = '30'.

ITAB-V4 = '40'.

ITAB-V5 = '50'.

APPEND ITAB.

LOOP AT itab .

itab-f1 = itab-f3.

itab-v1 = itab-v3.

itab-f2 = itab-f4.

itab-v2 = itab-v4.

itab-f3 = itab-f5.

itab-v3 = itab-v5.

clear: itab-F4, itab-V4, itab-F5, itab-V5.

MODIFY itab TRANSPORTING f1 f2 f3 v1 v2 v3 f4 f5 v4 v5.

clear itab.

ENDLOOP.

Regards,

Prakash

Read only

Former Member
0 Likes
725

Hi,

Try this,


loop at itab.
if not itab-f3 is initial.
iout-f1 = itab-f3.
endif.

if not itab-v3 is initial.
iout-v1 = itab-v3.
endif.

if not itab-f4 is initial.
iout-f2 = itab-f4.
endif.

if not itab-v4 is initial.
iout-v2 = itab-v4.
endif.

if not itab-f5 is initial.
iout-f3 = itab-f5.
endif.

if not itab-v5 is initial.
iout-v3 = itab-v5.
endif.

append iout.
clear iout.
endloop.

Regards,

Vikranth