Hi All,
REQUIREMENT: On PGI (VL02n) or on Reversing goods movement (VL09), when VBUK-WBSTK changes from A to C or C to A, output should be triggered. It should also trigger an IDoc for every PGI and Reversing.
MY CODE:
1) New routine created (VOFM -> Requirements -> Output Control, Application area = V2)
2) New Output Type created in NACE for V2 (Transmission Medium = EDI, Partner Function = LS)
3) Code within routine:
**-Fetch the existing Goods movement status
CLEAR lv_wbstk.
SELECT SINGLE wbstk "Total goods movement status
FROM vbuk "Sales Doc: Header Status and Admin Data
INTO lv_wbstk
WHERE vbeln EQ komkbv2-vbeln.
IF sy-subrc EQ 0.
**-Check with the current status
CASE lv_wbstk.
WHEN 'A'.
IF komkbv2-wbstk EQ 'C'.
sy-subrc = 0.
ENDIF.
WHEN 'C'.
IF komkbv2-wbstk EQ 'A'.
sy-subrc = 0.
ENDIF.
ENDCASE.
ENDIF.
DOUBTS:
1) Each time I do PGI, status should be updated in NAST table (VL02N -> Extra -> Delivery Output -> Header should be update with new line item). How to achive this?
2) How do I trigger IDocs from this routine?
Please help!
Thanks in advance.
Rgds