2008 May 12 9:06 PM
Hi Experts,
I hv data in t_vbak and t_vbap itabs.
I need to SUM the QUANTITY i.e. VBAP-KWMENG for each VBELN in VBAK i.e each Doc.
So, normally, I use,
loop at t_vbak.
loop at t_vbap where vbeln = t_vbak-vbeln
tot_qty = tot_qty + vbap-kwmeng
endloop.
modify ......
endloop.
But, I do not wanna to use NESTED LOOPS, so, pls. let me any other solution?
thanq
2008 May 12 9:21 PM
Use COLLECT statement.
* Declare IT_SUM with VBELN and QTY
LOOP AT IT_VBAP.
IT_SUM-VBELN = IT_VBAP-VBELN.
IT_SUM-QTY = IT_VBAP-MENGE.
COLLECT IT_SUM.
CLEAR IT_SUM.
ENDLOOP.
Regards,
Naimesh Patel
Hi Experts,
I hv data in t_vbak and t_vbap itabs.
I need to SUM the QUANTITY i.e. VBAP-KWMENG for each VBELN in VBAK i.e each Doc.
So, normally, I use,
loop at t_vbak.
loop at t_vbap where vbeln = t_vbak-vbeln
tot_qty = tot_qty + vbap-kwmeng
endloop.
modify ......
endloop.
But, I do not wanna to use NESTED LOOPS, so, pls. let me any other solution?
thanq
2008 May 12 9:11 PM
Forget it, wasn't look to well a coding....vbaK and vbaP
Sort the table by VBELN and next use SUM (standard ABAP statement) within loop at vbap.
Edited by: Micky Oestreich on May 12, 2008 10:12 PM
Edited by: Micky Oestreich on May 12, 2008 10:12 PM
Edited by: Micky Oestreich on May 12, 2008 10:14 PM
2008 May 12 9:13 PM
make vbeln in another table of the same structure of t_vbap a key and then do this
loop at t_vbap.
read table t_vbak with key vbeln = vbap-vbenln.
if sy-subrc eq 0.
collect vbap into other_vbap.
endif.
endloop.
You will have the sum in kwmeng in the other table
2008 May 12 9:21 PM
Use COLLECT statement.
* Declare IT_SUM with VBELN and QTY
LOOP AT IT_VBAP.
IT_SUM-VBELN = IT_VBAP-VBELN.
IT_SUM-QTY = IT_VBAP-MENGE.
COLLECT IT_SUM.
CLEAR IT_SUM.
ENDLOOP.
Regards,
Naimesh Patel
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |