Application Development 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: 

fm IN BACKGROUND TASK output

Former Member
0 Kudos

I need to use the delivery number created in the FM z_create_dlvry.

How can I get an FM to have an output when it's called in background task?

CALL FUNCTION 'Z_CREATE_DLVRY' IN BACKGROUND TASK

EXPORTING

i_order = vbak-vbeln

TABLES

itab_msg = itab_msg1.

itab_msg1 does not return anything if it is called in background. But it returns correct value if the IN BACKGROUND TASK is removed. (delivery number = itab_msg1-msgv2). The current program needs to call the fm in background.

How can i get the delivery number created in the FM?

Thank you.

Che

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

In your function module 'Z_CREATE_DLVRY' , after your logic is complete, you fill the message in your internal table. After that just log a success message such as..

Message s000(..). ( this should contain the delivery number ).

when you execute the FM in teh background, this message gets logged and in the spool you will be able to see the delivery number.

6 REPLIES 6

Former Member
0 Kudos

Hi,

In your function module 'Z_CREATE_DLVRY' , after your logic is complete, you fill the message in your internal table. After that just log a success message such as..

Message s000(..). ( this should contain the delivery number ).

when you execute the FM in teh background, this message gets logged and in the spool you will be able to see the delivery number.

Former Member
0 Kudos

Hi Cherryl,

After calling this FM

CALL FUNCTION 'Z_CREATE_DLVRY' IN BACKGROUND TASK

EXPORTING

i_order = vbak-vbeln

TABLES

itab_msg = itab_msg1.

export delivery number(itab_msg1-msgv2) to some memory id.

Now in your program import delivery number(itab_msg1-msgv2)

from memory id.

Kindly check this and get back to me incase of any queries.

Dont forget to reward points if found useful.

Thanks,

Satyesh

former_member195698
Active Contributor
0 Kudos

why do you want to call the FM in background task?

If you call FM in background task, they are not executed till you have a commit work.

Former Member
0 Kudos

Hi Satyesh,

Thanks for your answer but exporting and importing (from memory) do not when using IN BACKGROUND TASK.

Hi Abhishek,

Thank you.

It is called in background because it is creating a delivery for the currently opened order. The processing type is remote-enabled module. And it can be triggered by IDocs.

Would the IN UPDATE TASK still work? I did not code the Z_CREATE_DLVRY fm but i need the delivery number it generates.

Hi Shruthi,

I added Message s000(..) inside the FM 'Z_CREATE_DLVRY' . But I am not able to see a new entry logged in TSP01 table under my username. Could you please help me how to log the delivery number to the spool and how to retrieve it after the function call?

Thanks!

Che

0 Kudos

Hi Cherryl,

What is the flow in your RFC ? What exactly is your requirement?

Since you are calling the FM in BACKGROUND TASK and since it will be called only when a COMMIT WORK statement is encountered you will not be able to get the Delivery Number until COMMIT WORK is encountered

Now if your requirement is to get the delivery number in this case this will be possible only after COMMIT WORK. Now if the data is commited at this point you can very well fetch the required delivery based on the sales order from the Database.

Even the IN UPDATE TASK Will not work as that also will be called only After the COMMIT statement.

Why can't we call that FM as a Normal Functional Module?

Is it called in background task just to keep transactional Integrity ?

Regards,

Abhishek

0 Kudos

The requirement is to create billing document automatically after creation of KE doc (which is currently creating delivery automatically).

Thank you so much for your help.

I put the code in the user exit save of delivery creation... and not in order creation save user exit. I am now able to create billing document.

Thanks to all!

Regards,

Che