反查BOM, 找出它的上阶
转自:https://blog.csdn.net/zhongguomao/article/details/80172441
查询物料的上阶方法有三:
1. CS15 可直接查出物料的上阶直至顶阶物料.
2. CALL FUNCTION. 只能查上上阶, 要想得到顶阶, 需要递归查询.
CS_WHERE_USED_MAT Bills of material; where-used list
CS_WHERE_USED_MAT_ANY Bills of material; where-used list as material or class item
3. 根据表 STAS 和 STPO.
REPORT z_af_023.
DATA: BEGIN OF iwultb OCCURS 0.
INCLUDE STRUCTURE stpov. " BOM Item
DATA: END OF iwultb.
DATA: BEGIN OF iequicat OCCURS 0.
INCLUDE STRUCTURE cscequi. " BOM Explosion: Equipments
DATA: END OF iequicat.
*
DATA: BEGIN OF ikndcat OCCURS 0.
INCLUDE STRUCTURE cscknd. " BOM Explosion: Sales Order
DATA: END OF ikndcat.
*
DATA: BEGIN OF imatcat OCCURS 0.
INCLUDE STRUCTURE cscmat. " BOM Explosion: Materials
DATA: END OF imatcat.
*
DATA: BEGIN OF istdcat OCCURS 0.
INCLUDE STRUCTURE cscstd. " BOM Explosion: Standard Object
DATA: END OF istdcat.
*
DATA: BEGIN OF itplcat OCCURS 0.
INCLUDE STRUCTURE csctpl. " BOM Explosion: Equipments
DATA: END OF itplcat.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME.
PARAMETERS: i_werks LIKE marc-werks.
PARAMETERS: i_matnr LIKE marc-matnr.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
DATA: datub LIKE rc29l-datub,
datuv LIKE rc29l-datuv.
CALL FUNCTION 'CS_WHERE_USED_MAT'
EXPORTING
datub = datub
datuv = datuv
matnr
DATA: BEGIN OF iwultb OCCURS 0.
INCLUDE STRUCTURE stpov. " BOM Item
DATA: END OF iwultb.
DATA: BEGIN OF iequicat OCCURS 0.
INCLUDE STRUCTURE cscequi. " BOM Explosion: Equipments
DATA: END OF iequicat.
*
DATA: BEGIN OF ikndcat OCCURS 0.
INCLUDE STRUCTURE cscknd. " BOM Explosion: Sales Order
DATA: END OF ikndcat.
*
DATA: BEGIN OF imatcat OCCURS 0.
INCLUDE STRUCTURE cscmat. " BOM Explosion: Materials
DATA: END OF imatcat.
*
DATA: BEGIN OF istdcat OCCURS 0.
INCLUDE STRUCTURE cscstd. " BOM Explosion: Standard Object
DATA: END OF istdcat.
*
DATA: BEGIN OF itplcat OCCURS 0.
INCLUDE STRUCTURE csctpl. " BOM Explosion: Equipments
DATA: END OF itplcat.
SELECTION-SCREEN BEGIN OF BLOCK bk1 WITH FRAME.
PARAMETERS: i_werks LIKE marc-werks.
PARAMETERS: i_matnr LIKE marc-matnr.
SELECTION-SCREEN END OF BLOCK bk1.
START-OF-SELECTION.
DATA: datub LIKE rc29l-datub,
datuv LIKE rc29l-datuv.
CALL FUNCTION 'CS_WHERE_USED_MAT'
EXPORTING
datub = datub
datuv = datuv
matnr
本人常年接收SAP运维和远程项目,ECC,S/4HANA,CRM,WDA.
远程人天可谈,终身售后,有活请联系V信:18925782767(问问题免费,欢迎交流!)
!!请关注本人技术分享公众号:SAP翔子(可扫头像二维码)
每天分享新知识,博客文章也会陆续整理并迁移至公众号,与您一起共同学习