tRFC – RFC IN BACKGROUND TASK

light111Details of RFC IN BACKGROUND TASK

The post described about tRFC(Asynchronous RFC –  IN BACKGROUND TASK) details. Consider we have two system and one system does some business process , then calls another system to pass the data via RFC connection in an asynchronous way and commits the business process.

As the RFC is called asynchronously, this RFC FM is not executed at the time of call, but what the COMMIT WORK occurs. So with COMMIT WORK the LUW completes and then the tRFC execution starts( which can be monitored in the Tx- SMQS)  but the RFC connection failed due to some reason.

That means the business process is complete in the first system and the RFC connection failed to pass data to the target system. With tRFC the call is written in the table – ARFCSSTATE and the call data is stored in table- ARFCSDATA

By default the system again tries to execute the RFC FM again with a frequency of 15mins and continue this for 30times until the call is successful.

If default(30 times) call attempt with a gap of 15mins is not sufficient, then in the RFC destination(Tx- SM59), it is possible to set tRFC options which allows to set what is the number of attempts and the gap time in minutes between 2 consecutive calls.

The post describes the process in details with screen shots: for the demo, the tRFC call is made in 2 different clients of the same system, but the same holds good in 2 different SAP systems.


Client-010 – Source,    Client-070 – Target

Here we have a RFC FM with a small piece of code.

1

SCARR table entries in two clients.

2

RFC Destination created in client-010  to connect client-070

3

protocol as – tRFC

4


A small report that calls RFC FM (Asynchronously-tRFC). Execute the program.

5

Program output.   Highlighted record reached in client-070

6


For demo- changed the instance number of the target system, so that RFC connection to fail.

7

Connection test is failed now.

8

Execute the program now ( Carrid = UA ) 

9

Commit work happened in the program . RFC FM executed but failed due to connection error.  Record not reached in target client.

10

Now a  background job created ( Tx- SM37 ) with a name start with – ARFC* , and the job is schedule to run 15 mins after.

1112


The FM call data is written to the table – ARFCSDATA

14

The failed tRFC call is written in the table- ARFCSSTATE, one of the counter is 30, signifies that it has to try 30times atleast to make one successful call. If the call is successful in one of the 30 trials then, the entry deleted from the table.

13

As the RFC dest having error, after 15mins, the scheduled job executed but sue to that the RFC connection error, one more time a new job scheduled to run after 15mins.

151617

Time diff = 15 mins

28


Now the table entry counter says that – remaining trial – 29 times.

18

Before the background job runs at the scheduled time, lets make the RFC dest work properly.

19

Now the scheduled job executed again and RFC FM executed without any connection problem. ( no more jobs ). Record reached in target client.

20


Up to this, we saw, how system tries to make automatically execute tRFC 30 times with a gap of 15mins in each trial which is the default settings for tRFC to ensure the RFC connection happened.

Lets try the option to set details in RFC destination.

Lets delete record from target client, so that we can test the demo scenario by sending the same record from source client.

2122


Now no entry in ARFCSSTATE table for the RFC DESTINATION-    TO_CLNT070

23

Go to Tx- SM59 and edit the destination. From menu choose Edit- tRFC options.

24

Below screen appears.

25

Provide details like- number of attempts – 100 and 10mins gap in 2 consecutive calls. Save.

26

Make sure that the connection, must not work so that we can test our demo scenario.

27

Execute the program again – with CARRID = AA

29

Record not reached in target.

30

Now the table – says it has to make a trial for 100 times which was set the RFC destination.

31

A job is scheduled to be executed 10 mins later.

32

After 10 mins, 1 trial to execute is finished with error. Now it has to make 99 trials.

34

Another job is scheduled.

33

Before the job runs at scheduled time, lets correct the RFC destination.

35

The tRFC calls can be seen from the system with Tx- SMQS. Choose the RFC destination name and select TRFC Monitor.

36

The below details can be seen.

3738


After 10 mins, job executed again and this time no more scheduled job again , as the RFC call is successful.

39

Record created in target system

40


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s