Edwin的专栏

ERP/SAP

销售凭证的用户状态 - User statuses in sales document

由于业务原因,最近在销售合同表头上启用了用户状态,但某时间以前创建的不希望启用此用户状态。

查找个SD Document方面的各种user-exit,都没有合适的方法。后来在SCN找到一篇文章,描述了用户状态不在SD程序中,因此无法直接通过SD user-exit处理。文章中提示,TVAK表的某字段保存了此状态参数文件名。经尝试,只要在保存前清除User-exit中全局变量的两处内容,即可实现该销售合同的用户状态不保存:

1. vbak-objnr  状态对象号

2. tvak-stsma  状态参数文件名

User-exit: MV45AFZZ-USEREXIT_SAVE_DOCUMENT_PREPARE.

经测试,达到预期效果。


以下为参考文章:


PROCESS

Sales transactions are the most omnipresent transactions happening everywhere at any point of time earning revenue for the organisation. To streamline and prevent the undesirable chain of intractable transactions they need to be aligned in proper sequence with judicial controls. One such tool which helps to achieve this objective is the statuses used in the sales transaction at header or item levels.

Order header and item statuses I refer here differ from the normal completion status we are used to. These statuses are classified into system status and user status. While the system status automatically controls the sequence of transactions and comes packaged in SAP, the user statuses are customizable to the business requirement. These statuses are sequenced and tagged to either the execution or prevention of various transactions. This bunch of controls is encapsulated inside a status profile. Finally the status profile is linked either to the document type or item category.

Though it is efficient and effective to manage the process through status profiles, it is not possible to extract reports based on the status of the sales orders or their items. This is due to lack of knowledge on the database tables behind the process and also limited usage of this functionality in a stand alone sales scenario.

This document tries to break this myth and helps to create a simple quick view query to know the status of sales orders or to find the orders of a specific status.

TECHNICAL INFORMATION

The repository of information related to statuses is controlled mainly by the field object numberwhich is updated in every transaction in each possible level. For example this field called object number is available in VBAK for the sales order header and VBAP for the items of the sales order. The field OBJNR in VBAK and VBAP is the key field used to further mine the details of the user and system status.

If the sales order header or item or both are enabled with a status profile, then the VBAK-OBJNRand VBAP-OBJNR will be updated with an automatically generated object number. The value of this field will be used in all further searches to get the desired status of the orders.

The next important table is the table JEST. This table also contains the field OBJNR and thus links either VBAK or VBAP with JEST. For the given object number, the table JEST will give the presentuser status and system status.  The status codes are presented in the field JEST- STAT. The user statuses always start with E and the system status starts with I. The status codes used in this table will need to be used to further extract the correct status as the user sees. The status codes shown in JEST are only the technical names of the statuses created.

There is also another table called JCDS which also contains the field OBJNR and this table will give the list of status changes the document had gone through. It should be remembered that it is easy to approach this table instead of CDHDR or CDPOS for any status related change documents.

The table JEST has the system and the user status of the document in technical terms. To know the correct description for them, two different tables should be used.

If the user status and its description need to be found out, the table TJ30T should be made use of. This table has got the status profile and the status codes. The status profile is indicated in the field TJ30T- STSMA and the status code is represented by the field TJ30T- ESTAT. As the combination of status profile and the status code are unique keys, both the values need to be provided to get the actual status.  As we already know, the status profile is either configured in the sales document type in table TVAK or at the item category level in the table TVAP.  By giving the status profile in the field TJ30T-STSMA and the status in TJ30T-ESTAT the field TJ30T- TXT04 represents the correct user status and TJ30T- TXT30 indicates the description of the status.

If the system status has to be found out, the status codes from JEST-STAT starting with I should be provided as an input in the table TJ02T- ISTAT along with the language key as EN for example in the field SPRAS. The resultant TJ02T- TXT04 and TJ02T- TXT30 gives the status and its description respectively.

Just to add, the entire logic is not just applicable for only sales order header or sales order items, it is applicable for all transactions in SAP which uses the User status through status profiles. To make matters simple, you can use the function module STATUS_TEXT_EDIT to get the system and user status.

The import parameters are as follows.

FLG_USER_STAT—————-Put X is you want the user status also. If system status alone is sufficient, leave this empty

OBJNR——————————–This is the object number. We discussed about this in detail already.

ONLY_ACTIVE——————— Just put X to get only the active statuses

SPRAS——————————–Put the language code, for example EN for English

BYPASS_BUFFER—————Leave it empty.

In the result, the export parameters LINE and USER_LINE indicate the system and user status respectively. Here the parameter E_STSMA indicates the status profile for the user status.

If there is scope for improvement on this content, it will be done when God gifts me with some more information.


阅读更多
个人分类: SAP
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