SAP MM 并非奇怪现象之MB5B报表里期初库存余额或者期末库存余额为负数?

SAP MM 并非奇怪现象之MB5B报表里期初库存余额或者期末库存余额为负数?

 

笔者在做某个项目的进销存报表优化的的时候,发现了一个奇怪现象:MB5B查某个日期或某个期间的库存的时候,发现有负的库存余额!

 

 

以物料为号1400005012为例,MB5B,

 

 

 

期初金额与期末金额都是负数?尼玛,这不科学啊!某一天的物料库存余额怎么能为负数呢?笔者很是好奇与不解。于是去上网查资料,发现有不少同行都有发现这个现象! 笔者还发现了某外国同行写的一篇BLOG, 看了这个BLOG,笔者茅塞大开。

 

如下文字来自互联网该同行的BLOG, 与诸多同行朋友共勉。

 

https://blogs.sap.com/2008/06/08/mb5b-offers-negative-results-when-executed-per-posting-date/

 

Many users see negative results when they execute the transaction MB5B for a specific posting date, even when the negative stocks have not been allowed in the customizing.

 

We need to consider that, at the time of the goods issue, the system only validates whether sufficient stock is available in the complete posting period, and not on a specific posting date. 

The stock and value information is kept in the tables on a period basis.

The table entries relate to the complete posting period, and not to a specific posting date.

If there is stock enough in a posting period, the system will indeed allow the posting, even if it does not make sense according to the specific date within the period. 

If we were posting the goods issue in a different period in which we do not have stock, the system would indeed send an error message, but if the postings occur in the same period with different dates, the system will not issue any error. 

For example, we can have the following situation:

 

Stock in the period 04/2008

0 PC

  

Goods movements in the period 05/2008:

 

Movement

Posting date

Date of entry

Quantity

Goods Receipt

20.05.2008

20.05.2008

10 PC

Goods Issue

10.05.2008

21.05.2008

10 PC

 

 

The system allows this goods issue to be posted with a posting date before than the posting date in the goods receipt because on the period 05/2008 we have stock enough to save this goods movement. The system checks for stock in the whole period, and not to specific dates within the period.

If negative stocks are not allowed in the system, this goods issue could not have been executed with posting date in the previous month (04/2008), because in this period we do not have stock. In this case the system sends the error message M7021 reporting a deficit of stock at Storage Location level in the previous period (M7 021 “Deficit of SL Unrestr. prev. + Quantity: Material, Plant, Storage Location”).

  

In the stocks tables (MARC, MARD, MBEW) the system will never allow negative stocks if you make the settings for negative stocks NOT allowed in Customizing for Inventory Management by using transaction “OMJ1”.

 

Reports like MB5B (Stock on posting date) can offer negative results when executed for dates previous to the goods receipt, but this is only a reporting issue: if the program is correctly executed for the complete period (month/year), it should never show negative values. 

For the example we were discussing before: 

MB5B executed with a selection date within the month like 10.05.2008: 

 

  

Will indeed offer negative stocks: 

 

 

However, when executed for the complete posting period with selection date from the 01.05.2008 to the 31.05.2008, the negative stocks are no longer listed: 

 

 

So you will need to consider if it makes sense to post a material movement with a posting date lower than acquisition date.

If you do the goods issue posting corresponding to the real goods issue date in your stock, this incidence will be avoided.

