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

ROUTINE MODIFICATION

bsivasankarreddy_reddy
Active Contributor
0 Likes
1,584

Hi gurus

i am basically sd consultant , i have one requirement when you take return order with reference to invoice , once i create the return order with reference to invoice

invoice 3 line item

1 st -10 quantity

2 nd - 9 quantity

3 rd - 8 quantity

return order create

1 st - 1 quantity

2 nd- 1 quantity

3 rd - 1 quantity

next time create the return order with same invoice , in that time  the previous order quantity minus invoice quantity

1 st = 10-1 =9

2nd = 9-1  = 8

3 rd = 8-1 = 7

this quantity comes at second order quantity , how this capture

i tried to change routine a t copy control

DATA : w_kwmeng TYPE vbap-kwmeng,

         w_ntgew  TYPE vbap-ntgew,

         w_brgew  TYPE vbap-brgew,

         bal_kwmeng TYPE vbap-kwmeng.

  SELECT SUM( kwmeng ) SUM( ntgew ) SUM( brgew )  FROM vbap INTO (w_kwmeng , w_ntgew , w_brgew)

  WHERE vgbel = cvbrp-vbeln AND vgpos = cvbrp-posnr.

  IF sy-subrc EQ 0.

    IF NOT w_kwmeng IS INITIAL.

*      cvbrp-fkimg = vbrp-fkimg - w_kwmeng.

      bal_kwmeng = cvbrp-fkimg - w_kwmeng.

      cvbrp-fkimg = bal_kwmeng.

      cvbrp-ntgew = cvbrp-fkimg.

      cvbrp-brgew = cvbrp-fkimg.

but system gives below quantity

1 st = 8

2 nd = 7

2 nd = 6

but i want sale order quantity like  9, 8, 7

please help me ,

7 REPLIES 7
Read only

former_member209920
Active Participant
0 Likes
1,448

Hi

Add

CLEAR: w_kwmeng , w_ntgew , w_brgew.

before select query.

Regards

Read only

0 Likes
1,448

hi

thq replly

can clear explanation ,

Read only

0 Likes
1,448

is it resolved ?

Read only

0 Likes
1,448

hi

it is not resolved , same issue will come, check screen

but net weight and gross weight will come fine like below screen

CLEAR: w_kwmeng , w_ntgew , w_brgew.

  SELECT SUM( kwmeng ) SUM( ntgew ) SUM( brgew )  FROM vbap INTO (w_kwmeng , w_ntgew , w_brgew)

  WHERE vgbel = vbrp-vbeln AND vgpos = vbrp-posnr.

  IF sy-subrc EQ 0.

    IF NOT w_kwmeng IS INITIAL.

      cvbrp-fkimg = cvbrp-fkimg - w_kwmeng.( here i missing some thing , this deduction it some come wrong )

      cvbrp-ntgew = cvbrp-fkimg.

      cvbrp-brgew = cvbrp-fkimg

can guide me

.

Read only

0 Likes
1,448

hi

any reply

Read only

0 Likes
1,448

Hi Siva,

Your query is on VBAP where only key fields are VBELN and POSNR.

So you can remove SUM aggregate function.

Re-phrase selection query as:

CLEAR: W_KWMENG , W_NTGEW , W_BRGEW.

SELECT KWMENG

                  NTGEW

                  BRGEW

                          FROM VBAP INTO (W_KWMENG , W_NTGEW , W_BRGEW)

                         WHERE VGBEL = VBRP-VBELN

                                AND VGPOS = VBRP-POSNR.

IF SY-SUBRC EQ 0.

IF NOT W_KWMENG IS INITIAL.

CVBRP-FKIMG = CVBRP-FKIMG - W_KWMENG.

CVBRP-NTGEW = CVBRP-FKIMG.

CVBRP-BRGEW = CVBRP-FKIMG

Regards,

ManuB

Read only

0 Likes
1,448

hi

i check same but its come same no changes ,

when i remove for C

CVBRP-FKIMG = VBRP-FKIMG  - W_KWMENG

when this activate system last line item qunatity for all like below screen

here 4 line qnatity 6 , this copy to all line item , this is my problem.

can help this