2012 Feb 09 5:01 PM
Hi all,
During posting of an inbound IDoc, I am trying to update my Z-table in user-exit. I want to do it regardless of the result of IDoc posting. The problem is: if IDoc posted successfully - table is updated because COMMIT WORK is called at the end of the posting, however, if IDoc not posted - ROLLBACK WORK is called and table is not updated. So, my aim now is to commit the update of Z-table in any case, but it is the only thing that should be committed - no other prior update FMu2019s should be committed.
I'm aware about the following thread
http://forums.sdn.sap.com/thread.jspa?threadID=1884700
Author of this thread says that he solved a problem by means of RFC and STARTING NEW TASK. But ABAP help says
that starting asynchronous RFC triggers immediately a database commit in the calling program (which is unacceptable because all prior update FMu2019s will be committed ). I've checked and it is really the case.
From my point of view SET UPDATE TASK LOCAL with COMMIT WORK should work in such kind of tasks, but in case of IDoc processing the whole process runs in a local update (see SET UPDATE TASK LOCAL in FM 'IDOC_INPUT'), so writing once again SET UPDATE TASK LOCAL has no effect.
I tested SUBMIT statement as well. It had no effect and then I found out from ABAP help that SUBMIT ... AND RETURN starts new SAP LUW, but NOT a DB LUW. That is if I update my Z-table in the program called by SUBMIT - all ROLLBACK statements still affect my Z-table update.
Is there any simple solution? Please suggest.
Thanks in advance!
2012 Feb 09 7:24 PM
Hello,
Try SUBMIT VIA JOB.....
Sample Code
call function 'JOB_OPEN'
exporting
jobname = name
importing
jobcount = number
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if sy-subrc = 0.
submit z_idoc_create_process_order and return
via job name number number
with p_aufnr = it_header1-aufnr
with p_werks = it_header1-werks
with p_autyp = c_autyp
with p_auart = it_header1-auart
with p_dispo = it_header1-dispo
with p_opt = c_opt
with p_mestyp = c_mestyp.
if sy-subrc = 0.
call function 'JOB_CLOSE'
exporting
jobcount = number
jobname = name
strtimmed = 'X'
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if sy-subrc 0.
endif.
2012 Feb 09 10:13 PM
Hi,
I am guessing you are checking something in a customer exit in a IDOC fm and regardless of the posting status you wish to keep the same in your Z-Table. If that is the case then there is a easy solution.
Create a wrapper FM for that IDOC fm, when you are calling the IDOC FM inside the wrapper create the same in a new task.
Once that FM is done it's job, outside the FM and in the wrapper update your Z-Table. Of course you have to export your data first.
But this is not advisable, as if your IDOC fails anything related to the same, should fail too.
Best Regards,
Tapodipta Khan.
2012 Feb 10 8:08 AM
Hi Vinit,
Thanks for the new idea, but unfortunately it does not work.
First, JOB_OPEN will do a commit immediately to save job info to DB tables (see form STORE_NEW_JOB_IN_DB inside), second - seems that there is no difference between SUBMIT and SUBMIT VIA JOB in regard to creating new SAP/DB LUWs. So, the further ROLLBACK in the posting FM will rollback my updates of Z-table, even so I did it in a batch job.
2012 Feb 10 8:29 AM
Hello Khan,
I guess your solution will work. But I would say it is a final possibility. The standard SAP posting FM is in use now, so, I will need to pass a long sequence of approvals to get a chance to change it to custom wrapper Z-module.