Skip to Content
0

BAPI to capture start of Order Creation

Oct 21, 2016 at 01:01 PM

162

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

flavio ciotola Oct 22, 2016 at 04:59 AM
1

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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)---------------------------------------------------------------------------------$*$*

0
max bianchi Oct 21, 2016 at 01:40 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
max bianchi Oct 21, 2016 at 01:15 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

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

0
max bianchi Oct 21, 2016 at 05:04 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded
Jelena Perfiljeva
Oct 21, 2016 at 08:46 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded