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: 

abap logic

Former Member
0 Kudos

hi,

may i know if the logic is correct?

i only doubt is the last loop, where the select statement in the loop.

wa_report-vgbel and wa_report-vgpos, this combination is unique and no duplication. can the control in the select statement when meet endselect after process 1 record (the unique combination), will go to next record in the loop?

thanks

sort it_delivery by vbeln vgbel vgpos.

loop at it_delivery into wa_delivery.

move wa_delivery-vbeln to wa_report-vbeln.

move wa_delivery-vgbel to wa_report-vgbel.

move wa_delivery-vgpos to wa_report-vgpos.

move wa_delivery-matnr to wa_report-matnr.

move wa_delivery-charg to wa_report-charg.

move wa_delivery-lfimg to wa_report-lfimg.

collect wa_report into it_report.

endloop.

loop at it_report into wa_report.

v_tabix = sy-tabix.

select a~kwmeng

bvkorg bvtweg bspart bvbtyp

into (wa_report-kwmeng, wa_report-vkorg,

wa_report-vtweg, wa_report-spart, wa_report-vbtyp)

from vbap as a inner join vbak as b

on avbeln = bvbeln

where a~vbeln = wa_report-vgbel and

a~posnr = wa_report-vgpos.

if sy-subrc = 0.

SELECT SINGLE tknum FROM vttp INTO wa_report-tknum

WHERE vbeln = wa_delivery-vbeln.

SELECT SINGLE * FROM vbpa

WHERE vbeln = wa_report-vbeln AND

parvw = 'SH'.

READ TABLE it_customer WITH KEY kunnr = vbpa-kunnr.

IF sy-subrc = 0.

wa_report-kunnr = vbpa-kunnr.

endif.

wa_report-openqty = wa_report-kwmeng - wa_report-lfimg.

modify it_report from wa_report index v_tabix transporting

kwmeng vkorg vtweg spart vbtyp tknum kunnr.

endif.

endselect.

endloop.

endif.

1 REPLY 1

Former Member
0 Kudos

Hi

Performance point of view it is not good to use Select query inside a loop statement .Rather u can use for all entries and get the data into int tables and then loop it.

Regards

Zarina