概述
*&---------------------------------------------------------------------*
*& Report ZPPR005
*&---------------------------------------------------------------------*
*& Author : NathanSun
*& Create Date : 2019-09-28
*& Program Type : Report
*& Description : WIP在制品报表
*&---------------------------------------------------------------------*
REPORT ZPPR005.
*&---------------------------------------------------------------------*
*& 包含 YN_TEST02_TOP
*&---------------------------------------------------------------------*
TABLES:EORD,MARC,MARA,ZTMJCP,AUFK,VBRK.
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 ,
WERKS TYPE AUFK-WERKS, "工厂
AUFNR TYPE AUFK-AUFNR, "工单号
ERDAT TYPE AUFK-ERDAT, "工单日期
MATNR TYPE AFPO-MATNR, "成品项目号
AUART TYPE AUFK-AUART, "工单类型
OBJNR TYPE AUFK-OBJNR, "工单状态
STTXT TYPE BSVX-STTXT, "工单状态
STLAN TYPE AFKO-STLAN, "BOM类型
MAKTX TYPE MAKT-MAKTX, "成品项目说明
PSMNG TYPE AFPO-PSMNG, "成品定单数量
WEMNG TYPE AFPO-WEMNG, "成品完工数量
AMEIN TYPE AFPO-AMEIN, "成品单位
MATNR_Z TYPE RESB-MATNR, "子件项目号
MAKTX_Z TYPE MAKT-MAKTX, "子件项目号说明
WERKS_Z TYPE RESB-WERKS, "子件发料工厂
MEINS TYPE RESB-MEINS, "子件单位
DATUV TYPE STPO-DATUV, "工单状态
MENGE TYPE STPO-MENGE, "子件BOM数量
MENGE_C TYPE STPO-MENGE, "子件BOM数量汇总
BDMNG TYPE RESB-BDMNG, "子件计划数量
MENGE_Y TYPE MSEG-MENGE, "子件已发数量
MENGE_G TYPE MSEG-MENGE, "工单产出数
MENGE_K TYPE MSEG-MENGE, "子件WIP参考数
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.
PARAMETERS: S_GJAHR TYPE NUMC4 OBLIGATORY.
PARAMETERS: S_POPER TYPE NUMC2 OBLIGATORY.
SELECT-OPTIONS: S_WERKS FOR AUFK-WERKS .
SELECT-OPTIONS: S_AUFNR FOR AUFK-AUFNR .
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 .
DATA:LV_DAT_L TYPE DATS .
DATA:LV_DAT_B TYPE DATS .
DATA:LV_DAT_H TYPE DATS .
DATA:LV_OBJNR TYPE JEST-OBJNR.
DATA:LV_NEW TYPE C.
DATA:LV_END TYPE C.
DATA:GT_MSEG TYPE TABLE OF MSEG WITH HEADER LINE.
CLEAR LV_DAT_L .
LV_DAT_L = S_GJAHR && '0101'.
CLEAR LV_DAT_B .
LV_DAT_B = S_GJAHR && S_POPER && '01'.
CLEAR LV_DAT_H .
CALL FUNCTION 'BKK_GET_MONTH_LASTDAY' "获取当前月的最后一天
EXPORTING
I_DATE = LV_DAT_B
IMPORTING
E_DATE = LV_DAT_H.
CLEAR GT_DATA[] .
SELECT
AUFK~WERKS
AUFK~AUFNR
AUFK~ERDAT
AUFK~AUART
AUFK~OBJNR
AFKO~STLAN
AFPO~MATNR
AFPO~PSMNG
AFPO~WEMNG
AFPO~AMEIN
RESB~MATNR AS MATNR_Z
RESB~WERKS AS WERKS_Z
RESB~MEINS
RESB~BDMNG
INTO CORRESPONDING FIELDS OF TABLE GT_DATA[]
FROM RESB
INNER JOIN AFPO ON RESB~AUFNR = AFPO~AUFNR AND RESB~BAUGR = AFPO~MATNR
INNER JOIN AFKO ON AFPO~AUFNR = AFKO~AUFNR
INNER JOIN AUFK ON AFKO~AUFNR = AUFK~AUFNR
WHERE AUFK~WERKS IN S_WERKS
AND AUFK~AUFNR IN S_AUFNR
AND AUFK~ERDAT >= LV_DAT_L
AND AUFK~ERDAT <= LV_DAT_H
.
LOOP AT GT_DATA.
CLEAR LV_OBJNR .
LV_OBJNR = |OR{ GT_DATA-AUFNR }|.
CALL FUNCTION 'STATUS_TEXT_EDIT'
EXPORTING
CLIENT = SY-MANDT
OBJNR = LV_OBJNR
ONLY_ACTIVE = 'X'
SPRAS = SY-LANGU
IMPORTING
LINE = GT_DATA-STTXT.
IF GT_DATA-STTXT CS 'PREL'
OR GT_DATA-STTXT CS 'REL'
.
IF GT_DATA-STTXT CS 'DLV'
OR GT_DATA-STTXT CS 'TECO'
.
DELETE GT_DATA.
ELSE .
*子件BOM数量:
SELECT SINGLE STLNR, MATNR INTO @DATA(LV_MAST) FROM MAST
WHERE MATNR = @GT_DATA-MATNR
.
SELECT SINGLE MENGE MAX( DATUV ) INTO ( GT_DATA-MENGE, GT_DATA-DATUV )
FROM STPO
WHERE STLNR = LV_MAST-STLNR
AND IDNRK = GT_DATA-MATNR_Z
GROUP BY STPO~MENGE
.
CLEAR LV_MAST .
*子件已发数量:
CLEAR GT_MSEG[] .
SELECT MENGE MATNR AUFNR BWART INTO CORRESPONDING FIELDS OF TABLE GT_MSEG[] FROM MSEG
WHERE BWART IN ( '261','262' )
AND MATNR = GT_DATA-MATNR_Z
AND AUFNR = GT_DATA-AUFNR
.
LOOP AT GT_MSEG .
IF GT_MSEG-BWART = '262'.
GT_MSEG-MENGE = GT_MSEG-MENGE * -1 .
ENDIF.
GT_DATA-MENGE_Y = GT_DATA-MENGE_Y + GT_MSEG-MENGE .
CLEAR GT_MSEG .
ENDLOOP.
MODIFY GT_DATA .
ENDIF.
ELSE.
DELETE GT_DATA.
ENDIF.
CLEAR GT_DATA.
ENDLOOP.
SORT GT_DATA[] BY WERKS AUFNR MATNR .
GT_DATA_A[] = GT_DATA[] .
DELETE ADJACENT DUPLICATES FROM GT_DATA_A[] COMPARING WERKS AUFNR MATNR.
LOOP AT GT_DATA_A.
LOOP AT GT_DATA WHERE WERKS = GT_DATA_A-WERKS
AND AUFNR = GT_DATA_A-AUFNR
AND MATNR = GT_DATA_A-MATNR.
GT_DATA_A-MENGE_C = GT_DATA_A-MENGE_C + GT_DATA-MENGE .
CLEAR GT_DATA .
ENDLOOP.
MODIFY GT_DATA_A.
CLEAR GT_DATA_A .
ENDLOOP.
LOOP AT GT_DATA.
*工单产出数:
READ TABLE GT_DATA_A WITH KEY WERKS = GT_DATA-WERKS AUFNR = GT_DATA-AUFNR MATNR = GT_DATA-MATNR .
IF SY-SUBRC = 0 AND GT_DATA_A-MENGE_C <> 0.
GT_DATA-MENGE_C = GT_DATA_A-MENGE_C .
GT_DATA-MENGE_G = GT_DATA-WEMNG * ( GT_DATA-MENGE / GT_DATA-MENGE_C ) .
ENDIF.
*子件WIP参考数:
GT_DATA-MENGE_K = GT_DATA-MENGE_Y - GT_DATA-MENGE_G .
SELECT SINGLE MAKTX INTO GT_DATA-MAKTX FROM MAKT
WHERE MATNR = GT_DATA-MATNR
.
SELECT SINGLE MAKTX INTO GT_DATA-MAKTX_Z FROM MAKT
WHERE MATNR = GT_DATA-MATNR_Z
.
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 = 'WERKS'
OR WA_FIELDCAT-FIELDNAME = 'AUFNR'
OR WA_FIELDCAT-FIELDNAME = 'MATNR'
.
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 = 'AUFNR'
.
WA_FIELDCAT-REF_TABNAME = 'AUFK'.
WA_FIELDCAT-REF_FIELDNAME = 'AUFNR'.
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 :
'WERKS' '工厂',
'AUFNR' '工单号',
'ERDAT' '工单日期',
'MATNR' '成品项目号',
'AUART' '工单类型',
'STTXT' '工单状态',
'STLAN' 'BOM类型',
'MAKTX' '成品项目说明',
'PSMNG' '成品定单数量',
'WEMNG' '成品完工数量',
'AMEIN' '成品单位',
'MATNR_Z' '子件项目号',
'MAKTX_Z' '子件项目号说明',
'WERKS_Z' '子件发料工厂',
'MEINS' '子件单位',
'MENGE' '子件BOM数量',
'BDMNG' '子件计划数量',
'MENGE_Y' '子件已发数量',
'MENGE_K' '子件WIP参考数'.
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 '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.
最后
以上就是粗暴纸飞机为你收集整理的PP-WIP在制品报表(ABAP开发笔记)的全部内容,希望文章能够帮你解决PP-WIP在制品报表(ABAP开发笔记)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复