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

COMMUNICATION_FAILURE in CALL FUNCTION STARTING NEW TASK/Background task

Former Member
0 Likes
4,676

Hi friends,

I am trying to use a FM in a Print Program (when user prints a document), using

CALL FUNCTION STARTING NEW TASK 'TASK' DESTINATION 'NONE'.

The program is triggered from VL02N tcode.

But it's giving an exception - COMMUNICATION_FAILURE. Message is Error when opening an RFC connection

I also tried

CALL FUNCTION IN BACKGROUND TASK as Separate Unit

,

then error message pops up - Database error when recording transactional RFC

We are attaching a PDF file of the print to content server within this function module and because the "attaching" takes a while, this part needs to be detached from the print program so that we can avoid performance issue.

I can't figure out the issue. i gues this is happening because print program is already running in Update task. I also tried with RFC enabled FM. Please help me resolve/understand the issue.

Appreciate your help.

Regards,

Ronjan.

1 ACCEPTED SOLUTION
Read only

former_member224404
Active Participant
0 Likes
2,443

Hi,

Is the FM you are calling is a custom one? If yes, then use the following steps.

1. Make the FM as RFC enabled.

2. Call the FM like - call function FM as background task destination 'NONE'.

3. Write a statement COMMIT WORK AND WAIT. This will actually invoke the FM

Let me know if that doesn't work. Also show me your code segment where you are calling the FM.

Thanks,

Mainak

5 REPLIES 5
Read only

former_member224404
Active Participant
0 Likes
2,444

Hi,

Is the FM you are calling is a custom one? If yes, then use the following steps.

1. Make the FM as RFC enabled.

2. Call the FM like - call function FM as background task destination 'NONE'.

3. Write a statement COMMIT WORK AND WAIT. This will actually invoke the FM

Let me know if that doesn't work. Also show me your code segment where you are calling the FM.

Thanks,

Mainak

Read only

Former Member
0 Likes
2,443

Hi Ronjan,

COMMUNICATION_FAILURE. Message is Error when opening an RFC connection

I guess the reason for the above is that every RFC call synchronous/Asynchronous issues a DB COMMIT and we cannot have DB COMMITs in the V1/V2 updates, please go through the link below.

http://help.sap.com/saphelp_nw70ehp2/helpdata/en/23/e9aa61638e404d81575e939b5cd847/frameset.htm

Now, the possible solutions i can think of are,

1) Call the FM in update task delayed start and try.

2) Or create a report program and use SUBMIT (look at the job options as well).

@Mainak

3. Write a statement COMMIT WORK AND WAIT. This will actually invoke the FM

Mainak, this will lead to a Update termination, as the program is running in an update task.

Regards,

Chen

Read only

0 Likes
2,443

Hi Chen,

Yes. You are right. I didn't read the scenario properly. Now I have following questions in mind.

1. Why you think he print program is running in update task. Do you make a save in VL02N which triggers the print program. I guess no. Then I believe print program is running in the current LUW.

2. If I can't put a commit work then I won't be able to call the FM in background task. Can you try with JOB_OPEN , SUBMIT Report and JOB_CLOSE. In that case You need to create a report and call the FM inside of that report.

Thanks,

Mainak

Read only

0 Likes
2,443

Hi Mainak,

1. Why you think he print program is running in update task.

Well, that is what the OP said i gues this is happening because print program is already running in Update task. and i guess that is how it should be done too, if you are running the print program in the same LUW then you are holding up the entire transaction and a DWP, in most of the scenarios Correspondence is a non-critical activity and hence is handled in V2 updates. This is normally done via output types, and this can be configured to trigger "on save", "process later with a background job" etc.

2. If I can't put a commit work then I won't be able to call the FM in background task. Can you try with JOB_OPEN , SUBMIT Report and JOB_CLOSE. In that case You need to create a report and call the FM inside of that report.

Right, so the OP has two options like i suggested in my original post, one of which is submitting a report with JOB options as you say.

Regards,

Chen

Read only

0 Likes
2,443

Thanks Chan and Mainak.

From your feeds, I could go in depth, could learn a lot.

I found out that the issue was with the interface paramters. I found a table structure in the IMPORT interface (my bad).

It worked fine with small table content only.

So I passed it as TABLES parameter. It's working fine now.

Appreciate your help.