Skip to Content
-6

Function module is not getting executed when report is run in Background

Nov 15, 2016 at 08:26 AM

194

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded

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?

1
Former Member
Matthew Billingham

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

0

...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?

1
Former Member
Matthew Billingham

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.

0

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

0

Correction sy-subrc is always 0

0
Former Member
Rob Dielemans

Yes,

But the Issue I am facing is the Function module is not getting Executed in Background

0
Show more comments

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.

0
Former Member
Kiran K

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

0

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.

4
Further commenting has been locked.
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Matthew Billingham
Nov 15, 2016 at 08:55 AM
1

Have you implemented logging into your program? If not, do it, and log all relevant events, especially non-zero return codes.

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Sorry I did not get the concept of logging into the program

Can you please explain

0
Former Member
Former Member

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/

0
Former Member
Former Member

Thank you, I will try this as well to check the logs

I was adding messages and exceptions in function module as well

0
Further commenting has been locked.
Eli Klovski
Nov 15, 2016 at 09:54 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I am not getting any dump and I will try checking ST05 now

0

Umm, you check for dumps in ST22

1
Further commenting has been locked.
avatar image
Former Member Nov 15, 2016 at 09:41 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Rob Dielemans Nov 15, 2016 at 09:49 AM
0

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Yes, I have created the custom FM, I have passed all the required parameters

0

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

0
Former Member
Rob Dielemans

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.

0
Further commenting has been locked.