Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI to capture start of Order Creation

former_member200967
Active Participant
0 Kudos

Hallo Community,

I have a requirement where I need to capture the start of a new Sales order creation. Which BAPI can I use to capture the fact that sales order creation has started. Also ; i want to save the information in a variable whose value will be available to me in the Sales order Save BAPI, where should i declare this variable so that it is available to every BAPI, enhancement spot in sales order creation.

Regards

Manpreet

8 REPLIES 8

Former Member
0 Kudos

Hi

What does "starting" main for you?

When is the process beginning?When the saving is starting?

Anyway I suppose you mean USER-EXIT and not BAPI

Max

0 Kudos

Hi Max,

Yes i mean user exit and by starting means, when the user gives the sales order type and presses enter and move to the sales order screen where he inputs customer number and other details. THen Finally when he hits save , i want to save the information in a Z table.

Just answering you i realised another problem , that i will not have a sales document number till SAP actually saves the information. 🙂

Regards

Manpreet

Former Member

Ok

You can use the user-exit USEREXIT_SAVE_DOCUMENT (include MV45AFZZ) in order to save some data in your custom table, here u can check the field T180-TRTYP:

- T180-TRTYP = 'H' sales order will be created

- T180-TRTYP = 'V' sales order will be changed

I don't believe you need to place a code in an user-exit at the beginning, I mean here you should have all information you need

In this exit you'ba the sales order number

Max

0 Kudos

Thanks for the comments Max.

Actually i want to capture the start of the Order Creation time and then save it in a table, that is the reason that i want to use the start of the order creation.

Also what would be the best place to declare a Global variable that will not get overwritten during SAP upgrade?

Regards

Manpreet

Former Member
0 Kudos

Hi

There isn't an user-exit at the beginning, so you can try to use the first user-exit called (perhaps USEREXIT_MOVE_FIELD_TO_VBAK but I'm not sure) or create an enhancement spot

The global data have to be defined in the include MV45ATZZ

Max

Jelena
Active Contributor
0 Kudos

There is no user exit, to my knowledge, that is triggered exactly when you are asking. However, in more recent release there were some BADIs added. Our system is a bit old, so I don't know for sure but check in your system, maybe there is something. SD user exits have already been discussed gazillion times on SCN, as well as how to find a BADI. Use Google.

During SAP upgrade (I'm assuming you mean support packs) you get to choose whether to keep the modifications or not. And BADIs implementations are usually unaffected by the upgrade.

Flavio
Active Contributor

Hi Manpreet,

I had a similar requirement in the past, and solved it by using, as anyhow already proposed here above, the userexit USEREXIT_SAVE_DOCUMENT, in the include MV45AFZZ.

The trick to get the order number at sales order creation (VA01) is to check, within the userexit, the internal table VBAK: the field VBAK-VBELN contains already the order number, before document saving. The sales order item can be obtained from itab XVBAP-POSNR (XVBAP-VBELN is however still blank at this stage).

I do hope this could help.

Thanks and regards,

Flavio

0 Kudos

Hi,

I have implemented the code in USEREXIT_SAVE_DOCUMENT as an Enhancement, but the code does not execute. Even in debugger i cannot see the enhancement code . Below is the screenshot of the code.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form USEREXIT_SAVE_DOCUMENT, End A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZMV45AFZZ. "active version
*if T180-TRTYP eq 'H'.
BREAK-POINT.
ZTABLE-MANDT = SY-MANDT.

ZTABLE-ORDERNUMBER = vbak-VBELN.

ZTABLE-STARTDATE = gv_STARTDATE.
INSERT ZTABLE.

*ENDIF.
ENDENHANCEMENT.
*$*$-End: (1)---------------------------------------------------------------------------------$*$*