REPORT ytest_vl09.
DATA :lv_msg TYPE bapi_msg,
lv_err TYPE c,
lt_mesgx TYPE mesg OCCURS 0 WITH HEADER LINE,
lt_mesg TYPE tsmesg,
ls_mesg TYPE smesg,
ls_emkpf TYPE emkpf,
l_tcode TYPE sy-tcode.
DATA: ident LIKE sy-uzeit.
DATA: lf_user TYPE symsgv,
lf_enqueue_arg LIKE seqg3-garg, "n_1662694
lt_enqueue LIKE seqg3 OCCURS 0 WITH HEADER LINE,
ls_vbuk TYPE vbuk,
BEGIN OF lt_key OCCURS 0,
mandt TYPE mandt,
vbeln TYPE vbeln,
END OF lt_key.
*l_tcode = 'VL09'.
*export tcode = l_tcode to memory id 'ZSDVL09'.
PARAMETER delivery LIKE likp-vbeln DEFAULT '0080000976'.
START-OF-SELECTION.
* "LOCK - 销售凭证被锁定 -
SELECT mandt vgbel INTO TABLE lt_key FROM lips WHERE vbeln = delivery.
SORT lt_key BY vbeln.
DELETE ADJACENT DUPLICATES FROM lt_key.
LOOP AT lt_key.
CLEAR:lf_user,lf_enqueue_arg,lt_enqueue[].
lf_enqueue_arg = lt_key.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = 'VBAK'
garg = lf_enqueue_arg
guname = '*'
TABLES
enq = lt_enqueue
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
READ TABLE lt_enqueue INDEX 1.
IF sy-subrc = 0.
WRITE lt_enqueue-guname TO lf_user. "^_n_1662694
MESSAGE e045(vl) WITH lt_key-vbeln lf_user INTO lv_msg.
WRITE:/ lv_msg.
lv_err = 'X'.
EXIT.
ENDIF.
ENDLOOP.
CHECK lv_err IS INITIAL.
" 交货单锁定
CLEAR:lf_user,lf_enqueue_arg,lt_enqueue,lt_enqueue[].
CONCATENATE sy-mandt '0080000976' INTO lf_enqueue_arg.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
gclient = sy-mandt
gname = 'LIKP'
garg = lf_enqueue_arg
guname = '*'
TABLES
enq = lt_enqueue
EXCEPTIONS
communication_failure = 1
system_failure = 2
OTHERS = 3.
READ TABLE lt_enqueue INDEX 1.
IF sy-subrc = 0.
WRITE lt_enqueue-guname TO lf_user. "^_n_1662694
MESSAGE e046(vl) WITH delivery lf_user INTO lv_msg.
WRITE:/ lv_msg.
lv_err = 'X'.
EXIT.
ENDIF.
CHECK lv_err IS INITIAL.
CALL FUNCTION 'MESSAGES_INITIALIZE' "消息初始化
EXPORTING
i_identification = ident
IMPORTING
e_identification = ident
EXCEPTIONS
OTHERS = 0.
CALL FUNCTION 'MESSAGES_ACTIVE' "激活消息
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
i_vbeln = delivery
i_budat = '20160919'
i_tcode = 'VL09'
i_vbtyp = 'J'
IMPORTING
es_emkpf = ls_emkpf
TABLES
t_mesg = lt_mesgx
EXCEPTIONS
error_reverse_goods_issue = 1
OTHERS = 2.
IF sy-subrc = 0.
COMMIT WORK.
WRITE:/ ls_emkpf-mblnr.
ELSE.
ROLLBACK WORK.
* call function 'MESSAGES_SHOW' "显示消息
* exporting
* show_linno = space
* object = 'ERROR LOG'
* exceptions
* no_messages = 1.
CALL FUNCTION 'MESSAGES_GIVE' "获取消息
TABLES
t_mesg = lt_mesg.
LOOP AT lt_mesg INTO ls_mesg.
CLEAR lv_msg.
IF ls_mesg-msgty IS INITIAL.
ls_mesg-msgty = 'S'.
ENDIF.
MESSAGE ID ls_mesg-arbgb TYPE ls_mesg-msgty NUMBER ls_mesg-txtnr
WITH ls_mesg-msgv1 ls_mesg-msgv2 ls_mesg-msgv3 ls_mesg-msgv4 INTO lv_msg.
WRITE:/ lv_msg.
ENDLOOP.
ENDIF.
CALL FUNCTION 'MESSAGES_INITIALIZE'
EXPORTING
i_identification = ident
IMPORTING
e_identification = ident
EXCEPTIONS
OTHERS = 0. "^_n_720286
CALL FUNCTION 'MESSAGES_STOP'. "释放消息
交货冲销消息获取 - VL09
最新推荐文章于 2024-05-11 15:02:15 发布