2016 Nov 15 8:26 AM
Hello,
I need to schedule a job for custom Function module for which I have created a report in which I have called the same custom Function module.
When I am executing the report in background , Job is getting scheduled but the Function module is not getting executed.
When I re-run the same job using JDBG then the FM is getting executed and also when I run the report in foreground FM is getting executed.
I am facing issue only when I execute the report in background.
Kindly provide suggestions on how to proceed
Thank you!
BestRegards,
Aamukta Malyada A
2016 Nov 15 8:29 AM
There's really insufficient information here for a meaningful answer. How about posting the relevant code?
How do you know the FM isn't being executed in background?
2016 Nov 15 8:45 AM
Hi Matthew,
In the custom FM ,I have written a piece of code for RFC creation.
When I execute the report in background that RFC was not created where as when I execute the report in foreground RFC was created
2016 Nov 15 8:55 AM
...and How about posting the relevant code?
Have you checked for dumps, or in SM21? Have you looked at the job logs of the background report?
2016 Nov 15 8:55 AM
Have you implemented logging into your program? If not, do it, and log all relevant events, especially non-zero return codes.
2016 Nov 15 12:41 PM
Sorry I did not get the concept of logging into the program
Can you please explain
2016 Nov 15 9:43 PM
SLG1 t-code is the application log. There are various function modules and classes which you can write custom logs to this. I havent read this blog but looks like it will give you the basics;
https://blogs.sap.com/2012/04/18/create-and-view-log-using-slg0-and-slg1-transaction/
2016 Nov 16 7:17 AM
Thank you, I will try this as well to check the logs
I was adding messages and exceptions in function module as well
2016 Nov 15 9:49 AM
Hi,
Did you write the custom function module? Either the FM tries to do something in the foreground for which it needs user interaction, or there is a piece of code checking sy-batch, or when you execute it in the background it uses a different user and that one is missing authorizations or missing user parameters.
Kind regards, Rob Dielemans
2016 Nov 15 12:41 PM
Yes, I have created the custom FM, I have passed all the required parameters
2016 Nov 15 1:22 PM
Hi,
I'm not interested in parameters I'm interested in which ABAP code that you have written behaves differently depending on foreground or background. For instance: do you use a popup function module?
Kind regards, Rob Dielemans
2016 Nov 15 3:13 PM
Hello,
Inside the Function module I am creating a RFC for different system (say ABC) and updating a custom Table in that system(ABC) and No pop up FM's are used or any code that requires information from fore ground.
2016 Nov 15 9:54 AM
Hi,
It should be dumping then... some FM, indeed, are not meant to be executed in background. But, then you would receive a dump... Otherwise, I wonder how you claim that it was not executed. Log the action through ST05 and see what happens...
Regards,
Eli
2016 Nov 15 12:42 PM
2016 Nov 15 12:54 PM
2016 Nov 15 10:48 AM
Hi,
Can you also provide info on the scenario which necessitated creation of RFCs in the background through a Custom FM rather than using SM59.
Are you are creating RFC using a BDC on SM59 ?
K.Kiran.
2016 Nov 15 12:39 PM
Hi Matthew,
Here is the code I used
REPORT ztest.
DATA:
lv_tasklist TYPE stc_scenario_id,
* ls_sid TYPE syst_sysid,
it_return TYPE bapirettab.
lv_tasklist = 'Ztasklist_test'
CALL FUNCTION 'Ztest'
EXPORTING
tasklist_name = lv_tasklist
system_id = sy-sysid
TABLES
it_return = it_return
EXCEPTIONS
errors_occurred = 1
no_data = 2
rfc_failed = 3
failed_updation = 4
OTHERS = 5.
COMMIT WORK.
IF sy-subrc = 0.
WRITE: 'Entries updated'.
* Implement suitable error handling here
ENDIF.
2016 Nov 15 12:40 PM
I have created RFC Using Standard FM for RFC creation. and I created RFC in the FM as I need too update table in a different system
In order to connect to that system I have created a RFC in the FM
2016 Nov 15 3:49 PM
Hi,
The exceptions of your FM is immediately followed by a commit work, which means that sy-subrc will either be 0 or 4.
Kind regards, Rob Dielemans
2016 Nov 15 3:55 PM
2016 Nov 15 5:23 PM
Yes,
But the Issue I am facing is the Function module is not getting Executed in Background
2016 Nov 15 5:39 PM
And still there is no answer on how exactly you established that FM does not work and no code posted of what the FM does...
What have you tried so far to troubleshoot this? Quick Google search for "does not work in background site:sap.com" should've found all the answers regarding what the differences are. And if you can't debug in background then how about adding some messages to display in the job log? ("Logging" is a common programming concept.)
How did you get a job at SAP? If you are an intern/trainee then there should be a trainer assigned to you. SCN is not a replacement for this, sorry.
2016 Nov 15 9:41 PM
Your report does not explicitly change whether your Function Module is called if the report is run as a background/scheduled job.
Providing your job is finishing and in succeed status i would suggest it IS getting executed but something within the Ztest function module is not working properly, or you are handling an exception which equates to a 'successful' run. So you would need to paste the code for the ztest function module for these kind sirs/madams to assist you further.
Hint: Transaction SE37 to get your Function module code.
Hint 2: If you are in a development environment, put an infinite loop in your report code prior to the function call. Schedule the job and when it is running, go to SM50 and find the dialog process for the program - the user the job is scheduled under will be the indicator in this case. Highlight the line and go to administration -> Program -> Debugging. Step through and you will see.
Hint 3: Take an ABAP course.
ALSO: Have you considered that the foreground and background execution users are different.
2016 Nov 16 7:22 AM
I think we're all well aware what your problem is. You do not need to keep restating it.
If you don't check the sy-subrc at the correct point, then you're not going to trap any issues.
Since you refuse to supply relevant details, I'm going to close this question.