公众号:SAP Technical
本文作者:matinal
 

前言部分

大家可以关注我的公众号,公众号里的排版更好,阅读更舒适。

正文部分

TCODE::CS15

或者函数::CS_WHERE_USED_MAT

​

tables : stpo,stas,mara,makt.

data : begin of itab occurs ,
matnr like mast-matnr,
menge like stpo-menge,
end of itab. data : begin of alttab occurs ,
matnr like mast-matnr,
menge like stpo-menge,
end of alttab. data : begin of top_code occurs ,
matnr(),
maktx(),
meins(),
menge like stpo-menge,
matkl(),
wrkst(),
end of top_code. data : begin of makr occurs ,
maker(),
idnlf(),
end of makr. data : begin of usedtab occurs .
include structure stpov.
data : end of usedtab. data : begin of equicat occurs .
include structure cscequi.
data : end of equicat. data : begin of kndcat occurs .
include structure cscknd.
data : end of kndcat. data : begin of matcat occurs .
include structure cscmat.
data : end of matcat. data : begin of stdcat occurs .
include structure cscstd.
data : end of stdcat. data : begin of tplcat occurs .
include structure csctpl.
data : end of tplcat. data : top_cnt() type n,
m_cnt() type n,
lin() type n,
line_cnt() type n. selection-screen begin of block blk1 with frame.
selection-screen : comment () text-,
skip.
parameters : matnr like marc-matnr obligatory,
werks like marc-werks obligatory default 'PQ50'.
select-options : bdate for sy-datum default sy-datum to sy-datum
no-extension obligatory.
selection-screen end of block blk1. start-of-selection.
itab-matnr = matnr.
itab-menge = .
append itab.
clear itab. perform get_top_code. ************************************
*&---------------------------------------------------------------------*
*& Form GET_TOP_CODE
*&---------------------------------------------------------------------*
form get_top_code. clear lin.
describe table itab lines lin.
if lin = .
exit.
endif. loop at itab.
call function 'CS_WHERE_USED_MAT'
exporting
datub = bdate-high
datuv = bdate-low
matnr = itab-matnr
werks = werks
tables
wultb = usedtab
equicat = equicat
kndcat = kndcat
matcat = matcat
stdcat = stdcat
tplcat = tplcat
exceptions
call_invalid =
material_not_found =
no_where_used_rec_found =
no_where_used_rec_selected =
no_where_used_rec_valid =
others = . clear line_cnt.
describe table usedtab lines line_cnt.
if line_cnt = .
move itab-matnr to top_code-matnr.
top_code-menge = itab-menge.
collect top_code.
clear top_code.
else.
loop at usedtab where postp ne 'F' and datuv le bdate-high
and ( sumfg = ' ' or sumfg = 'x' ).
select single lkenz into stas-lkenz from stas
where stlty = 'M'
and stlnr = usedtab-stlnr
and stlal = ''
and stlkn = usedtab-stlkn
and datuv le bdate-low
and lkenz = 'X'.
if sy-subrc ne .
move usedtab-matnr to alttab-matnr.
alttab-menge = usedtab-menge * itab-menge.
collect alttab.
endif.
clear alttab.
endloop.
endif.
refresh : usedtab,equicat,kndcat,matcat,stdcat,tplcat. endloop. refresh itab.
itab[] = alttab[].
refresh alttab.
perform get_top_code. endform. " GET_TOP_CODE ​

【ABAP系列】SAP BOM反查的更多相关文章

  1. SAP函数 CS_WHERE_USED_MAT 反查上层BOM

    遇到用户要根据下层物料反查最上层BOM物料是什么. 试了一下,通过函数 CS_WHERE_USED_MAT 来查询,但是只能往上查询一层,类似事务码CS15的效果.如果要找最上层物料,需要自己写迭代进 ...

  2. 【ABAP系列】SAP GUI740 PATCH5出现弹窗BUG

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP GUI740 PATCH ...

  3. SAP MM 根据采购订单反查采购申请?

    SAP MM 根据采购订单反查采购申请? 前日微信上某同行发来一个message,说是想知道如何通过采购订单号查询到其前端的采购申请号. 笔者首先想到去检查采购订单相关的常用报表ME2L/ME2M/M ...

  4. 单层反查BOM

    *&---------------------------------------------------------------------* *& Report YCX_001 * ...

  5. 【ABAP系列】SAP ABAP BAPI_REQUISITION_CREATE创建采购申请

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP BAPI_RE ...

  6. 【ABAP系列】SAP ABAP 字符编码与解码、Unicode

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 字符编码与解码 ...

  7. 【ABAP系列】SAP ABAP下载带密码的Excel文件

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP下载带密码的Ex ...

  8. 【ABAP系列】SAP ABAP 高级业务应用程序编程(ABAP)

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP 高级业务应用程 ...

  9. 【ABAP系列】SAP ABAP Break Point

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP Break P ...

随机推荐

  1. ab测试nginx Nginx性能优化

    转自:https://www.cnblogs.com/nulige/p/9369700.html 1.性能优化概述 在做性能优化前, 我们需要对如下进行考虑 1.当前系统结构瓶颈 观察指标 压力测试 ...

  2. LINUX笔记之二常用命令(文件处理命令)

    一.概述 1. “.”开头的文件是隐藏文件,大小写敏感是因为用C语言编写 2. DOS中 cd..可回到父目录 在LINUX中要用cd ..(用空格) 3. 4.LINUX命令有两种:仅root可执行 ...

  3. JVM启动参数大全及默认值

    Java启动参数共分为三类: 其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容: 其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足, ...

  4. .net post 字符串含有+号的时候,加号会变成空格 处理方法

    value= value.Replace("+", "%2B");  替换加号

  5. 窗体操作:GetWindowLong()

    函数原型: LONG GetWindowLong( HWND hWnd,int nIndex )   参数: hWnd:指定窗口的句柄 nIndex:需要获得的信息的类型      值         ...

  6. 51 Nod 1073 约瑟夫环

    1073 约瑟夫环  基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题  收藏  关注 N个人坐成一个圆环(编号为1 - N),从第1个人开始报数,数到K的人出列,后面的人 ...

  7. 「SCOI2015」小凸玩矩阵

    题目链接 问题分析 题目给了充足的暗示,我们只需要二分答案然后跑匈牙利即可.要相信匈牙利的速度 参考程序 #include <bits/stdc++.h> using namespace ...

  8. [笔记]makefile编写

    makefile的隐含规则默认处理第一个目标 函数:wildcard可以进行文本匹配 patsubst内容替换 变量: $@代表目标 $^  代表全部依赖 $<  第一个依赖 $?   第一个变 ...

  9. 剑指offer-Q60 n个骰子的点数

    python版本代码 g_maxValue = 6 # 单个骰子最大的点数 def PrintProbability(number): ''' :param number: 骰子的个数 :return ...

  10. mongo注解详解

    1.@Entity如果你想通过Morphia把你的对象保存到Mongo中,你首先要做的是使用@Entity注解你的类:@Entity(value="comm_user_favorite_co ...