REPORT ZSLMMR027.
TABLES : LIPS,EKPO,VBUK,ZSLIPSRELIST,ZSLIPSRELOG.
"首先定义宏
DEFINE D_RANGE.
&1-SIGN = 'E'.
&1-OPTION = &2.
&1-LOW = &3.
&1-HIGH = &4.
APPEND &1.
CLEAR &1.
END-OF-DEFINITION.
INCLUDE ZSLMMR027_DATA.
INCLUDE ZSLMMR027_SCRN.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TITLE1.
SELECT-OPTIONS : SVBELN FOR LIPS-VBELN . "交货单号
SELECTION-SCREEN : END OF BLOCK B1.
INCLUDE ZSLMMR027_GETDATA.
INCLUDE ZSLMMR027_CHECK.
START-OF-SELECTION.
IF SVBELN is not initial .
perform frm_get_lips_data.
perform frm_alv_display.
ELSE .
MESSAGE I888(SABAPDOCU) WITH '交货单号不能为空!'.
ENDIF.
*&---------------------------------------------------------------------*
*& FORM FRM_GET_LIPS_DATA
*&---------------------------------------------------------------------*
* 获取ALV展示需要的交货信息
*----------------------------------------------------------------------*
FORM FRM_GET_LIPS_DATA.
PERFORM FRM_CHECK_AUTO.
CLEAR GT_LIPS[].
SELECT A~VBELN POSNR A~MATNR ARKTX MATKL WERKS LGORT CHARG A~VRKME LFIMG VGBEL VGPOS B~VBELN AS EBELN B~POSNN AS EBELP
INTO CORRESPONDING FIELDS OF TABLE GT_LIPS FROM LIPS AS A
INNER JOIN VBFA AS B ON B~VBELV = A~VGBEL AND B~POSNV = A~VGPOS AND VBTYP_N = 'V'
WHERE A~VBELN IN SVBELN.
IF GT_LIPS[] IS INITIAL.
MESSAGE '没有找到交货单对应的采购订单行项目,请检查!' TYPE 'I'.
EXIT.
ENDIF.
ENDFORM. "FRM_GET_LIPS_DATA
*&---------------------------------------------------------------------*
*& 包括 ZSLMMR027_SCRN
*&---------------------------------------------------------------------*
FORM FRM_ALV_DISPLAY .
* 定义ALV 所要显示的字段信息
PERFORM FRM_FIELCDAT_DEFINE.
* 设定 STATUS/USER_COMMAND/TOP_OF_PAGE等事件
PERFORM FRM_COMMENT_BUILD.
* 设定ALV LAYOUT
PERFORM FRM_LAYOUT_BUILD.
* ALV 函数调用
PERFORM FRM_ALV_FUNCTION.
ENDFORM. "FRM_ALV_DISPLAY
*&---------------------------------------------------------------------*
*& FORM FRM_FIELCDAT_DEFINE
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_FIELCDAT_DEFINE .
CLEAR: IT_FIELDCAT.
DEFINE L_FIELDCAT.
IT_FIELDCAT-FIELDNAME = &1.
IT_FIELDCAT-SELTEXT_L = &2.
IT_FIELDCAT-OUTPUTLEN = &3.
IT_FIELDCAT-CHECKBOX = &4.
IT_FIELDCAT-EDIT = &5.
IT_FIELDCAT-NO_ZERO = &6.
IT_FIELDCAT-JUST = &7.
IT_FIELDCAT-QFIELDNAME = &8.
IT_FIELDCAT-CURRENCY = &9.
* IT_FIELDCAT-INPUT = &10.
APPEND IT_FIELDCAT.
CLEAR IT_FIELDCAT.
END-OF-DEFINITION.
L_FIELDCAT 'CHECK' '选择' '1' 'X' 'X' '' 'L' '' ''.
L_FIELDCAT 'VBELN' '交货单编号' '10' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'POSNR' '交货行项目' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'MATNR' '物料编码' '14' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'ARKTX' '物料描述' '30' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'MATKL' '物料组' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'WERKS' '工厂' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'LGORT' '库存地点' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'CHARG' '批次' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'VRKME' '单位' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'LFIMG' '交货数量' '8' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'EBELN' '采购订单号' '10' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'EBELP' '采购行项目' '4' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'VGBEL' '确认订单号' '10' '' '' 'X' 'L' '' ''.
L_FIELDCAT 'VGPOS' '确认订单行项目' '4' '' '' 'X' 'L' '' ''.
ENDFORM. " FRM_FIELCDAT_DEFINE
*&---------------------------------------------------------------------*
*& FORM FRM_COMMENT_BUILD
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_COMMENT_BUILD .
CLEAR IT_EVENTS[].
CLEAR IT_EVENTS.
MOVE 'USER_COMMAND' TO IT_EVENTS-NAME.
MOVE 'FRM_USER_COMMAND' TO IT_EVENTS-FORM.
APPEND IT_EVENTS.
CLEAR IT_EVENTS.
MOVE 'PF_STATUS_SET' TO IT_EVENTS-NAME.
MOVE 'FRM_PF_STATUS' TO IT_EVENTS-FORM.
APPEND IT_EVENTS.
ENDFORM. " FRM_COMMENT_BUILD
*&---------------------------------------------------------------------*
*& FORM FRM_LAYOUT_BUILD
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_LAYOUT_BUILD .
GW_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "优化列
"GW_LAYOUT-BOX_FIELDNAME = 'VBELN'.
GW_LAYOUT-ZEBRA = 'X'.
ENDFORM. " FRM_LAYOUT_BUILD
*&---------------------------------------------------------------------*
*& FORM FRM_ALV_FUNCTION
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_ALV_FUNCTION .
DATA: L_REPID LIKE SY-REPID.
L_REPID = SY-REPID.
" 回调变量 用来获取复选框的值
DATA: I_GRID_SETTINGS TYPE LVC_S_GLAY .
I_GRID_SETTINGS-EDT_CLL_CB = 'X' .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = L_REPID
I_DEFAULT = 'X'
I_INTERFACE_CHECK = 'X'
I_SAVE = 'A'
IS_LAYOUT = GW_LAYOUT
IT_FIELDCAT = IT_FIELDCAT[]
IT_SORT = IT_SORT[]
IT_EVENTS = IT_EVENTS[]
I_GRID_SETTINGS = I_GRID_SETTINGS
TABLES
T_OUTTAB = GT_LIPS.
IF SY-SUBRC NE 0.
* MESSAGE E000 WITH TEXT-010.
ENDIF.
ENDFORM. " FRM_ALV_FUNCTION
*&---------------------------------------------------------------------*
*& FORM FRM_PF_STATUS
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* --> P1 TEXT
* <-- P2 TEXT
*----------------------------------------------------------------------*
FORM FRM_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'PF_STATUS'.
ENDFORM. " PF_STATUS
*&---------------------------------------------------------------------*
*& FORM FRM_CHECK_AUTO
*&---------------------------------------------------------------------*
* 检查是否已自动收货(自建表)
*----------------------------------------------------------------------*
FORM FRM_CHECK_AUTO.
CLEAR GT_AUTO_VBELN.
SELECT DISTINCT VBELN_VL INTO TABLE GT_AUTO_VBELN
FROM ZSLIPSRELIST WHERE ZSLIPSRELIST~VBELN_VL IN SVBELN.
IF GT_AUTO_VBELN[] IS NOT INITIAL.
CLEAR STR_VBELN.
LOOP AT GT_AUTO_VBELN.
CONCATENATE STR_VBELN GT_AUTO_VBELN-VBELN_VL ',' INTO STR_VBELN.
D_RANGE SVBELN 'EQ' GT_AUTO_VBELN-VBELN_VL ''. "屏幕查询条件增加条件限制
ENDLOOP.
CONCATENATE '交货单:' STR_VBELN '已自动收货,已剔除并继续进行查询!' INTO STR_VBELN.
MESSAGE STR_VBELN TYPE 'I'.
EXIT.
ENDIF.
ENDFORM. "FRM_CHECK_AUTO
*&---------------------------------------------------------------------*
*& Form frm_user_command
*& 自定义事件
*&---------------------------------------------------------------------*
FORM FRM_USER_COMMAND USING VALUE(R_UCOMM) LIKE SY-UCOMM "#EC *
CHANGING RS_SELFIELD TYPE SLIS_SELFIELD.
DATA:TEM_GRID TYPE REF TO CL_GUI_ALV_GRID.
CASE SY-UCOMM.
WHEN 'E_AUTO'.
perform frm_exe_auto_btn.
WHEN '&ALLSAL'.
LOOP AT GT_lips .
gt_lips-CHECK = 'X'.
MODIFY gt_lips TRANSPORTING CHECK.
ENDLOOP.
WHEN '&SALALL'.
LOOP AT GT_lips.
gt_lips-CHECK = ''.
MODIFY gt_lips TRANSPORTING CHECK.
ENDLOOP.
WHEN OTHERS.
.
ENDCASE.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = TEM_GRID.
CALL METHOD TEM_GRID->CHECK_CHANGED_DATA.
RS_SELFIELD-REFRESH = 'X'.
ENDFORM. " frm_user_command