当前位置:   article > 正文

SAP 批量bom展开的需求_sap批量导多个物料bom

sap批量导多个物料bom

研发需求:导出在用零件清单 

1、被挂bom的零件: bom多层展开 +  物料类型

2、用于销售的零件  :物料类型

3、近3个月新增的零件 :物料类型 + mara~ERDAT

 

  1. *&---------------------------------------------------------------------*
  2. *& REPORT ZRPT_PP_BOM_EXP
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *& author 8256
  6. *& date 20230213
  7. *& from 20230213
  8. *& Tcode zppbom
  9. *&---------------------------------------------------------------------*
  10. REPORT ZRPT_PP_BOM_EXP.
  11. TABLES: MAKT, MARC,MARA,T438T.
  12. SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE TEXT-001.
  13. SELECT-OPTIONS S_WERKS FOR MARC-WERKS OBLIGATORY. "工厂
  14. SELECT-OPTIONS S_MATNR FOR MARC-MATNR. "物料
  15. SELECT-OPTIONS S_MTART FOR MARA-MTART. "物料类型
  16. SELECTION-SCREEN END OF BLOCK 001.
  17. SELECTION-SCREEN SKIP.
  18. SELECTION-SCREEN BEGIN OF BLOCK DESC WITH FRAME TITLE BLKTEXT1.
  19. SELECTION-SCREEN COMMENT 1(78) TXT1.
  20. SELECTION-SCREEN SKIP.
  21. SELECTION-SCREEN COMMENT 1(78) TXT2.
  22. SELECTION-SCREEN SKIP.
  23. SELECTION-SCREEN COMMENT 1(78) TXT3.
  24. SELECTION-SCREEN SKIP.
  25. SELECTION-SCREEN COMMENT 1(78) TXT4.
  26. SELECTION-SCREEN SKIP.
  27. SELECTION-SCREEN COMMENT 1(78) TXT5.
  28. SELECTION-SCREEN END OF BLOCK DESC.
  29. TYPES:
  30. BEGIN OF TYP_DATA,
  31. MATNR TYPE MARC-MATNR, "物料
  32. WERKS TYPE MARC-WERKS, "工厂
  33. IDNRK TYPE STPOX-IDNRK,"零件
  34. MAKTX TYPE MAKT-MAKTX,
  35. MAKTI TYPE MAKT-MAKTX,
  36. END OF TYP_DATA.
  37. DATA:
  38. GT_DATA TYPE TABLE OF TYP_DATA,
  39. GS_DATA TYPE TYP_DATA,
  40. GT_FIELDCAT TYPE LVC_T_FCAT,
  41. GS_FIELDCAT TYPE LVC_S_FCAT,
  42. GS_LAYOUT TYPE LVC_S_LAYO.
  43. DATA:runnercnt TYPE I,
  44. sumrcnt TYPE I.
  45. DATA:pdate TYPE sy-datum.
  46. DATA:STDATUM LIKE SY-DATUM,
  47. STUZEIT LIKE SY-UZEIT.
  48. INITIALIZATION.
  49. %_S_WERKS_%_APP_%-TEXT = '工厂'.
  50. %_S_MTART_%_APP_%-TEXT = '展示物料类型'.
  51. %_S_MATNR_%_APP_%-TEXT = '物料'.
  52. BLKTEXT1 = '使用场景和逻辑简介'.
  53. TXT1 = '需求来源:罗圆圆 功能:批量展开多个公司的bom,对于重复件保留唯一'.
  54. TXT2 = '注:展示物料类型 不选 则显示所有物料类型'.
  55. * TXT3 = ' 方式二 直接点 【SM30维护 视图 ZBBMS】 进行维护'.
  56. *TXT4 = '本月采购:ZMCCGEHZ(TCODE) 本月采购去除 公司间采购数据,即供应商是V开
  57. pdate = 20140515.CLEAR sumrcnt.
  58. PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
  59. TXT5 = '运行情况:总共' && runnercnt && '用户运行了' && sumrcnt && '次,'.
  60. pdate = sy-datum.pdate+4(4) = '0101'.CLEAR sumrcnt.
  61. PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
  62. TXT5 = TXT5 && '本年度总共' && runnercnt && '用户运行了' && sumrcnt && '次,'.
  63. pdate = sy-datum.pdate+6(2) = '01'.CLEAR sumrcnt.
  64. PERFORM getrunstatic(ZPRT_FI_SCCB1L) USING pdate sy-REPID CHANGING runnercnt sumrcnt.
  65. TXT5 = TXT5 && '本月度总共' && runnercnt && '用户运行了' && sumrcnt && ''.
  66. START-OF-SELECTION.
  67. STDATUM = SY-DATUM.
  68. STUZEIT = SY-UZEIT.
  69. PERFORM GET_DATA.
  70. PERFORM PROCESS_DATA.
  71. PERform WRITERPTRUNRECORD.
  72. PERFORM DISPLAY_DATA.
  73. *&---------------------------------------------------------------------*
  74. *& Form WRITERPTRUNRECORD
  75. *&---------------------------------------------------------------------*
  76. * text
  77. *----------------------------------------------------------------------*
  78. FORM WRITERPTRUNRECORD.
  79. data:l_werks like t001w OCCURS 0 WITH HEADER LINE.
  80. select * into TABLE l_werks FROM t001w
  81. where t001w~werks in s_werks.
  82. loop at l_werks.
  83. get time.
  84. CALL FUNCTION 'ZSYS_RPT_RUNRECORD'
  85. EXPORTING
  86. TCODE = SY-TCODE
  87. PROGRAMM = SY-CPROG
  88. "bukrs = bukrs
  89. werks = l_werks-werks
  90. DATUMRST = STDATUM
  91. UZEITRST = STUZEIT
  92. BATCH = SY-BATCH
  93. DATUMREND = SY-datum
  94. UZEITREND = sy-UZEIT
  95. DATUMC = '20230213'
  96. RUNNER = SY-UNAME
  97. RPTSRC = 'lyy'.
  98. ENDLOOP.
  99. ENDFORM. "WRITERPTRUNRECORD
  100. *&---------------------------------------------------------------------*
  101. *& FORM GET_DATA
  102. *&---------------------------------------------------------------------*
  103. * 获取数据
  104. *----------------------------------------------------------------------*
  105. FORM GET_DATA.
  106. DATA : BEGIN OF t_stb OCCURS 0.
  107. INCLUDE STRUCTURE stpox.
  108. DATA END OF t_stb.
  109. DATA : BEGIN OF t_topmat OCCURS 0.
  110. INCLUDE STRUCTURE cstmat.
  111. DATA END OF t_topmat.
  112. DATA: BEGIN OF t_mast OCCURS 0,
  113. werks LIKE mast-werks,
  114. matnr LIKE mast-matnr.
  115. DATA END OF t_mast.
  116. data:lmatnr TYPE mara-matnr.
  117. SELECT werks matnr into TABLE t_mast
  118. from marc where matnr in s_matnr and werks in s_werks.
  119. LOOP AT T_MAST.
  120. CLEAR T_STB[].
  121. CALL FUNCTION 'CS_BOM_EXPL_MAT_V2'
  122. EXPORTING
  123. AUFSW = 'X'
  124. CAPID = 'PP01'
  125. DATUV = SY-DATUM
  126. MEHRS = 'X'
  127. MDMPS = ''
  128. EMENG = 1
  129. POSTP = 'L'
  130. MTNRV = T_MAST-MATNR
  131. WERKS = T_MAST-WERKS
  132. IMPORTING
  133. TOPMAT = T_TOPMAT
  134. TABLES
  135. STB = T_STB
  136. EXCEPTIONS
  137. ALT_NOT_FOUND = 1
  138. CALL_INVALID = 2
  139. MATERIAL_NOT_FOUND = 3
  140. MISSING_AUTHORIZATION = 4
  141. NO_BOM_FOUND = 5
  142. NO_PLANT_DATA = 6
  143. NO_SUITABLE_BOM_FOUND = 7
  144. CONVERSION_ERROR = 8
  145. OTHERS = 9.
  146. LOOP AT T_STB.
  147. clear lmatnr.
  148. GS_DATA-MATNR = T_MAST-MATNR.
  149. GS_DATA-WERKS = T_MAST-WERKS.
  150. GS_DATA-IDNRK = T_STB-IDNRK.
  151. SELECT MATNR INTO lmatnr FROM MARA WHERE MATNR = GS_DATA-IDNRK AND MTART IN S_MTART.
  152. ENDSELECT.
  153. IF SY-SUBRC = 0 and lmatnr is not INITIAL.
  154. APPEND GS_DATA TO GT_DATA.
  155. ENDIF.
  156. ENDLOOP.
  157. ENDLOOP.
  158. DELETE ADJACENT DUPLICATES FROM GT_DATA COMPARING MATNR IDNRK WERKS.
  159. LOOP AT GT_DATA INTO GS_DATA.
  160. SELECT SINGLE MAKTX INTO GS_DATA-MAKTX FROM MAKT WHERE MATNR = GS_DATA-MATNR AND SPRAS = 1.
  161. SELECT SINGLE MAKTX INTO GS_DATA-MAKTI FROM MAKT WHERE MATNR = GS_DATA-IDNRK AND SPRAS = 1.
  162. MODIFY GT_DATA FROM GS_DATA.
  163. ENDLOOP.
  164. ENDFORM. "GET_DATA
  165. *&---------------------------------------------------------------------*
  166. *& FORM PROCESS_DATA
  167. *&---------------------------------------------------------------------*
  168. * 处理数据
  169. *----------------------------------------------------------------------*
  170. FORM PROCESS_DATA.
  171. ENDFORM. "PROCESS_DATA
  172. *&---------------------------------------------------------------------*
  173. *& Form BUILD_FIELDCAT
  174. *&---------------------------------------------------------------------*
  175. * TEXT
  176. *----------------------------------------------------------------------*
  177. FORM BUILD_FIELDCAT USING P_FIELDNAME TYPE FIELDNAME
  178. P_QFIELDNAME TYPE LVC_QFNAME
  179. P_CFIELDNAME TYPE LVC_CFNAME
  180. P_REF_TABLE TYPE LVC_RTNAME
  181. P_REF_FIELD TYPE LVC_RFNAME
  182. P_CONVEXIT TYPE CONVEXIT
  183. P_EMPHASIZE TYPE LVC_EMPHSZ
  184. P_SCRTEXT_L TYPE SCRTEXT_L
  185. P_NO_ZERO TYPE XFLAG.
  186. GS_FIELDCAT-FIELDNAME = P_FIELDNAME.
  187. GS_FIELDCAT-QFIELDNAME = P_QFIELDNAME.
  188. GS_FIELDCAT-CFIELDNAME = P_CFIELDNAME.
  189. GS_FIELDCAT-REF_TABLE = P_REF_TABLE.
  190. GS_FIELDCAT-REF_FIELD = P_REF_FIELD.
  191. GS_FIELDCAT-CONVEXIT = P_CONVEXIT.
  192. GS_FIELDCAT-EMPHASIZE = P_EMPHASIZE.
  193. GS_FIELDCAT-SCRTEXT_L = P_SCRTEXT_L.
  194. GS_FIELDCAT-NO_ZERO = P_NO_ZERO.
  195. GS_FIELDCAT-COLDDICTXT = 'L'.
  196. APPEND GS_FIELDCAT TO GT_FIELDCAT.
  197. CLEAR: GS_FIELDCAT.
  198. ENDFORM. "BUILD_FIELDCAT
  199. *&---------------------------------------------------------------------*
  200. *& FORM DISPLAY_DATA
  201. *&---------------------------------------------------------------------*
  202. * 显示数据
  203. *----------------------------------------------------------------------*
  204. FORM DISPLAY_DATA.
  205. PERFORM BUILD_FIELDCAT USING 'WERKS' '' '' '' '' '' '' '工厂' ''.
  206. PERFORM BUILD_FIELDCAT USING 'MATNR' '' '' '' '' '' '' '物料' 'X'.
  207. PERFORM BUILD_FIELDCAT USING 'MAKTX' '' '' '' '' '' '' '物料描述' ''.
  208. PERFORM BUILD_FIELDCAT USING 'IDNRK' '' '' '' '' '' '' '子物料' 'X'.
  209. PERFORM BUILD_FIELDCAT USING 'MAKTI' '' '' '' '' '' '' '子物料描述' ''.
  210. gs_layout-cwidth_opt = 'X'.
  211. gs_layout-zebra = 'X'.
  212. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  213. EXPORTING
  214. I_CALLBACK_PROGRAM = SY-REPID
  215. " I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_ALV'
  216. I_CALLBACK_USER_COMMAND = 'USER_COMMAND_ALV'
  217. IT_FIELDCAT_LVC = GT_FIELDCAT
  218. IS_LAYOUT_LVC = GS_LAYOUT
  219. I_DEFAULT = 'X'
  220. I_SAVE = 'A'
  221. TABLES
  222. T_OUTTAB = GT_DATA
  223. EXCEPTIONS
  224. OTHERS = 1.
  225. ENDFORM. "DISPLAY_DATA
  226. **&---------------------------------------------------------------------*
  227. **& FORM PF_STATUS_ALV
  228. **&---------------------------------------------------------------------*
  229. ** TEXT
  230. **----------------------------------------------------------------------*
  231. *FORM PF_STATUS_ALV USING RT_EXTAB TYPE SLIS_T_EXTAB .
  232. * SET PF-STATUS 'STATUS_ALV' EXCLUDING RT_EXTAB.
  233. *ENDFORM. "PF_STATUS_ALV
  234. *&---------------------------------------------------------------------*
  235. *& FORM USER_COMMAND_ALV
  236. *&---------------------------------------------------------------------*
  237. * TEXT
  238. *----------------------------------------------------------------------*
  239. FORM USER_COMMAND_ALV USING R_UCOMM LIKE SY-UCOMM
  240. RS_SELFIELD TYPE SLIS_SELFIELD.
  241. CASE R_UCOMM.
  242. WHEN '&IC1'.
  243. CASE RS_SELFIELD-FIELDNAME.
  244. WHEN ''.
  245. * CHECK RS_SELFIELD-VALUE IS NOT INITIAL.
  246. * SET PARAMETER ID 'MBN' FIELD RS_SELFIELD-VALUE.
  247. * CALL TRANSACTION 'MB03' AND SKIP FIRST SCREEN.
  248. ENDCASE.
  249. ENDCASE.
  250. ENDFORM. "USER_COMMAND_ALV

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/323762?site
推荐阅读
相关标签
  

闽ICP备14008679号