*&---------------------------------------------------------------------*
*& Report ZMMR102
*&---------------------------------------------------------------------*
*& Author : NathanSun
*& Create Date : 2019-05-27
*& Program Type : Report
*& Description : 采购单打印
*&---------------------------------------------------------------------*
REPORT ZMMR106C.
*&---------------------------------------------------------------------*
*& 包含 YN_TEST02_TOP
*&---------------------------------------------------------------------*
TABLES:EORD,EKPO,MARC.
TYPE-POOLS:SLIS.
"定义ALV输出所需变量
DATA: S_LAYOUT TYPE LVC_S_LAYO,
GT_FIELDCAT TYPE LVC_T_FCAT,
IS_VARIANT TYPE DISVARIANT.
DATA: G_TITLE_0200 TYPE STRING,
LV_SUM TYPE STRING,
G_INDEX TYPE SY-INDEX.
DATA: LS_STYLE TYPE LVC_S_STYL,
LT_STYLE TYPE TABLE OF LVC_S_STYL.
TYPES BEGIN OF GTS_DATA.
TYPES CKBOX TYPE C. "标记字段
INCLUDE STRUCTURE EORD. "采购货源清单
TYPES: TYPBOD TYPE CHAR4,
MESSAGED TYPE BAPI_MSG, "报错信息
TYPBO TYPE CHAR4, "消息图标
MESSAGE TYPE BAPI_MSG, "报错信息
STYLE TYPE LVC_T_STYL. "控制不可编辑
TYPES END OF GTS_DATA.
DATA: GT_DATA TYPE TABLE OF GTS_DATA WITH HEADER LINE.
DATA: GT_DATA_A TYPE TABLE OF GTS_DATA WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS: S_MATNR FOR EORD-MATNR MODIF ID C1, "物料
S_WERKS FOR EORD-WERKS MODIF ID C1, "工厂
S_LIFNR FOR EORD-LIFNR MODIF ID C1. "供应商
SELECTION-SCREEN END OF BLOCK B1.
*&---------------------------------------------------------------------*
*& 包含 YN_TEST02_FOM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& 包含 ZFIR092_FOM
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Form FRM_EXCLUDE_OPTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_EXCLUDE_OPTION .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SCREEN_OUTPUT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM SCREEN_OUTPUT .
LOOP AT SCREEN.
CASE SCREEN-GROUP1.
WHEN 'M1'.
SCREEN-INPUT = '0'.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form SCREEN_SETTING
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM SCREEN_SETTING .
* AUTHORITY-CHECK OBJECT 'M_MATE_WRK'
* ID 'WERKS' FIELD P_WERKS.
* IF SY-SUBRC <> 0.
* MESSAGE '您没有工厂:'&& P_WERKS && ' 的权限!' TYPE 'E' .
* ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FOM_GETDATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FOM_GETDATA .
CLEAR GT_DATA[].
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_DATA[] FROM EORD
WHERE MATNR IN S_MATNR
AND WERKS IN S_WERKS
AND LIFNR IN S_LIFNR
.
SORT GT_DATA[] BY WERKS MATNR LIFNR.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FOM_DELETEDATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FOM_DELETEDATA .
DATA: XEORD LIKE EORDU OCCURS 0 WITH HEADER LINE. "修改后的数据
DATA: YEORD LIKE EORD OCCURS 0 WITH HEADER LINE. "修改前的数据
LOOP AT GT_DATA WHERE CKBOX IS NOT INITIAL .
CLEAR: YEORD ,YEORD[].
MOVE-CORRESPONDING GT_DATA TO YEORD.
APPEND YEORD .
CLEAR: XEORD ,XEORD[].
* 更改货源清单
CALL FUNCTION 'ME_UPDATE_SOURCES_OF_SUPPLY'
EXPORTING
I_CHANGEDOCUMENT = 'X'
TABLES
XEORD = XEORD
YEORD = YEORD.
IF SY-SUBRC = 0.
GT_DATA-MESSAGE = '删除成功!'.
COMMIT WORK AND WAIT.
ELSE.
GT_DATA-MESSAGE = '删除货源清单失败!'.
ROLLBACK WORK.
ENDIF.
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
IF SY-SUBRC <> 0 .
MESSAGE '请选择数据行!' TYPE 'S' DISPLAY LIKE 'E'.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FRM_DISPLAY .
CLEAR S_LAYOUT.
S_LAYOUT-ZEBRA = 'X'.
S_LAYOUT-CWIDTH_OPT = 'X'.
* S_LAYOUT-CTAB_FNAME = 'CELLCOLOR'. "单元格颜色内表字段
S_LAYOUT-STYLEFNAME = 'STYLE'. "内部表字段的字段名称
* s_layout-box_fieldname = 'BOX'.
PERFORM FRM_FILL_FIELD .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_SAVE = 'A'
IS_VARIANT = IS_VARIANT
IS_LAYOUT_LVC = S_LAYOUT
IT_FIELDCAT_LVC = GT_FIELDCAT
I_CALLBACK_PROGRAM = SY-REPID
* IT_EVENTS = I_EVENTS
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
TABLES
T_OUTTAB = GT_DATA[].
ENDFORM.
FORM FRM_FILL_FIELD .
DATA: WA_FIELDCAT TYPE LINE OF LVC_T_FCAT.
DEFINE FILL_FIELD.
WA_FIELDCAT-FIELDNAME = &1.
WA_FIELDCAT-COLTEXT = &2.
* IF WA_FIELDCAT-FIELDNAME = 'MSLJH' OR WA_FIELDCAT-FIELDNAME = 'WCBJH'.
* WA_FIELDCAT-EMPHASIZE = 'C600'. "设置字段的颜色
* ENDIF.
*
IF WA_FIELDCAT-FIELDNAME = 'CKBOX' .
WA_FIELDCAT-CHECKBOX = 'X'.
WA_FIELDCAT-EDIT = 'X'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'STREET' .
WA_FIELDCAT-REF_TABLE = 'ADRC'.
WA_FIELDCAT-REF_FIELD = 'STREET'.
WA_FIELDCAT-EDIT = 'X'.
ENDIF .
IF WA_FIELDCAT-FIELDNAME = 'PLNBEZ' OR WA_FIELDCAT-FIELDNAME = 'MATNR' .
WA_FIELDCAT-REF_TABLE = 'MARA'.
WA_FIELDCAT-REF_FIELD = 'MATNR'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'ARKTX' OR WA_FIELDCAT-FIELDNAME = 'WAKTX' .
WA_FIELDCAT-REF_TABLE = 'VBAP'.
WA_FIELDCAT-REF_FIELD = 'ARKTX'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'AUFNR' .
WA_FIELDCAT-REF_TABLE = 'AUFK'.
WA_FIELDCAT-REF_FIELD = 'AUFNR'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'MESSAGE' .
WA_FIELDCAT-REF_TABLE = 'MARA'.
WA_FIELDCAT-REF_FIELD = 'MATNR'.
ENDIF.
APPEND WA_FIELDCAT TO GT_FIELDCAT.
CLEAR WA_FIELDCAT.
END-OF-DEFINITION.
FILL_FIELD :
'CKBOX' '选择列',
'ZEORD' '记录号',
'VDATU' '有效期从',
'BDATU' '有效期到',
'MATNR' '物料编号',
'WERKS' '工厂',
'LIFNR' '供应商',
'MESSAGE' '消息'.
ENDFORM.
FORM PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN'.
ENDFORM.
FORM USER_COMMAND USING I_UCOMM LIKE SY-UCOMM
IS_SELFIELD TYPE SLIS_SELFIELD.
DATA: REF TYPE REF TO CL_GUI_ALV_GRID.
DATA : LV_STABLE TYPE LVC_S_STBL. "刷新稳定性
RANGES: L_WERKS FOR T001W-WERKS.
RANGES: L_MATNR FOR MARA-MATNR.
DATA: L_BUKRS TYPE T001K-BUKRS.
DATA: NUM TYPE I .
DATA: TEMP TYPE I .
DATA: TEMP_Z TYPE I .
DATA: ZTAXL TYPE CHAR6 .
DATA: T_FTAXP LIKE FTAXP OCCURS 0 WITH HEADER LINE .
LV_STABLE-ROW = '1'.
LV_STABLE-COL = '1'.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF.
CALL METHOD REF->CHECK_CHANGED_DATA.
CASE I_UCOMM.
WHEN 'DELE'."点击打印
PERFORM FOM_DELETEDATA .
WHEN 'ALL'.
LOOP AT GT_DATA .
GT_DATA-CKBOX = 'X' .
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
WHEN 'SAL'.
LOOP AT GT_DATA.
GT_DATA-CKBOX = '' .
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
ENDCASE.
CALL METHOD REF->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LV_STABLE.
ENDFORM.
INITIALIZATION .
PERFORM FRM_EXCLUDE_OPTION.
AT SELECTION-SCREEN OUTPUT.
PERFORM SCREEN_OUTPUT.
AT SELECTION-SCREEN.
PERFORM SCREEN_SETTING.
START-OF-SELECTION.
PERFORM FOM_GETDATA .
PERFORM FRM_DISPLAY.
货源清单ME01批量删除/修改(开发笔记)
最新推荐文章于 2024-03-13 15:55:05 发布