Hi Expert,
kindly need your help regarding above issue. I have use BDC to do reversal and update the delivery quantity. Unfortunately, it failed to update quantity to zero after done the reversal. Below is my code, please advise me if i am wrong.
SELECT * FROM lips INTO TABLE lt_lips
WHERE vbeln = p_lips-vbeln.
* First VL02N Screen
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '4004'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'LIKP-VBELN' p_lips-vbeln.
LOOP AT lt_lips.
*Click select position
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '1000'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '=POPO_T'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_CURSOR' 'LIPS-MATNR(01)'.
*Enter the posnr
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '0111'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '=WEIT'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'RV50A-POSNR' lt_lips-posnr.
*Enter the posnr - Update Batch to empty
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '1000'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'LIPS-CHARG(01)' ''.
*Enter the posnr - Update Quantity to 0 MT
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '1000'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'LIPSD-G_LFIMG(01)' '0.00'.
**Enter the posnr - Update Batch to empty
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '1000'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '/00'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'LIPS-CHARG(01)' ''.
ENDLOOP.
*Click Save
PERFORM bdc_dynpro TABLES lt_bdcdata
USING 'SAPMV50A' '1000'.
PERFORM bdc_field TABLES lt_bdcdata
USING 'BDC_OKCODE' '=SICH_T'.
CALL TRANSACTION 'VL02N' USING lt_bdcdata
MODE lv_mode
UPDATE lv_upd
MESSAGES INTO lt_msg.
READ TABLE lt_msg WITH KEY msgtyp = 'S' TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
p_lv_err = '2'.
MESSAGE i229(zmm).
ELSE.
p_lv_err = '3'.
MESSAGE E000(zmm) WITH 'Failed to update quantity in VL03'.
ENDIF.
Your kindness is really appreciated.
Thanks and regards,
LIYANA