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: 

BADI/EXIT: Only after Sales Order details been saved in the database

yarnagula_sudhir
Active Participant
0 Kudos

Hi Experts,

My requirement is to trigger a piece of my code only after Sales Order details been Saved (COMMIT) in the Database.

I'm looking for BADI/EXIT or SPOT etc...

Kindly let me know the exact place.

Observations:

1. In TCode VA01, sales order creation happens.

2. Respective Sales Order details been committed into the Database.

3. Now my code should trigger.

With Regards,

Sudhir.


1 ACCEPTED SOLUTION

sriram_korlepara
Participant
0 Kudos

Hi,

In the highlighted subroutine you can put your logic using some implicit/explicit which will trigger after updating the database of that particulat order.

Let me know if you need any assistance.

Thanks,

Pawan.

13 REPLIES 13

Tomas_Buryanek
Active Contributor
0 Kudos

In exit MV45AFZZ and form USEREXIT_SAVE_DOCUMENT you can call your code "IN UPDATE TASK", so it will be triggered right after COMMIT.


       FORM USEREXIT_SAVE_DOCUMENT      


*       This userexit can be used to save data in additional tables

*       when a document is saved.

*                                                                    

*       If field T180-TRTYP contents 'H', the document will be       

*       created, else it will be changed.                            

*                                                                    

*       This form is called at from form BELEG_SICHERN, before COMMIT

-- Tomas --

0 Kudos

Hi Tomas,

Using  USEREXIT_SAVE_DOCUMENT, i'm getting the Sales Oder details, but the respective SO is not the committed one.

I need a place where exactly the SO is committed into the DB. So that i can write my own code only after SO is committed into the Database.

Kindly let me know the solution.

With Regards,

Sudhir.

0 Kudos

Have you tried call your code "IN UPDATE TASK" ?

-- Tomas --

0 Kudos


Hi Tomas,

Thank you so much for your reply.

Your point is very valid. I didn't call my code using "IN UPDATE TASK".

As I have to call a REPORT in USEREXIT_SAVE_DOCUMENT, i've used SUBMIT <Report Name>.

Where inside that Report there is an RFC which will ping to PI System.

Now in this scenario, how to apply "IN UPDATE TASK"?

Kindly let me know the solution.

With Regards,

Sudhir.

0 Kudos

You can wrap this SUBMIT inside new FM 🙂

Edit: submit in update task will not work

-- Tomas --

0 Kudos

Hi Thomas,

I'm calling a FM with IN UPADTE TASK and inside that FM, SUBMIT <Report Name>.

Using the above scenario, will i get committed SO?

If not kindly let me know the solution.

With Regards,

Sudhir.

Check VBAK-VBELN and XVBAP in MV45AFZZ.

But sadly you can not do SUBMIT in CALL FUNCTION - IN UPDATE TASK. Info from ABAP Keyword Documentation:


During the processing of an update function module in the update work process, the statements SUBMIT, CALL DIALOG, CALL SCREEN, CALL TRANSACTION, COMMIT WORK, and ROLLBACK WORK, as well as all other statements that create a database commit, must not be executed.

-- Tomas --

0 Kudos

What has said is correct,

One twick you may try. Inside your CALL FUNCTION.... IN UPDATE TASK.

Try to CALL another FM in BACKGROUND TASK, inside that you can SUBMIT your program.

Or else.. What has said can be a good alternative.

You can go for a standard task where you use BUS2032.CREATED/ BUS2032.CHANGED as triggering event and write your code in the Method. you get lots of help over the internet about how to use macros inside a workflow method

R

Former Member
0 Kudos

hI,

why dont you go for USEREXIT_SAVE_DOCUMET_PREPARE

This form is used to check any changes when sale order has saved.

0 Kudos


Hi Balaji,

I need a place where exactly the SO is committed into the DB. So that i can write my own code only after SO is committed into the Database.

Kindly let me know the solution.

Note:

Both USEREXIT_SAVE_DOCUMENT and USEREXIT_SAVE_DOCUMET_PREPARE will get the Sales Order details, but that respective SO is not committed into the DB.

With Regards,

Sudhir.

0 Kudos

Hi Yarnagula,

If you want to execute your process just after saved or create SO, then i would suggest, go with Business Object BUS2032 (t-code SWO1). Activate CREATE Event and do some activation in SWE2 t-code to trigger the same after completion of VA01.

It's workflow process, but the same you can use in you requirement.

Regards,

Praveer.

sriram_korlepara
Participant
0 Kudos

Hi,

In the highlighted subroutine you can put your logic using some implicit/explicit which will trigger after updating the database of that particulat order.

Let me know if you need any assistance.

Thanks,

Pawan.

0 Kudos

Hi Sriram,

You are right. Thank you so much.

At Perform beleg_initialisieren I'm getting the Committed SO.

Now I made an Implict enhancement inside the perform.

Now calling my report over to that place is working fine.

Issue resolved.

With Regards,

Sudhir.