‎2011 Sep 20 10:38 AM
Halo Experts,
I am working on an Perfomance Optimization project . I am trying to optimize the program by scehduling the individual methods inside the program via asynchronous function modules . By this way I can run this independent methods parallely ( and not sequentailly) . for eg
if the program has
me->m1( ).
me->m2( ).
me->m3( )
if m2 and m3 are independent of each other I schedule them parallely by
me->run_m2_m3_parallely( ) see the below code
CALL FUNCTION 'ZM2'
STARTING NEW TASK 'FUNC1'
DESTINATION 'NONE'
CALLING ZCLASS=>set_flag_4_m2 ON END OF TASK.
CALL FUNCTION 'ZM3'
STARTING NEW TASK 'FUNC2'
DESTINATION 'NONE'
CALLING ZCLASS=>set_flag_4_m3 ON END OF TASK.
WAIT UNTIL l_m2_flag = 'X' AND
l_m3_flag = 'X'.
the FMs ZM2 and ZM3 are updating Z Database tables( say ZM2 and ZM3 ) . Do I need an explicit commit work for Individual FMs or a single commit work for both the FMs.
How can I roll back both the updates to the database if a dump occurs ?
How should the commit work statement be in this case ?
Regards
Arshad
‎2011 Sep 20 10:53 AM
Hello Arshad,
When you're using asynch-RFC(aRFC) they are run in separate RFC contexts which don't share a common LUW. You need to maintain an explicit commit to store the data in the DB tables.
How can I roll back both the updates to the database if a dump occurs?
What exactly is your requirement, can you elaborate?
BR,
Suhas
PS: If you're using a transactioncal RFC(tRFC), they are registed in a common LUW.
‎2011 Sep 20 10:53 AM
Hello Arshad,
When you're using asynch-RFC(aRFC) they are run in separate RFC contexts which don't share a common LUW. You need to maintain an explicit commit to store the data in the DB tables.
How can I roll back both the updates to the database if a dump occurs?
What exactly is your requirement, can you elaborate?
BR,
Suhas
PS: If you're using a transactioncal RFC(tRFC), they are registed in a common LUW.
‎2011 Sep 20 9:27 PM
Halo Suhas,
My aim is to run independent methods parallely so that I can optimise the perfomance of the program
My question regarding roll back was if some exception happens and dumps in Zm3 , will the M2 update be rolled back also?( because we are having individual commits inside Zm2 and Zm3 )
I tried this parallel execution , it is succesfully updating table m2 ( same as the number of entries of sequential run ) and table m3 it is not updating.
But the strange thing is if I put user defined break point in Zm3 and executing the program it is correctly updating m3 table .
Regards
Arshad
‎2011 Sep 21 5:48 AM
Hello Arshad,
My question regarding roll back was if some exception happens and dumps in Zm3 , will the M2 update be rolled back also?( because we are having individual commits inside Zm2 and Zm3 )
No, because you're running the updates in parallel, if you want to achieve this requirement you'll have to bundle the updates in a single LUW.
I tried this parallel execution , it is succesfully updating table m2 ( same as the number of entries of sequential run ) and table m3 it is not updating.
Are you issuing a COMMIT WORK in the asych task 'M3'?
BR,
Suhas
‎2011 Sep 21 9:35 AM
Yes I am using commit work inside task M3 also.
Regards
Arshad
‎2011 Sep 20 11:21 AM
I think you can solve your issue by using the KEEPING TASK addition.
In your ZCLASS=>set_flag_4_m2 method try this:
METHOD set_flag_4_m2.
RECEIVE RESULTS FROM FUNCTION 'ZM2 ' KEEPING TASK.
ENDMETHOD.
METHOD set_flag_4_m3.
RECEIVE RESULTS FROM FUNCTION 'ZM3 ' KEEPING TASK.
ENDMETHOD.
And after your wait you can try to do this:
WAIT UNTIL l_m2_flag = 'X' AND
l_m3_flag = 'X'.
* In set_func2_commited you must receive results from BAPI_tRANSACTION_COMMIT and set global flag g_func2_commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
STARTING NEW TASK 'FUNC2'
DESTINATION 'NONE'
CALLING ZCLASS=>set_func2_commited ON END OF TASK.
* In set_func3_commited you must receive results from BAPI_tRANSACTION_COMMIT and set global flag g_func3_commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
STARTING NEW TASK 'FUNC3'
DESTINATION 'NONE'
CALLING ZCLASS=>set_func3_commited ON END OF TASK.
WAIT UNTIL g_func3_commit EQ 'X' and g_func2_commit EQ 'X'.
‎2011 Sep 23 2:53 PM
Halo Arseni,
Thanks for your reply . I tried the same but still the table M3 is not updated . While going in debugging its still updated . Dont know what really is the issue here ?
Regards
Arshad
‎2011 Sep 21 10:07 AM
Hi,
As said by Suhas, bundle into one LUW. then it will work..
Instead of upadating tables directly in FM Z2 , and Z3 , recieve the results back to main internal session and use UPDATE Function module to update the tables..
RECEIVE RESULTS FROM FUNCTION z2
parameter_list
RECEIVE RESULTS FROM FUNCTION z3
parameter_list
Regards,
Ravi.
‎2011 Sep 23 2:55 PM
Halo rshankar,
I cant change the existing logic of the program . So the table updates takes place in method m2 and m3 . and I need to put the same inside Async FM ZM2 and ZM3
Regards
Arshad