You are on page 1of 5

5/10/2014

How to wait until Update Task V2 finish? | SCN


Getting Started New sletters

Welcome, Guest

Login

Store

Search the Community

Register

Products

Services & Support

About SCN

Downloads

Industries

Training & Education

Partnership

Developer Center

Lines of Business

University Alliances

Events & Webinars

Innovation

Activity

Communications

Actions

Brow se

17 Replies Latest reply: Nov 5, 2013 8:50 AM by Rdiger Plantiko

Share

Tw eet

Like

Jonathan Hurtado

Nov 4, 2013 8:35 PM

How to wait until Update Task V2 finish?


This question is Assumed Answered.
Hi,
My abap program executes two processes, but the first process triggers one Update Task V2:
1) processA -> 2)Update task V2 (SIS Tab le update)
3) processB
I need the processB to be excecuted only when the Update Task V2 has been finished.
I had implemented the SET UPDATE TASK LOCAL before processA but doesn't work.
Someone knows how to do that?
Thank you for your help.

Helpful Answer by Rdiger Plantiko

453 View s

Topics: abap

Average User Rating


(1 rating)

Neal Wilhite Nov 4, 2013 8:58 PM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
If you are using an update task, there should be locks on the object. assuming that there are, If you
watch for the release of the lock, you will know that the process is complete.
Neal

Like (0)

Rdiger Plantiko Nov 4, 2013 9:25 PM (in response to Neal Wilhite)


Re: How to wait until Update Task V2 finish?
This is true for V1, but not for V2.

Like (0)

Rdiger Plantiko Nov 4, 2013 9:29 PM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
Jonathan,
in cases like these, instead of having a "global super-control program" wasting its time in stupid Do
loops, watching the process from outside until it's finished, an event-driven approach is usually
better.
In your case:

http://scn.sap.com/thread/3448792

1/5

5/10/2014

How to wait until Update Task V2 finish? | SCN


Write your own V2 function module, and call it in update task after the SIS calls of the standard have
been executed!
Now the update system calls your function module in the right time. In that module, you can do
whatever you have to do.
Regards,
Rdiger

Like (1)

Jonathan Hurtado Nov 4, 2013 9:37 PM (in response to Rdiger Plantiko)


Re: How to wait until Update Task V2 finish?
Yes this would be great... but I can't implement my own V2 FM, because the processA that I am
talking is about SAP Standard functionality (Product Allocation).
Regards

Like (0)

Neal Wilhite Nov 4, 2013 9:41 PM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
99% of SAP standard FM's have a end implicit enhancement. How about implementing
Rdiger's suggestion there.
Neal

Like (1)

Jonathan Hurtado Nov 4, 2013 9:58 PM (in response to Neal Wilhite)


Re: How to wait until Update Task V2 finish?
I am only allowed to change my own abap program.
This is a BIG restriction from my customer.

Like (0)

nabheet madan Nov 5, 2013 2:48 AM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
The first processis happening via calling some FM and then commit etc..? Please
share your sample code..

Like (0)

Jonathan Hurtado Nov 5, 2013 3:11 AM (in response to nabheet madan)


Re: How to wait until Update Task V2 finish?
The first process calls this BAPI
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
When this Bapi is excecuted, the V2 update is triggered, in order to update
one SIS table
The second process call this another BAPI
BAPI_SALESORDER_CREATEFROMDAT2

Like (0)

http://scn.sap.com/thread/3448792

2/5

5/10/2014

How to wait until Update Task V2 finish? | SCN


nabheet madan Nov 5, 2013 6:56 AM (in response to Jonathan Hurtado)
Re: How to wait until Update Task V2 finish?
Please use BAPI_TRASNACTION_COMMIT with WAIT option after after
the call of first BAPI

Like (0)

Rdiger Plantiko Nov 5, 2013 7:52 AM (in response to nabheet madan)


Re: How to wait until Update Task V2 finish?
COMMIT WORK AND WAIT (or BAPI_TRANSACTION_COMMIT with
WAIT) doesn't wait for V2 to be finished - only for V1.
http://help.sap.com/saphelp_nw04/helpdata/EN/41/7af4dda79e11d1950f0000e82de14a/frameset.htm

Like (1)

nabheet madan Nov 5, 2013 7:56 AM (in response to Rdiger Plantiko)


Re: How to wait until Update Task V2 finish?
Hi Rudiger
Thanks you are right i overlooked it..
Nabheet

Like (0)

Rdiger Plantiko Nov 5, 2013 8:08 AM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
Option 1) If you are allowed to use customer exits or enhancements:
Replace the enhancement section
ENHANCEMENT-SECTION

STATISTIK_UPDATE_10 SPOTS

ES_SAPMV45A.
in form MV45AFST_STATISTIK_UPDATE by an own code fragment,
containing first the call of MCV_STATISTICS_ORDER like the standard,
and then, after this, the call of a V2 module
Z_SALESORDER_SIS_CHANGED. In this own V2 function module, you
will have to call your BAPI_SALESORDER_CREATEFROMDAT2 IN
BACKGROUND TASK, since this will perform a separate commit and
thus cannot be called in the same LUW.
Option 2) If the customer by no means allows any modification or
enhancement: I would suggest to register an own function module to the
event CHANGED of busines object BUS2032 (sales order) and write a
worklist of sales order numbers into a Z table. In a periodic job, then, you
read this Z table of sales order numbers and check whether the SIS
update already has been performed for this order (inspect the Snnn
tables to detect the change). If yes -> start your action, and remove the
sales order number from the Z table.
Regards,
Rdiger

Like (2)

nabheet madan Nov 5, 2013 8:15 AM (in response to Rdiger Plantiko)


Re: How to wait until Update Task V2 finish?
Hi Rudiger
Can we check VB* table also and wait for them to be finished what
do you think?
Nabheet

http://scn.sap.com/thread/3448792

3/5

5/10/2014

How to wait until Update Task V2 finish? | SCN


Like (0)

Rdiger Plantiko Nov 5, 2013 8:59 AM (in response to nabheet madan)


Helpful Answer Re: How to wait until Update Task V2 finish?
Hi Nabheet,
if you look for VBMOD entries with VBFUNC = MC... and hence
waiting to be processed - you still have to ensure that you get all
changed sales orders. So you still need an approach like the
above option 2, to know all the processed sales order numbers.
Inside of your own function module that is called from the
BUS2032->CHANGED event, you might provide such a wait
loop until all VBMOD's with VBFUNC LIKE 'MC*' and VBMODE =
2 disappeared.
But I am not sure whether checking the VBMOD this way really
would give a reliable solution.
My personal rule of thumb is: If an approach looks ugly (like the
wait loop concept here, and even checking a completely
technical/system-specific table here), it indicates some
drawbacks which will bite you sooner or later. (Maybe, if it's
rather late, it may not be your concern any more, since you are
already at another project with another customer... :-) ).

Regards,
Rdiger

Like (2)

Raymond Giuseppi Nov 5, 2013 8:13 AM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
Why do you want update task V2 to be finished, usually this is not mandatory ?
To add a V2 call as suggested by
Rdiger, you could use implicit enhancement (like the end of
the form which call the other FM) or any BAdI/Customer exit where you could add a single PERFORM
ON COMMIT which will be triggered by COMMIT WORK and in the performed form use a CALL IN
UPDATE TASK of your own V2 module. Does you customer allow BAdI or Customer Exits if they don't
allows implicit enhancement ?
Else you would have to loop thru VBMOD (call TH_GET_VBKEY before COMMIIT WORK) until every
module is executed, but V2 can take some time to execute at peak times...
Regards,
Raymond

Like (1)

Rdiger Plantiko Nov 5, 2013 8:50 AM (in response to Raymond Giuseppi)


Re: How to wait until Update Task V2 finish?

Why do you want update task V2 to be finished, usually this is not mandatory ?
This is a good question I didn't dare to ask, since it is considered not polite to "question a
question"...
But, yes, statistics contribute to analytical reporting. This should have no relevance to the
business process at all. Imposing such a dependency on a business process is a flaw in itself.

Like (0)

Klaus Babl Nov 5, 2013 8:40 AM (in response to Jonathan Hurtado)


Re: How to wait until Update Task V2 finish?
Hi,
after COMMIT WORK AND WAIT for processA you can call a function module
CALL FUNCTION xyz STARTING NEW TASK ... PERFORMING processA_finished ON END OF TASK.

http://scn.sap.com/thread/3448792

4/5

5/10/2014

How to wait until Update Task V2 finish? | SCN


Function xyz has to watch (in a DO loop) that V2 has finished (you know the expected data and can
read the table) and finish, when the data are available.
Form processA_finished should have only two lines:
receive results from function 'xyz'.
set user-command 'PROB'.
Then you can continue with processB in event AT USER-COMMAND.
This is not tested, that's just an idea.
Regards
Klaus

Like (0)

Share

Site Index
Privacy

Tw eet

Contact Us
Terms of Use

http://scn.sap.com/thread/3448792

Like

SAP Help Portal


Legal Disclosure

Copyright

Follow SCN

5/5

You might also like