2009 Nov 02 8:38 AM
Hi guys,
I need to compare some fields from vbap and vbkd and to add values from sales order items, before I print then on screen.
I need to compare if vbkd-ihrez_e and vbkd-bstkd and vbap-matnr are the same for two records from sales order (10 and 20), If they are the same then add vbkd-ihrez values (for items 10 and 20), also add vbap-kwmeng, and write that sum on screen.
Compare item with previous one. if doing for 20 compare with 10, for item 30 compare with 20 etc.
I start like this.
select aubel posnr into (wa_tab-vbeln, wa_tab-posnr)
from vbrp
where vbeln = p_vbeln.
append wa_tab to it_tab.
endselect.
loop at it_tab into wa_tab. << I need somewhere to compare fields if they are the same before I print them.
select single fbuda bstkd_e ihrez_e ihrez bstkd
into
(wa_tab-fbuda,
wa_tab-bstkd_e,
wa_tab-ihrez_e,
wa_tab-ihrez,
wa_tab-bstkd)
from vbkd
where vbeln = wa_tab-vbeln and
posnr = wa_tab-posnr.
select single kbmeng waerk netwr arktx kwmeng
into
(wa_tab-kbmeng,
wa_tab-waerk,
wa_tab-netwr,
wa_tab-arktx,
wa_tab-kwmeng)
from vbap
where vbeln = wa_tab-vbeln and
posnr = wa_tab-posnr.
modify it_tab from wa_tab.
endloop.
How can I modify code to get this process? Thanks,
Edited by: nihad omerbegovic on Nov 2, 2009 9:45 AM
Hi guys,
I need to compare some fields from vbap and vbkd and to add values from sales order items, before I print then on screen.
I need to compare if vbkd-ihrez_e and vbkd-bstkd and vbap-matnr are the same for two records from sales order (10 and 20), If they are the same then add vbkd-ihrez values (for items 10 and 20), also add vbap-kwmeng, and write that sum on screen.
Compare item with previous one. if doing for 20 compare with 10, for item 30 compare with 20 etc.
I start like this.
select aubel posnr into (wa_tab-vbeln, wa_tab-posnr)
from vbrp
where vbeln = p_vbeln.
append wa_tab to it_tab.
endselect.
loop at it_tab into wa_tab. << I need somewhere to compare fields if they are the same before I print them.
select single fbuda bstkd_e ihrez_e ihrez bstkd
into
(wa_tab-fbuda,
wa_tab-bstkd_e,
wa_tab-ihrez_e,
wa_tab-ihrez,
wa_tab-bstkd)
from vbkd
where vbeln = wa_tab-vbeln and
posnr = wa_tab-posnr.
select single kbmeng waerk netwr arktx kwmeng
into
(wa_tab-kbmeng,
wa_tab-waerk,
wa_tab-netwr,
wa_tab-arktx,
wa_tab-kwmeng)
from vbap
where vbeln = wa_tab-vbeln and
posnr = wa_tab-posnr.
modify it_tab from wa_tab.
endloop.
How can I modify code to get this process? Thanks,
Edited by: nihad omerbegovic on Nov 2, 2009 9:45 AM
2009 Nov 02 9:32 AM
Hi Nihad
select aubel posnr into CORRESPONDING FIELDS OF TABLE it_tab
from vbrp
where vbeln EQ p_vbeln.
select a~vbeln a~posnr a~fbuda a~bstkd_e a~ihrez_e a~ihrez a~bstkd
b~kbmeng b~waerk b~netwr b~arktx b~kwmeng
into CORRESPONDING FIELDS OF TABLE it_vb
from vbkd as a INNER JOIN vbap as b ON a~vbeln EQ b~vbeln AND a~posnr EQ b~posnr
FOR ALL ENTRIES IN it_tab
where vbeln EQ it_tan-vbeln and
posnr EQ it_tab-posnr.
SORT it_tab BY vbeln posnr.
LOOP AT it_tab INTO wa_tab.
IF lv_vbeln EQ wa_tab-vbeln. "means it's the same order but a different item
IF ( lv_ihrez_e = wa_tab-ihrez_e ) AND ( lv_bstkd = wa_tab-bstkd ) AND ( lv_matnr = wa_tab-matnr ).
ADD wa_tab-kwmeng TO lv_kwmeng.
WRITE lv_kwmeng.
ENDIF.
CLEAR lv_kwmeng.
lv_ihrez_e = wa_tab-ihrez_e.
lv_bstkd = wa_tab-bstkd.
lv_matnr = wa_tab-matnr.
lv_vbeln = wa_tab-vbeln.
lv_kwmeng = wa_tab-kwmeng.
endloop.
Thanks
Pushpraj
2009 Nov 02 10:26 AM
Hi
I think u need to store the data in a new internal table where the keys are the fields u need to compair and collect the data there.
Max
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |