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
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.
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.