TYPES: BEGIN OF ty_data.
INCLUDE TYPE ZSDF_077_LOG.
TYPES: END OF ty_data.
DATA: LT_DATA TYPE TABLE OF ty_data,
LS_data TYPE ty_data.
DATA:
FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV,
GD_REPID LIKE SY-REPID,
I_EVENTS TYPE SLIS_T_EVENT
.
*选择屏幕
SELECTION-SCREEN BEGIN OF BLOCK BLK1 WITH FRAME TITLE T1.
SELECT-OPTIONS :
S_KUNNR FOR LIKP-KUNNR,
S_VBELN FOR VBUK-VBELN OBLIGATORY,
S_WADATE FOR LIKP-WADAT_IST,
S_WEEKS FOR LIPS-WERKS.
PARAMETERS S_WADAT TYPE LIKP-WADAT.
PARAMETERS S_DELAY TYPE i DEFAULT '1' .
SELECTION-SCREEN END OF BLOCK BLK1.
*权限
AUTHORITY-CHECK OBJECT 'S_TCODE'
ID 'TCD' FIELD 'VL09'.
IF SY-SUBRC <> 0.
MESSAGE '您没有访问权限' TYPE 'E'.
STOP.
ENDIF.
*获取数据
PERFORM FROM_GET_DATA.
PERFORM FROM_FIELDCATALOG.
PERFORM FROM_LAYOUT.
PERFORM FROM_DISPLAY_ALV.
FORM from_get_data .
DATA WADAT TYPE LIKP-WADAT_IST.
WADAT = S_WADAT.
IF S_WADAT IS INITIAL.
SELECT
P~VBELN
P~WADAT_IST
P~KUNNR
L~WERKS
P~WADAT_IST AS WADAT
INTO CORRESPONDING FIELDS OF TABLE LT_DATA
FROM likp AS P
INNER JOIN lips AS L ON L~vbeln = P~vbeln
INNER JOIN VBUK AS V ON P~VBELN = V~VBELN
WHERE L~VBELN IN S_VBELN
AND P~WADAT_IST IN S_WADATE
AND P~KUNNR IN S_KUNNR
AND L~WERKS IN S_WEEKS
AND WBSTK = 'C'
AND FKSTK = 'A'.
ELSE.
SELECT
P~VBELN
P~WADAT_IST
P~KUNNR
L~WERKS
INTO CORRESPONDING FIELDS OF TABLE LT_DATA
FROM likp AS P
INNER JOIN lips AS L ON L~vbeln = P~vbeln
INNER JOIN VBUK AS V ON P~VBELN = V~VBELN
WHERE L~VBELN IN S_VBELN
AND P~WADAT_IST IN S_WADATE
AND P~KUNNR IN S_KUNNR
AND L~WERKS IN S_WEEKS
AND WBSTK = 'C'
AND FKSTK = 'A'.
ls_data-WADAT = S_WADAT.
MODIFY LT_DATA FROM ls_data TRANSPORTING WADAT WHERE WADAT = '00000000' .
ENDIF.
* 排序
SORT LT_DATA BY VBELN.
*删除相邻的重复项
DELETE ADJACENT DUPLICATES FROM LT_DATA COMPARING VBELN.
ENDFORM.
FORM from_fieldcatalog .
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'VBELN'.
FIELDCATALOG-SELTEXT_M = '交货单号'.
FIELDCATALOG-OUTPUTLEN = 10.
FIELDCATALOG-KEY = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'KUNNR'.
FIELDCATALOG-SELTEXT_M = '门店编码'.
FIELDCATALOG-OUTPUTLEN = 10.
FIELDCATALOG-KEY = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'WADAT_IST'.
FIELDCATALOG-SELTEXT_M = '过账日期'.
FIELDCATALOG-OUTPUTLEN = 10.
FIELDCATALOG-KEY = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'WADAT'.
FIELDCATALOG-SELTEXT_M = '冲销日期'.
FIELDCATALOG-OUTPUTLEN = 10.
FIELDCATALOG-KEY = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'WERKS'.
FIELDCATALOG-SELTEXT_M = '发货工厂'.
FIELDCATALOG-OUTPUTLEN = 10.
FIELDCATALOG-KEY = 'X'.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'TYPE'.
FIELDCATALOG-SELTEXT_M = '冲销状态'.
FIELDCATALOG-OUTPUTLEN = 10.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MESSAGE'.
FIELDCATALOG-SELTEXT_M = '消息提示'.
FIELDCATALOG-OUTPUTLEN = 10.
APPEND FIELDCATALOG TO FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM.
FORM from_display_alv .
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
i_callback_pf_status_set = 'ALV_PF_STATUS '
i_callback_user_command = 'ALV_USER_COMMAND'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
I_SAVE = 'X'
IT_EVENTS = I_EVENTS[]
TABLES
T_OUTTAB = LT_DATA
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
FORM alv_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STAT'.
ENDFORM.
FORM alv_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'SEND'.
PERFORM from_send.
rs_selfield-refresh = 'X'.
rs_selfield-col_stable ='X'.
rs_selfield-row_stable ='X'.
ENDCASE.
ENDFORM.
FORM from_layout .
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-ZEBRA = 'X'.
ENDFORM.
FORM from_send .
DATA: LS_MESG TYPE TABLE OF MESG WITH HEADER LINE.
DATA: ZTEXT TYPE MESG-TEXT,
ZMSGTY TYPE MESG-MSGTY.
DATA: LV_VBTAP LIKE LIKP-VBTYP.
DATA LS_DATAS TYPE ty_data.
DATA: lv_delay TYPE i.
lv_delay = S_DELAY.
LOOP AT LT_DATA INTO LS_DATA.
LS_DATAS = LS_DATA.
AT END OF VBELN.
WAIT UP TO lv_delay SECONDS. "批量冲销添加等待时间,默认为1秒。
CALL FUNCTION 'WS_REVERSE_GOODS_ISSUE'
EXPORTING
I_VBELN = LS_DATAS-VBELN
I_BUDAT = LS_DATAS-WADAT
I_TCODE = 'VL09'
I_VBTYP = 'J'
TABLES
T_MESG = LS_MESG
EXCEPTIONS
ERROR_REVERSE_GOODS_ISSUE = 1
OTHERS = 2.
IF SY-SUBRC = 0.
COMMIT WORK.
ZTEXT = '冲销成功'.
ZMSGTY = 'S'.
ELSE.
ZTEXT = '冲销失败'.
ZMSGTY = 'E'.
ENDIF.
LS_DATAS-message = ZTEXT.
LS_DATAS-type = ZMSGTY.
LS_DATAS-ernam = sy-uname.
LS_DATAS-erdat = sy-datum.
LS_DATAS-erzet = sy-uzeit.
MODIFY LT_DATA FROM LS_DATAS.
ENDAT.
ENDLOOP.
ENDFORM.
记录批量取消门店交货单过账,VL09,WS_REVERSE_GOODS_ISSUE
最新推荐文章于 2024-08-12 16:57:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)