赞
踩
研发需求:导出在用零件清单
1、被挂bom的零件: bom多层展开 + 物料类型
2、用于销售的零件 :物料类型
3、近3个月新增的零件 :物料类型 + mara~ERDAT
- *&---------------------------------------------------------------------*
- *& REPORT ZRPT_PP_BOM_EXP
- *&
- *&---------------------------------------------------------------------*
- *& author 8256
- *& date 20230213
- *& from 20230213
- *& Tcode zppbom
- *&---------------------------------------------------------------------*
- REPORT ZRPT_PP_BOM_EXP.
-
- TABLES: MAKT, MARC,MARA,T438T.
-
- SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE TEXT-001.
- SELECT-OPTIONS S_WERKS FOR MARC-WERKS OBLIGATORY. "工厂
- SELECT-OPTIONS S_MATNR FOR MARC-MATNR. "物料
- SELECT-OPTIONS S_MTART FOR MARA-MTART. "物料类型
- SELECTION-SCREEN END OF BLOCK 001.
- SELECTION-SCREEN SKIP.
- SELECTION-SCREEN BEGIN OF BLOCK DESC WITH FRAME TITLE BLKTEXT1.
- SELECTION-SCREEN COMMENT 1(78) TXT1.
- SELECTION-SCREEN SKIP.
- SELECTION-SCREEN COMMENT 1(78) TXT2.
- SELECTION-SCREEN SKIP.
- SELECTION-SCREEN COMMENT 1(78) TXT3.
- SELECTION-SCREEN SKIP.
- SELECTION-SCREEN COMMENT 1(78) TXT4.
- SELECTION-SCREEN SKIP.
- SELECTION-SCREEN COMMENT 1(78) TXT5.
- SELECTION-SCREEN END OF BLOCK DESC.
- TYPES:
- BEGIN OF TYP_DATA,
- MATNR TYPE MARC-MATNR, "物料
- WERKS TYPE MARC-WERKS, "工厂
- IDNRK TYPE STPOX-IDNRK,"零件
- MAKTX TYPE MAKT-MAKTX,
- MAKTI TYPE MAKT-MAKTX,
- END OF TYP_DATA.
-
- DATA:
- GT_DATA TYPE TABLE OF TYP_DATA,
- GS_DATA TYPE TYP_DATA,
- GT_FIELDCAT TYPE LVC_T_FCAT,
- GS_FIELDCAT TYPE LVC_S_FCAT,
- GS_LAYOUT TYPE LVC_S_LAYO.
-
- DATA:runnercnt TYPE I,
- sumrcnt TYPE I.
- DATA:pdate TYPE sy-datum.
-
- DATA:STDATUM LIKE SY-DATUM,
- STUZEIT LIKE SY-UZEIT.
-
- INITIALIZATION.
- %_S_WERKS_%_APP_%-TEXT = '工厂'.
- %_S_MTART_%_APP_%-TEXT = '展示物料类型'.
- %_S_MATNR_%_APP_%-TEXT = '物料'.
-
- BLKTEXT1 = '使用场景和逻辑简介'.
- TXT1 = '需求来源:罗圆圆 功能:批量展开多个公司的bom,对于重复件保留唯一'.
- TXT2 = '注:展示物料类型 不选 则显示所有物料类型'.
- * TXT3 = ' 方式二 直接点 【SM30维护 视图 ZBBMS】 进行维护'.
- *TXT4 = '本月采购:ZMCCGEHZ(TCODE) 本月采购去除 公司间采购数据,即供应商是V开
- pdate = 20140515.CLEAR sumrcnt.
- PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
- TXT5 = '运行情况:总共' && runnercnt && '用户运行了' && sumrcnt && '次,'.
- pdate = sy-datum.pdate+4(4) = '0101'.CLEAR sumrcnt.
- PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
- TXT5 = TXT5 && '本年度总共' && runnercnt && '用户运行了' && sumrcnt && '次,'.
- pdate = sy-datum.pdate+6(2) = '01'.CLEAR sumrcnt.
- PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
- TXT5 = TXT5 && '本月度总共' && runnercnt && '用户运行了' && sumrcnt && '次'.
- START-OF-SELECTION.
- STDATUM = SY-DATUM.
- STUZEIT = SY-UZEIT.
- PERFORM GET_DATA.
- PERFORM PROCESS_DATA.
- PERform WRITERPTRUNRECORD.
- PERFORM DISPLAY_DATA.
- *&---------------------------------------------------------------------*
- *& Form WRITERPTRUNRECORD
- *&---------------------------------------------------------------------*
- * text
- *----------------------------------------------------------------------*
- FORM WRITERPTRUNRECORD.
- data:l_werks like t001w OCCURS 0 WITH HEADER LINE.
- select * into TABLE l_werks FROM t001w
- where t001w~werks in s_werks.
- loop at l_werks.
- get time.
- CALL FUNCTION 'ZSYS_RPT_RUNRECORD'
- EXPORTING
- TCODE = SY-TCODE
- PROGRAMM = SY-CPROG
- "bukrs = bukrs
- werks = l_werks-werks
- DATUMRST = STDATUM
- UZEITRST = STUZEIT
- BATCH = SY-BATCH
- DATUMREND = SY-datum
- UZEITREND = sy-UZEIT
- DATUMC = '20230213'
- RUNNER = SY-UNAME
- RPTSRC = 'lyy'.
- ENDLOOP.
- ENDFORM. "WRITERPTRUNRECORD
- *&---------------------------------------------------------------------*
- *& FORM GET_DATA
- *&---------------------------------------------------------------------*
- * 获取数据
- *----------------------------------------------------------------------*
- FORM GET_DATA.
- DATA : BEGIN OF t_stb OCCURS 0.
- INCLUDE STRUCTURE stpox.
- DATA END OF t_stb.
- DATA : BEGIN OF t_topmat OCCURS 0.
- INCLUDE STRUCTURE cstmat.
- DATA END OF t_topmat.
- DATA: BEGIN OF t_mast OCCURS 0,
- werks LIKE mast-werks,
- matnr LIKE mast-matnr.
- DATA END OF t_mast.
- data:lmatnr TYPE mara-matnr.
- SELECT werks matnr into TABLE t_mast
- from marc where matnr in s_matnr and werks in s_werks.
- LOOP AT T_MAST.
- CLEAR T_STB[].
- CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
- EXPORTING
- AUFSW = 'X'
- CAPID = 'PP01'
- DATUV = SY-DATUM
- MEHRS = 'X'
- MDMPS = ''
- EMENG = 1
- POSTP = 'L'
- MTNRV = T_MAST-MATNR
- WERKS = T_MAST-WERKS
- IMPORTING
- TOPMAT = T_TOPMAT
- TABLES
- STB = T_STB
- EXCEPTIONS
- ALT_NOT_FOUND = 1
- CALL_INVALID = 2
- MATERIAL_NOT_FOUND = 3
- MISSING_AUTHORIZATION = 4
- NO_BOM_FOUND = 5
- NO_PLANT_DATA = 6
- NO_SUITABLE_BOM_FOUND = 7
- CONVERSION_ERROR = 8
- OTHERS = 9.
- LOOP AT T_STB.
- clear lmatnr.
- GS_DATA-MATNR = T_MAST-MATNR.
- GS_DATA-WERKS = T_MAST-WERKS.
- GS_DATA-IDNRK = T_STB-IDNRK.
- SELECT MATNR INTO lmatnr FROM MARA WHERE MATNR = GS_DATA-IDNRK AND MTART IN S_MTART.
- ENDSELECT.
- IF SY-SUBRC = 0 and lmatnr is not INITIAL.
- APPEND GS_DATA TO GT_DATA.
- ENDIF.
- ENDLOOP.
- ENDLOOP.
- DELETE ADJACENT DUPLICATES FROM GT_DATA COMPARING MATNR IDNRK WERKS.
- LOOP AT GT_DATA INTO GS_DATA.
- SELECT SINGLE MAKTX INTO GS_DATA-MAKTX FROM MAKT WHERE MATNR = GS_DATA-MATNR AND SPRAS = 1.
- SELECT SINGLE MAKTX INTO GS_DATA-MAKTI FROM MAKT WHERE MATNR = GS_DATA-IDNRK AND SPRAS = 1.
- MODIFY GT_DATA FROM GS_DATA.
- ENDLOOP.
- ENDFORM. "GET_DATA
- *&---------------------------------------------------------------------*
- *& FORM PROCESS_DATA
- *&---------------------------------------------------------------------*
- * 处理数据
- *----------------------------------------------------------------------*
- FORM PROCESS_DATA.
- ENDFORM. "PROCESS_DATA
- *&---------------------------------------------------------------------*
- *& Form BUILD_FIELDCAT
- *&---------------------------------------------------------------------*
- * TEXT
- *----------------------------------------------------------------------*
- FORM BUILD_FIELDCAT USING P_FIELDNAME TYPE FIELDNAME
- P_QFIELDNAME TYPE LVC_QFNAME
- P_CFIELDNAME TYPE LVC_CFNAME
- P_REF_TABLE TYPE LVC_RTNAME
- P_REF_FIELD TYPE LVC_RFNAME
- P_CONVEXIT TYPE CONVEXIT
- P_EMPHASIZE TYPE LVC_EMPHSZ
- P_SCRTEXT_L TYPE SCRTEXT_L
- P_NO_ZERO TYPE XFLAG.
- GS_FIELDCAT-FIELDNAME = P_FIELDNAME.
- GS_FIELDCAT-QFIELDNAME = P_QFIELDNAME.
- GS_FIELDCAT-CFIELDNAME = P_CFIELDNAME.
- GS_FIELDCAT-REF_TABLE = P_REF_TABLE.
- GS_FIELDCAT-REF_FIELD = P_REF_FIELD.
- GS_FIELDCAT-CONVEXIT = P_CONVEXIT.
- GS_FIELDCAT-EMPHASIZE = P_EMPHASIZE.
- GS_FIELDCAT-SCRTEXT_L = P_SCRTEXT_L.
- GS_FIELDCAT-NO_ZERO = P_NO_ZERO.
- GS_FIELDCAT-COLDDICTXT = 'L'.
- APPEND GS_FIELDCAT TO GT_FIELDCAT.
- CLEAR: GS_FIELDCAT.
- ENDFORM. "BUILD_FIELDCAT
- *&---------------------------------------------------------------------*
- *& FORM DISPLAY_DATA
- *&---------------------------------------------------------------------*
- * 显示数据
- *----------------------------------------------------------------------*
- FORM DISPLAY_DATA.
- PERFORM BUILD_FIELDCAT USING 'WERKS' '' '' '' '' '' '' '工厂' ''.
- PERFORM BUILD_FIELDCAT USING 'MATNR' '' '' '' '' '' '' '物料' 'X'.
- PERFORM BUILD_FIELDCAT USING 'MAKTX' '' '' '' '' '' '' '物料描述' ''.
- PERFORM BUILD_FIELDCAT USING 'IDNRK' '' '' '' '' '' '' '子物料' 'X'.
- PERFORM BUILD_FIELDCAT USING 'MAKTI' '' '' '' '' '' '' '子物料描述' ''.
- gs_layout-cwidth_opt = 'X'.
- gs_layout-zebra = 'X'.
- CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
- EXPORTING
- I_CALLBACK_PROGRAM = SY-REPID
- " I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_ALV'
- I_CALLBACK_USER_COMMAND = 'USER_COMMAND_ALV'
- IT_FIELDCAT_LVC = GT_FIELDCAT
- IS_LAYOUT_LVC = GS_LAYOUT
- I_DEFAULT = 'X'
- I_SAVE = 'A'
- TABLES
- T_OUTTAB = GT_DATA
- EXCEPTIONS
- OTHERS = 1.
- ENDFORM. "DISPLAY_DATA
- **&---------------------------------------------------------------------*
- **& FORM PF_STATUS_ALV
- **&---------------------------------------------------------------------*
- ** TEXT
- **----------------------------------------------------------------------*
- *FORM PF_STATUS_ALV USING RT_EXTAB TYPE SLIS_T_EXTAB .
- * SET PF-STATUS 'STATUS_ALV' EXCLUDING RT_EXTAB.
- *ENDFORM. "PF_STATUS_ALV
- *&---------------------------------------------------------------------*
- *& FORM USER_COMMAND_ALV
- *&---------------------------------------------------------------------*
- * TEXT
- *----------------------------------------------------------------------*
- FORM USER_COMMAND_ALV USING R_UCOMM LIKE SY-UCOMM
- RS_SELFIELD TYPE SLIS_SELFIELD.
- CASE R_UCOMM.
- WHEN '&IC1'.
- CASE RS_SELFIELD-FIELDNAME.
- WHEN ''.
- * CHECK RS_SELFIELD-VALUE IS NOT INITIAL.
- * SET PARAMETER ID 'MBN' FIELD RS_SELFIELD-VALUE.
- * CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
- ENDCASE.
- ENDCASE.
- ENDFORM. "USER_COMMAND_ALV
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。