2014 May 29 1:55 PM
Hi guys
I have problem with FM runing in background task!!
ıts suppsed to update the table zmm_t_so_001, it works well when run without background task
I have ran FMs like BAPis in background before and it was ok
Here is the code!!
Function Module --- ZZ_TEST_BACKGROUND
function zz_test_background.
break solend.
data(lr_satinalma_header) = new zmm_t_so_001( ).
call method zcl_mm_so=>get_next_number_appid
importing
appid = lr_satinalma_header->appid.
lr_satinalma_header->belnr = value #( ).
lr_satinalma_header->kalnr = value #( ).
*Aktarım durumu Yeni
lr_satinalma_header->bstyp = value #( ).
*Aktarım durumu
lr_satinalma_header->akdur = 'YK'.
lr_satinalma_header->frgst = value #( ).
*Onay Tipi
lr_satinalma_header->ontip = value #( ).
lr_satinalma_header->ontur = value #( ).
lr_satinalma_header->erdat = sy-datum.
lr_satinalma_header->erzet = sy-uzeit.
lr_satinalma_header->ernam = sy-uname.
**Gonderim durumu
lr_satinalma_header->gondr = ' '.
**İnsert here!!
insert zmm_t_so_001 from lr_satinalma_header->*.
commit work.
endfunction.
then this Fm is called from the report here
report z_learnıng.
START-OF-SELECTION.
call FUNCTION 'ZZ_TEST_BACKGROUND'
in BACKGROUND TASK
.
the interesting part is it works ok when its ran without the BACKGROUND TASK
2014 May 29 2:43 PM
Hi Solen,
When FM in called in background task then it first registered for LUW wont execute immediately. After COMMIT WORK statement the registered FM will execute.
In your case, i not seeing commit work statement in calling program Z_learning to execute the FM.
https://help.sap.com/saphelp_nwpi71/helpdata/en/8f/53b67ad30be445b0ccc968d69bc6ff/content.htm
Thanks & Regards
Arun
2014 May 29 2:46 PM
Hi Solen,
Try and add COMMIT WORK after the CALL FUNCTION.
This will update the database and also your problem will be solved.
Regards,
Ganesh Lathi.
2014 May 29 2:46 PM
Hi aruna
Thanks for the comment
I tried that and it still didnt update
please try yourself to update a z table like this
thats the reason i put it on SDN
Smth is causing it but no idea
2014 May 29 3:06 PM
Hi Solen,
Just want know any run time errors in ST22 ? Can you comment commit work inside the FM and try ?
Thanks & Regards,
Arun
2014 May 29 3:07 PM
Hi ganesh
i also added commit after the FM but that also dint fix the issue
i was checking the remote comparison by chance i saw that there is s problem with RFC
So i come to think it might be the RFC that has problem maybe.
then just now i tried and it worked without code change
it didnt make sense to me but i guess it was RFC issue!!
thanks guys for suggections!!
2014 May 29 3:12 PM
Hi Solen,
As you mentioned that you are using RFC. Try
CALL FUNCTION '-----------' IN BACKGROUND TASK DESTINATION 'RFC_DEST'.
COMMIT WORK.
here keep RFC destination as your calling system itself.
May be this will solve your issue.
Regarsd,
Ganesh Lathi.
2014 May 29 3:21 PM
Interesting thing here,
1. The commit will happen automatically if the executable program completes sucessfully without runtime error.
2. if you call the FM in background its not necessary that it executes right then, it will be scheduled for execution, In my system the background job will be scheduled with the delay of 30 mins atleast in DEV. Not sure how it decides the time. Please check if the job is scheduled or not.
if yes you can change the start time
2014 May 29 3:31 PM
Hi Syed,
For 2 point i got a point from help,
"If the specified destination is not available when COMMIT WORK is executed, an executable program called RSARFCSE is started in background processing. By default, this tries to start the function modules registered for a SAP LUW in their destination every 15 minutes and up to 30 times. You can make changes to these parameters using transaction SM59. If the destination does not become available within the defined time, it is recorded in the database table ARFCSDATA as the entry "CPICERR". By default, this entry in database table ARFCSSTATE is deleted after eight days."
So adding destination with the background may help in getting that Job start automatically.
2014 May 29 3:38 PM
yah good one, i didn't know that.
but i told that the job it itself will be scheduled to start after 30 mins the start time will be +30 mins from the execution of the parent program, how that happens?