Skip to Content
0
Former Member
Aug 08, 2013 at 12:15 PM

Reversal of Post goods Issue

806 Views

Hello Exports,

I created one program where i used WS_REVERSE_GOODS_ISSUE functional module for reversal of Post goods issue. But reversal of PGI is not happening. kindly help me.

Code:

TABLES LIKP.
TYPES: BEGIN OF TY_LIKP,
VBELN TYPE LIKP-VBELN,
VBTYP TYPE LIKP-VBTYP,
END OF TY_LIKP.

TYPES: BEGIN OF TY_MKPF,
MBLNR TYPE MKPF-MBLNR,
LE_VBELN TYPE MKPF-LE_VBELN,
BUDAT TYPE MKPF-BUDAT,
END OF TY_MKPF.


DATA: IT_LIKP TYPE TABLE OF TY_LIKP,
WA_LIKP TYPE TY_LIKP.

DATA: IT_MKPF TYPE TABLE OF TY_MKPF,
WA_MKPF TYPE TY_MKPF,

IT_MESG LIKE MESG OCCURS 0 WITH HEADER LINE,

DEL_NO LIKE LIKP-VBELN,
LV_VBTYP LIKE LIKP-VBTYP.
DATA: DEL_DOC LIKE LIKP-VBELN.

SELECT-OPTIONS DELNO FOR LIKP-VBELN.

START-OF-SELECTION.

SELECT VBELN VBTYP FROM LIKP INTO TABLE IT_LIKP
WHERE VBELN IN DELNO.


IF IT_LIKP IS NOT INITIAL.
SELECT MBLNR LE_VBELN BUDAT FROM MKPF INTO TABLE IT_MKPF
FOR ALL ENTRIES IN IT_LIKP
WHERE LE_VBELN = IT_LIKP-VBELN.
ENDIF.

REFRESH : IT_MESG.

* select single vbtyp from likp into lv_vbtyp
* where vbeln = del_no.

LOOP AT IT_LIKP INTO WA_LIKP.
READ TABLE IT_MKPF INTO WA_MKPF WITH KEY LE_VBELN = WA_LIKP-VBELN.
ENDLOOP.
LOOP AT IT_LIKP INTO WA_LIKP.
CLEAR DEL_DOC.
DEL_DOC = WA_LIKP-VBELN.
LV_VBTYP = WA_LIKP-VBTYP.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = DEL_DOC
I_BUDAT = SY-DATLO
* I_COUNT =
I_MBLNR = WA_MKPF-MBLNR
I_TCODE = 'VL09'
I_VBTYP = LV_VBTYP
* I_MBLPO =
* I_MJAHR =
* I_POSNR =
* I_SIMULATE = ' '
* I_SPE_BUDAT_UHR =
* I_SPE_BUDAT_ZONE =
* I_SPE_MDNUM_EWM =
* I_SPE_LOGSYS =
* I_SPE_CONFIRM_CENTRAL = ' '
* IMPORTING
* ES_EMKPF =
TABLES
T_MESG = IT_MESG
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
"OTHERS = 2

IF SY-SUBRC = 0.
"---commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.

CLEAR : WA_LIKP , WA_MKPF.
ENDLOOP.



IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

DATA: IT_RET LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE,
WA_RET TYPE BAPIRET2,
RET LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'SD_MESSAGE_LOG_DISPLAY'
TABLES
RETURN = IT_RET
.