Skip to Content
0
Apr 08, 2015 at 07:09 AM

Item Level Po Number and PO date need to copy from sales contract to sales order while creating sales order with reference to sales contract

612 Views

Hello ,

My requirement is to copy Item level PO number and po date from sales contract to sales order while creating sales order with reference to sales contract.

I am wrting my code in "userexit_move_field_to_vbkd".

TYPES : BEGIN OF TY_VBKD,
POSNR TYPE VBKD-POSNR,
BSTKD TYPE VBKD-BSTKD,
BSTDK TYPE VBKD-BSTDK,
END OF TY_VBKD.
DATA : IT_VBKD TYPE TABLE OF TY_VBKD,
WA_VBKD LIKE LINE OF IT_VBKD.

IF SY-TCODE = 'VA01'.
SELECT SINGLE POSNR BSTKD BSTDK FROM VBKD
INTO (WA_VBKD-POSNR,WA_VBKD-BSTKD,WA_VBKD-BSTDK)
WHERE VBELN EQ XVBFA-VBELV.
* AND POSNR EQ CVBKD-POSNR.

IF SY-SUBRC = 0.
IF WA_VBKD-BSTKD IS NOT INITIAL OR WA_VBKD-BSTKD IS NOT INITIAL.
VBKD-BSTKD_E = WA_VBKD-BSTKD.
VBKD-BSTDK_E = WA_VBKD-BSTDK.
ENDIF.
ENDIF.


But vbkd is structure,so it is updating last value of PO number and po date from sales contract to sales order.

Suppose , sales contract is having 3 line item with diffrent PO number and Po date then same should get copy in sales order.

But currently only last line item's PO number and PO date are getting copied in sales order for all line items.


Kindly help.


Regards,

Anuja dhondge