<think>好的,我现在需要帮助用户了解SAPMB5T事务代码的取数逻辑。首先,我得回忆一下自己之前学过的SAP相关知识,尤其是物料管理模块的相关事务代码。 用户提到了MB5T,我之前知道MB5系列的事务代码大多与物料库存相关,比如MB51是物料凭证列表,MB5B是库存余额分析,而MB5T可能也是类似的库存表事务码。不过具体到MB5T的功能,我需要先确认一下。根据引用中的内容,引用[4]提到了MB51的数据来源是T156T表,而MSEG表存储了移动类型等信息。这可能对分析MB5T有帮助,因为MB5T可能也涉及到类似的表和逻辑。 首先,MB5T的主要用途可能是什么?根据事务代码命名规则,MB通常代表物料管理,而5T可能代表某种特定的库存表,比如库存周转率或者库存天数?或者可能和库存价值相关?我需要进一步查找资料或根据已有知识推断。 接下来,用户问的是MB5T的取数逻辑,包括数据来源和处理方式。根据SAP的一般逻辑,这类表通常从物料凭证表(如MSEG)、库存相关表(如MKPF,物料凭证抬头)、以及主数据表(如MARA,物料主数据)中获取数据。此外,可能还需要关联到库存管理相关的配置表,比如移动类型相关的T156T或T156HT,如引用[4]中提到的MB51使用T156T来获取移动类型文本。 接下来,我需要确定MB5T具体处理哪些数据。例如,MB5T可能用于显示物料的库存周转情况,包括库存周转天数、库存数量变化等。如果是这样,那么数据来源可能包括物料凭证(MSEG)中的移动数据,结合期间内的库存变动来计算周转率。处理方式可能包括按期间汇总出入库数量,计算平均库存,然后应用公式得出周转率或周转天数。 另外,可能还需要考虑库存地点、工厂、物料类型等筛选条件,这些信息可能来自物料主数据(MARA)或库存地点主数据(T001L)。同时,会计期间的信息可能来自财务相关的表,如MARD(库存数量)或MBEW(库存价值)? 还需要注意,MB5T可能涉及到库存价值的计算,这时候可能需要关联到会计凭证表(如BKPF、BSEG)或者库存价值表(如MBEW)。但如果是数量层面的分析,可能主要依赖MSEG和MARD。 处理方式可能包括:根据用户输入的参数(如工厂、物料、期间等)筛选相关物料凭证,计算期初库存、期间入库、期间出库、期末库存,然后根据这些数据计算周转率。例如,库存周转率=期间出库总量/平均库存量,或者周转天数=期间天数/周转率。 此外,用户可能需要了解MB5T如何获取移动类型对应的文本,类似MB51使用T156T,MB5T可能也关联到T156T表来获取移动类型描述,但需要确认。 在引用中,引用[2]提到云迁移中的数据抽取限制,比如不能使用LSMW和批量导入,但用户的问题是关于MB5T的本地系统使用,所以可能不需要考虑云端的限制。引用[3]提到SAP表开发中的cl_demo_output类,这可能与前端展示有关,但MB5T作为标准事务码,其逻辑可能内置于SAP程序中,用户可能需要通过标准文档或后台表结构来理解。 总结,我需要组织回答的结构,首先说明MB5T的功能,然后数据来源的表(如MSEG, MKPF, T156T等),接着处理方式,比如如何计算库存周转,最后可能涉及到的配置或主数据。同时,根据用户提供的引用,引用[4]提到MB51使用T156T,可以推测MB5T可能也使用类似的表来获取移动类型文本,但需要结合库存相关的字段,如移动标识(KZBEW)等。 可能还需要检查是否有其他关键表,例如MARD存储库存数量,但MB5T可能直接读取物料凭证中的数量变化,而不是当前库存或者MB5T可能结合期间内的移动数据和期初期末库存来计算周转。 此外,需要注意MB5T可能与其他事务码的区别,比如MB5B用于库存余额,而MB5T可能更侧重于周转分析。处理逻辑可能包括汇总不同移动类型的出入库数量,按期间分组,应用计算公式。 最后,生成相关问题时应围绕MB5T的扩展,比如如何配置、如何优化性能、与其他事务码的对比等。</think>### SAP MB5T事务代码取数逻辑解析 #### 1. **功能概述** MB5T是SAP中用于分析**库存周转率**的标准事务码,核心功能是通过统计物料的出入库数量,计算库存周转周期或周转率,帮助企业评估库存管理效率[^4]。 #### 2. **数据来源** MB5T的取数逻辑主要依赖以下表和字段: - **MSEG表**(物料凭证行项目):存储所有物料移动记录(如采购入库、生产消耗等),关键字段包括`MATNR`(物料编号)、`BWART`(移动类型)、`MENGE`(数量)、`SHKZG`(借贷标识)等[^4]。 - **MKPF表**(物料凭证抬头):关联MSEG表,提供凭证日期、过账时间等上下文信息。 - **T156T表**(移动类型文本):用于获取移动类型的描述文本(如“采购入库”或“生产发料”),通过`BWART`字段关联。 - **MARA表**(物料主数据):提供物料基本属性(如单位、物料类型)。 #### 3. **处理逻辑** MB5T的核心处理步骤如下: 1. **筛选数据**:根据用户输入的参数(如工厂、物料、会计期间),从MSEG中提取符合条件的移动记录。 2. **分类统计**: - 按移动类型(BWART)区分**入库**(如101采购入库)和**出库**(如261生产发料)。 - 通过`SHKZG`字段(H=贷方,S=借方)判断数量增减方向。 3. **计算周转率**: - **期初库存**:基于期间开始时的库存余额(可能从MARD表中读取)。 - **期间出入库总量**:汇总MSEG中所有相关移动类型的数量。 - **周转率公式**:$$ \text{周转率} = \frac{\text{期间出库总量}}{\text{平均库存量}} $$ - **周转天数**:$$ \text{周转天数} = \frac{\text{期间天数}}{\text{周转率}} $$ #### 4. **关键配置** - **移动类型关联**:需确保T156T中维护了移动类型的文本描述,否则MB5T可能显示空值或技术编码。 - **会计期间验证**:系统会根据后台配置的会计年度变式(如K4)校验日期范围的有效性。 #### 5. **与其他事务码的差异** - **MB5B**:分析库存余额,侧重于当前库存状态。 - **MB51**:展示物料凭证明细,不涉及周转计算。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值