Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Calling custom function module in background task

Former Member
0 Likes
6,602


Hi All,

I need to call a custom function module in my program and run it as a background task. I used

      CALL FUNCTION 'Z_SD_SERV_ORDER_CREATE' IN BACKGROUND TASK

        TABLES

          T_FLTHDR       = LT_FLTHDR

               .

IF SY-BATCH EQ 0.

ENDIF.

But the SY - BATCH returns me SPACE . I checked in SM37 also. There was no background job running. Can anyone please help me out on this?

Regards,

Siju

8 REPLIES 8
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,878

Hi Siju

If you call a function in background task it will not schedule a job in SM37/SM37. What exactly you want to happen?

Nabheet

Read only

0 Likes
2,878

Hi Nabheet,

The custom function module 'Z_SD_SERV_ORDER_CREATE' which I am calling in my program has the code to create service orders. I want it to be executed in background . Any way to do this?

Read only

0 Likes
2,878

Hi,

It is a trfc. The function will be registered in SM58. Kindly go through the basics on CALL FUNCTION IN BACKGROUND TASK before trying it. There are options to execute LUW.

Regards,

DPM

Read only

0 Likes
2,878

The way you have done is a TRFC  call as mentioned will get triggered on commit. You can use syntax starting new task/receiveing results(if you want) for the same. Search on SCN for function module starting new task

Nabheet

Read only

0 Likes
2,878

Hi DPM,

Now I used

CALL FUNCTION 'Z_SD_SERV_ORDER_CREATE' IN BACKGROUND TASK AS SEPARATE UNIT

        TABLES

          T_FLTHDR       = LT_FLTHDR

                .

COMMIT WORK.

And when I check in SM58 , it gives me an error that :

Function module "Z_SD_SERV_ORDER_CREATE" cannot be

used for 'remote' call   .

Any way to sort it out?

Read only

0 Likes
2,878

Hi,

Check whether your FM is remote enabled. If not, kindly make it Remote function in the Function module attribute screen.

Regards,

DPM

Read only

0 Likes
2,878

Goto Se37 and make your function module RFC enabled in attributes

Read only

Former Member
0 Likes
2,878

Thanks everyone. Issue resolved.