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

looping the data

Former Member
0 Likes
639

loop at i_open_posting into wa_open_posting.

move: wa_open_posting-mblnr to wa_print_mat-mblnr,

wa_open_posting-mbpos to wa_print_mat-mbpos,

wa_open_posting-bwart to wa_print_mat-bwart,

wa_open_posting-menge to wa_print_mat-menge,

wa_open_posting-meins to wa_print_mat-meins.

endloop.

*looping at i_cpudt to append the data into i_print_mat.

loop at i_cpudt into wa_cpudt.

move: wa_cpudt-cpudt to wa_print_mat-cpudt.

endloop.

*looping at i_t156t to append the data into i_print_mat.

loop at i_t156t into wa_t156t.

move: wa_t156t-btext to wa_print_mat-btext.

endloop.

*Appending i_open_posting, i_cpudt, i_t156t into one i_print_mat.

append initial line to i_print_mat.

the above code is not working properly to append all the 3 loops into one intenral table can u plz help me out.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
614

Hi,

you should have common fields to combine all three internal tables into 1

loop at i_open_posting into wa_open_posting.

move: wa_open_posting-mblnr to wa_print_mat-mblnr,

wa_open_posting-mbpos to wa_print_mat-mbpos,

wa_open_posting-bwart to wa_print_mat-bwart,

wa_open_posting-menge to wa_print_mat-menge,

wa_open_posting-meins to wa_print_mat-meins.

move-corresponding i_open_posting to i_print_mat.

read table i_cpudt with key <common field> = < i_open_posting-common

field>

if sy-subrc eq 0.

move-corresponding i_cpudt to i_print_mat.

endif.

read table i_t156t with key <common fild> = < i_open_posting-common

field>

if sy-subrc eq 0.

move-corresponding i_t156t to i_print_mat.

endif.

append i_print_mat.

endloop.

Regards

amole

5 REPLIES 5
Read only

Former Member
0 Likes
614

Hi,

use below logic

loop at itab.

read table itab1 with key matnr = itab-matnr

binary search.

if sy-subrc eq 0.

data lv_index type sy-tabix.

clear lv_index.

lv_index = sy-tabix.

loop at itab1 from lv_index.

if itab-matnr <> itab1-matnr.

clear itab.

exit.

endif.

endloop.

endif.

move-corresponding itab to i_final.

move-corresponding itab1 to i_final.

append it_final.

endif.

endloop.

regards

amole

Read only

Former Member
0 Likes
614

what you need to do is

Loop at i_open_posting into wa_open_posting "Header table

move: wa_open_posting-mblnr to wa_print_mat-mblnr,

wa_open_posting-mbpos to wa_print_mat-mbpos,

wa_open_posting-bwart to wa_print_mat-bwart,

wa_open_posting-menge to wa_print_mat-menge,

wa_open_posting-meins to wa_print_mat-meins.

read table i_cpudt into wa_cpudt with key mblnr = wa_open_posting-mblnr

move: wa_cpudt-cpudt to wa_print_mat-cpudt.

read table i_t156t into wa_t156t with key mblnr = wa_open_posting-mblnr

move: wa_t156t-btext to wa_print_mat-btext.

append wa_print_mat to i_print_mat

endloop.

Read only

Former Member
0 Likes
615

Hi,

you should have common fields to combine all three internal tables into 1

loop at i_open_posting into wa_open_posting.

move: wa_open_posting-mblnr to wa_print_mat-mblnr,

wa_open_posting-mbpos to wa_print_mat-mbpos,

wa_open_posting-bwart to wa_print_mat-bwart,

wa_open_posting-menge to wa_print_mat-menge,

wa_open_posting-meins to wa_print_mat-meins.

move-corresponding i_open_posting to i_print_mat.

read table i_cpudt with key <common field> = < i_open_posting-common

field>

if sy-subrc eq 0.

move-corresponding i_cpudt to i_print_mat.

endif.

read table i_t156t with key <common fild> = < i_open_posting-common

field>

if sy-subrc eq 0.

move-corresponding i_t156t to i_print_mat.

endif.

append i_print_mat.

endloop.

Regards

amole

Read only

Former Member
0 Likes
614

Whatz the relationship between the three internal tables ?

i_open_posting, i_cpudt and i_t156t internal tables..lets if they are linked to each other via field1 than you can use the below logic.

loop at i_open_posting...

move i_open_posting ...to wa_print_mat.

read table i_cpudt with key field1 = i_open_posting-field1.

move i_cpudt to wa_print_mat.

read table i_t156t with key field field1 = i_open_posting-field1.

move i_t156t to wa_print_mat.

append wa_print_mat to i_print_mat.

endloop.

Read only

Former Member
0 Likes
614

Loop at i_open_posting into wa_open_posting "Header table

move: wa_open_posting-mblnr to wa_print_mat-mblnr,

wa_open_posting-mbpos to wa_print_mat-mbpos,

wa_open_posting-bwart to wa_print_mat-bwart,

wa_open_posting-menge to wa_print_mat-menge,

wa_open_posting-meins to wa_print_mat-meins.

append wa_print_mat to i_print_mat.

endloop.

loop at i_print_mat.

Read the remaining fields i.e. CPUDT & BTEXT with the key field and modify i_print_mat .

endloop.

Hope this helps.

Regards,

Sudheer