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

503

Former Member
0 Likes
345

FORM GET_BKPF.

$$ Selecting data from BKPF table

SELECT BLDAT BLART BELNR USNAM INTO

CORRESPONDING FIELDS OF TABLE ITAB

FROM BKPF

***Changes made by Shiva on 26.02.2003

***---Code Modified by Venkat Ramana on 10.08.2005

  • WHERE BUKRS = 'GMKT'

WHERE BUKRS = P_BUKRS

***---End

AND BLDAT IN S_BLDAT

  • and usnam in s_usnam

and blart IN S_BLART

aNd blart = 'S1'.

loop at itab.

select a~bukrs

a~vbeln

b~posnr

b~fkimg

b~netwr

b~mwsbp

a~fkart

b~vkbur

into TABLE it_billdtl

FROM vbrk as a inner join vbrp as b

on a~vbeln = b~vbeln

where a~bukrs = p_bukrs

  • and b~werks = p_werks

and a~fkdat in S_BLDAT

and b~vkbur in s_vkbur.

endloop.

loop at itab.

.

*

clear: BKPF, vbrk, vbrp.

Select single * from bkpf into bkpf where belnr = itab-belnr.

if sy-subrc = 0.

select single * from vbrk into vbrk where vbeln = bkpf-awkey.

if sy-subrc = 0.

if vbrk-fkart = 'S1'.

select single * from vbrp into vbrp where vbeln = vbrk-vbeln.

if sy-subrc = 0.

loop at it_billdtl where vbeln = vbrp-vbeln.

if sy-subrc = 0.

vbrp-fkimg = vbrp-fkimg * -1.

it_billdtl-fkimg = vbrp-fkimg.

endif.

endloop.

collect it_billdtl.

endif.

endif.

endif.

endif.

endloop.

clear: bkpf, vbrk, vbrp.

***************

*qty = itab-fkimg.

*

  • IF iTAB-FKIMG EQ 0.

  • QTY = ' '.

  • ENDIF.

loop at it_billdtl .

move it_billdtl-vbeln to total_tab-vbeln.

move it_billdtl-fkart to total_tab-fkart.

move it_billdtl-fkimg to total_tab-fkimg.

move it_billdtl-netwr to total_tab-netwr.

move it_billdtl-mwsbp to total_tab-mwsbp.

move it_billdtl-vkbur to total_tab-vkbur.

collect total_tab.

endloop.

ENDFORM.

2 REPLIES 2
Read only

Former Member
0 Likes
328

loop at itab.

clear: BKPF, vbrk, vbrp.

Select single * from bkpf into bkpf where belnr = itab-belnr.

if sy-subrc = 0.

select single * from vbrk into vbrk where vbeln = bkpf-awkey.

if sy-subrc = 0.

if vbrk-fkart = 'S1'.

select single * from vbrp into vbrp where vbeln = vbrk-vbeln.

if sy-subrc = 0.

loop at it_billdtl where vbeln = vbrp-vbeln.

if sy-subrc = 0.

vbrp-fkimg = vbrp-fkimg * -1.

it_billdtl-fkimg = vbrp-fkimg.

modify it_billdtl.

endif.

endloop.

endif.

endif.

endif.

endif.

Endloop.

clear: BKPF, vbrk, vbrp.

Read only

Former Member
0 Likes
328

Remove the privious code and put the below code just above ENDFORM and below ther endloop.

endloop.

***********************************

Data: begin of ivbrp occurs 0,

Vbeln like vbrp-vbeln,

Fkimg like vbrp-fkimg,

End of ivbrp.

loop at total_tab..

clear: BKPF, vbrk, vbrp.

select single * from vbrk into vbrk where vbeln = total_tab-vbeln.

if sy-subrc = 0.

if vbrk-fkart = 'S1'.

select vbeln fkimg from vbrp into corresponding fileds of ivbrp where vbeln = vbrk-vbeln.

collect ivbrp.

Endseelect.

Loop at ivbrp where vbeln = total-tab-vbeln.

Total_tab-fkimg = total_tab-fkimg - ivbrp-fkimg.

Modify total_tab.

Endloop.

Endif.

Endif

Endloop.

*************

ENDFORM.