*&---------------------------------------------------------------------*
*& Report ZMMR120
*&---------------------------------------------------------------------*
*& Author : NathanSun
*& Create Date : 2019-09-23
*& Program Type : Report
*& Description : 物料的资源清单
*&---------------------------------------------------------------------*
REPORT ZMMR120.
*&---------------------------------------------------------------------*
*& 包含 YN_TEST02_TOP
*&---------------------------------------------------------------------*
TABLES:EORD,MARC,MARA,ZTMJCP,ZTMJZD.
TYPE-POOLS:SLIS,T001W.
"定义ALV输出所需变量
DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV,
GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
*----- Interne Tabellen für Orderbuch ---------------------------------*
TYPES: BEGIN OF GTS_DATA .
INCLUDE STRUCTURE EORD.
TYPES: MAKTX TYPE MAKT-MAKTX. "物料描述
TYPES: NAME1 TYPE LFA1-NAME1. "供应商名称1
TYPES: NAME2 TYPE LFA1-NAME2. "供应商名称2
TYPES: NAME3 TYPE CHAR70. "供应商名称
TYPES: MATKL TYPE MARA-MATKL. "物料组
TYPES: WGBEZ60 TYPE T023T-WGBEZ60. "物料组描述
TYPES: DISPO TYPE MARC-DISPO. "MRP控制员
TYPES: DSNAM TYPE T024D-DSNAM. "MRP控制员描述
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 .
SELECT-OPTIONS: S_WERKS FOR EORD-WERKS .
SELECT-OPTIONS: S_DISPO FOR MARC-DISPO .
SELECT-OPTIONS: S_LIFNR FOR EORD-LIFNR .
SELECT-OPTIONS: S_MATKL FOR MARA-MATKL .
SELECTION-SCREEN END OF BLOCK B1.
*&---------------------------------------------------------------------*
*& Form SCREEN_SETTING
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM SCREEN_SETTING .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FOM_GETDATA
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FOM_GETDATA .
CLEAR GT_DATA[] .
SELECT
EORD~MATNR
EORD~MATNR
EORD~WERKS
EORD~ZEORD
EORD~ERDAT
EORD~ERNAM
EORD~VDATU
EORD~BDATU
EORD~LIFNR
EORD~FLIFN
EORD~EBELN
EORD~EBELP
EORD~FEBEL
EORD~RESWK
EORD~FRESW
EORD~EMATN
EORD~NOTKZ
EORD~EKORG
EORD~VRTYP
EORD~EORTP
EORD~AUTET
EORD~MEINS
EORD~LOGSY
EORD~SOBKZ
MARA~MATKL
MARC~DISPO
INTO CORRESPONDING FIELDS OF TABLE GT_DATA[]
FROM EORD
INNER JOIN MARC ON EORD~MATNR = MARC~MATNR AND EORD~WERKS = MARC~WERKS
INNER JOIN MARA ON EORD~MATNR = MARA~MATNR
WHERE EORD~MATNR IN S_MATNR
AND EORD~WERKS IN S_WERKS
AND EORD~LIFNR IN S_LIFNR
AND MARA~MATKL IN S_MATKL
AND MARC~DISPO IN S_DISPO
.
LOOP AT GT_DATA.
SELECT SINGLE MAKTX INTO GT_DATA-MAKTX FROM MAKT
WHERE MATNR = GT_DATA-MATNR
.
SELECT SINGLE NAME1 NAME2 INTO ( GT_DATA-NAME1, GT_DATA-NAME2 ) FROM LFA1
WHERE LIFNR = GT_DATA-LIFNR
.
SELECT SINGLE WGBEZ60 INTO GT_DATA-WGBEZ60 FROM T023T
WHERE MATKL = GT_DATA-MATKL
.
SELECT SINGLE DSNAM INTO GT_DATA-DSNAM FROM T024D
WHERE DISPO = GT_DATA-DISPO
.
GT_DATA-NAME3 = GT_DATA-NAME1 && GT_DATA-NAME2 .
MODIFY GT_DATA .
CLEAR GT_DATA .
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_DISPLAY
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM FRM_DISPLAY .
CLEAR S_LAYOUT.
S_LAYOUT-ZEBRA = 'X'.
* S_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
S_LAYOUT-INFO_FIELDNAME = 'CLR'. "行颜色代码的字段
* S_LAYOUT-BOX_FIELDNAME = 'BOX'.
PERFORM FRM_FILL_FIELD .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_SAVE = 'A'
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = GT_FIELDCAT
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'
* I_CALLBACK_HTML_TOP_OF_PAGE = 'HTML_TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
TABLES
T_OUTTAB = GT_DATA[].
ENDFORM.
FORM FRM_FILL_FIELD .
DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DEFINE FILL_FIELD.
WA_FIELDCAT-FIELDNAME = &1.
WA_FIELDCAT-SELTEXT_L = &2.
IF WA_FIELDCAT-FIELDNAME = 'ZEORD'
OR WA_FIELDCAT-FIELDNAME = 'MATNR'
OR WA_FIELDCAT-FIELDNAME = 'WERKS'
.
WA_FIELDCAT-KEY = 'X'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'NOTKZ'
OR WA_FIELDCAT-FIELDNAME = 'FLIFN'
OR WA_FIELDCAT-FIELDNAME = 'FEBEL'
OR WA_FIELDCAT-FIELDNAME = 'FRESW'
.
WA_FIELDCAT-CHECKBOX = 'X'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'ZEORD'
.
WA_FIELDCAT-OUTPUTLEN = '4'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'MATNR'
OR WA_FIELDCAT-FIELDNAME = 'DSNAM'
.
WA_FIELDCAT-OUTPUTLEN = '25'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'MAKTX'
.
WA_FIELDCAT-OUTPUTLEN = '30'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'VDATU'
OR WA_FIELDCAT-FIELDNAME = 'BDATU'
.
WA_FIELDCAT-OUTPUTLEN = '10'.
ENDIF.
IF WA_FIELDCAT-FIELDNAME = 'WGBEZ60'
OR WA_FIELDCAT-FIELDNAME = 'NAME3'
.
WA_FIELDCAT-OUTPUTLEN = '40'.
ENDIF.
APPEND WA_FIELDCAT TO GT_FIELDCAT.
CLEAR WA_FIELDCAT.
END-OF-DEFINITION.
FILL_FIELD :
'ZEORD' '编号',
'MATNR' '物料',
'MAKTX' '物料描述',
'WERKS' '工厂',
'MATKL' '物料组',
'WGBEZ60' '物料组描述',
'DISPO' 'MRP控制员',
'DSNAM' 'MRP控制员描述',
'VDATU' '有效起始日',
'BDATU' '有效至',
'LIFNR' '供应商帐户号',
'NAME3' '供应商名称',
'RESWK' '采购工厂',
'EKORG' '采购组织',
'MEINS' '订单单位',
'EBELN' '协议',
'EBELP' '协议项目',
'AUTET' '物料计划',
'NOTKZ' '已冻结',
'FLIFN' '固定供应商',
'FEBEL' '固定框架采购协议项目',
'FRESW' '固定工厂',
'EMATN' 'MPN物料'.
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.
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 '&IC1'."表示双击
* IF IS_SELFIELD-FIELDNAME = 'EBELN' .
* CHECK IS_SELFIELD-TABINDEX > 0.
* CLEAR GT_DATA .
* READ TABLE GT_DATA INDEX IS_SELFIELD-TABINDEX.
*
* CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
* EXPORTING
* I_EBELN = GT_DATA-EBELN
* EXCEPTIONS
* NOT_FOUND =
* 1
* NO_AUTHORITY = 2
* INVALID_CALL = 3
* PREVIEW_NOT_POSSIBLE = 4
* OTHERS = 5.
*
* IF SY-SUBRC
* <> 0.
*
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER
* SY-MSGNO
*
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*
* ENDIF.
*
* IF SY-SUBRC <> 0.
** Implement suitable error handling here
* ENDIF.
*
* ELSE .
* MESSAGE '请选择有效字段!'TYPE 'S' DISPLAY LIKE 'W'.
* ENDIF .
WHEN 'POST_T'.
ENDCASE.
CALL METHOD REF->REFRESH_TABLE_DISPLAY
EXPORTING
IS_STABLE = LV_STABLE.
ENDFORM.
INITIALIZATION .
AT SELECTION-SCREEN.
PERFORM SCREEN_SETTING.
START-OF-SELECTION.
PERFORM FOM_GETDATA .
PERFORM FRM_DISPLAY.
MM-物料的资源清单(开发笔记)
最新推荐文章于 2022-11-11 18:35:18 发布
本博客详细介绍了如何使用 SAP ABAP 开发物料资源清单报表,包括数据选择、结构化查询、内部表操作及 ALV 控件的设置过程。通过实际案例,展示了如何从多个 SAP 核心数据库表中提取数据,并将其格式化为易于阅读的 ALV 格式。
摘要由CSDN通过智能技术生成