tRFC[transactional RFC]:- Use case is like when once Pur Order is created one system the same PO has to be created in another sap system. The call should not be a synchronous call because in synchronous call the target system has to be active. But in this case the target system may be active or may not be. But the business requirement is that the PO has to be created in the target system may be at that moment or another point of time when the target system is active. In this case tRFC plays the success role. The sender program calls the tRFC fM and records are passed ( tRFC call doesn't allow importing parameters ) to it which is stored temporarily in a table in the sender system and the sender program finishes its execution. When the commit work statement is executed in the calling program, the outbound scheduler reads the details of the tRFC call from the table and starts executing it in the target table by using the destination name. If at that moment the target system is active the FM is executed and if not the background program calls the FM in a regular interval of time unless it is successfully executed in the target system and the program takes care that it should be executed exactly once in the target system.
------------------------------------------------------------------------------------------------------------------------------------------------
Step1. Target System: Create a RFC FM.
Step2. Target System: It's having a Importing parameter.
Step3. Target System: Source code which inserts a record in scarr table.
Step4. Sender System: In Sender System we have the below RFC connection which connects to the target system.
Step5. Sender System: Do a connection test and we have the success message.
Step6. Target system : table SCARR table have the below records.
Step7. Sender system : Here we have the program which calls the RFC as a tRFC call .
-----------------------------------------------------------------------------------------------------------------------------------------------
DATA ls TYPE scarr.
CONSTANTS : rfc_det TYPE rfcdest VALUE 'DEV_TO_TED'.
SELECTION-SCREEN : BEGIN OF BLOCK b1.
PARAMETERS : cr RADIOBUTTON GROUP g1,
up RADIOBUTTON GROUP g1,
dl RADIOBUTTON GROUP g1.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK b2.
PARAMETERS : carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname.
SELECTION-SCREEN : END OF BLOCK b2.
START-OF-SELECTION.
IF carrid IS NOT INITIAL AND carrname IS NOT INITIAL.
CASE 'X'.
WHEN cr.
ls-carrid = carrid.
ls-carrname = carrname.
CALL FUNCTION 'ZRFC_CREATE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for create
DESTINATION rfc_det " tRFC doesn't have importing parameter
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
WHEN up.
CALL FUNCTION 'ZRFC_UPDATE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for update
DESTINATION rfc_det
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
WHEN dl.
CALL FUNCTION 'ZRFC_DELETE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for delete
DESTINATION rfc_det
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDCASE.
WRITE : /'Check Transaction SM58 for tRFC call'.
WRITE : /'Check Transaction SMQS for Scheduler'.
WRITE : /'Check table : ARFCSSTATE '.
ELSE.
WRITE :/' please provide valid I/P details'.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------------------------------
Step8. Sender system : go to Tcode- SM58 and execute it.
Step9. Sender system : Currently there is no tRFC call waiting in SM58.
Step10. Sender system : Go to tcode- SMQS to see the outbound queue scheduler.
Step11. Sender System: So right now this is the status.
Step12.Sender system: Go to tcode- SE11 and open the below table. Provide our RFC destination name.
Step13. Sender System: put a debug point in the program as shown and execute it.
Step14. Sender system: Enter input details, select create radio button and execute.
Step15. Sender System: So here the debugger stops. press F5. so we are on the line to execute commit work statement. When the TRFC function module ( in background task as separate unit - makes a rfc as tRFC) is execute, the source code inside it in the target system doesn't run. But a commit work statement makes it executable. Now again press F5 .
Step16. Sender system: So the commit work triggers this FM.Hold the debugger here and don't press F8.
Step17. Sender system: Open Tcode- SM58 and here we have a entry here.
Step18. Sender System: go to the table ARFCSSTATE & provide the RFC destination name and execute it. So we have the same call of the tRFC is present. SM58 reads this table and shows the record.
Step19. Sender system. Go to our hold debugger and press F7 so that the commit work statement execution is finished.
Step20. Sender System: Once the commit work statement is finished, the tRFC call entry is removed from the table ARFCSSTATE & from SM58 and the Scheduler puts it for the execution. Go to Tcode- SMQS and here one entry with our RFC destination name is present in waiting status. This waiting status indicates that the target FM is in process and execution has not yet finished.
Step21. Sender system: So the commit work statement execution finished.
Step22. Target System: As previously we have set a debug in the target RFC FM, the scheduler runs the RFC FM and the status is in waiting state.
Step23.Target System: As the debugger holds the execution of the FM, the status in SMQS (in sender system) is waiting. Press F8 and finish the execution of the FM.
Step24.Sender System: Refresh. So now the status is changed to inactive. As the scheduler is free, no call is to be processed.
Step25. Sender system: So we have the report output.
Step26. In target system: one more entry is created.
Step27. Sender System: After commit work the call of the tRFC FM is deleted from the SM58 transaction and forwarded to the scheduler to get processed.
Step28. Sender system: Also the temporary entry is deleted from the table.
--------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
Step2. Target System: It's having a Importing parameter.
Step3. Target System: Source code which inserts a record in scarr table.
Step4. Sender System: In Sender System we have the below RFC connection which connects to the target system.
Step5. Sender System: Do a connection test and we have the success message.
Step6. Target system : table SCARR table have the below records.
Step7. Sender system : Here we have the program which calls the RFC as a tRFC call .
-----------------------------------------------------------------------------------------------------------------------------------------------
DATA ls TYPE scarr.
CONSTANTS : rfc_det TYPE rfcdest VALUE 'DEV_TO_TED'.
SELECTION-SCREEN : BEGIN OF BLOCK b1.
PARAMETERS : cr RADIOBUTTON GROUP g1,
up RADIOBUTTON GROUP g1,
dl RADIOBUTTON GROUP g1.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN : BEGIN OF BLOCK b2.
PARAMETERS : carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname.
SELECTION-SCREEN : END OF BLOCK b2.
START-OF-SELECTION.
IF carrid IS NOT INITIAL AND carrname IS NOT INITIAL.
CASE 'X'.
WHEN cr.
ls-carrid = carrid.
ls-carrname = carrname.
CALL FUNCTION 'ZRFC_CREATE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for create
DESTINATION rfc_det " tRFC doesn't have importing parameter
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
WHEN up.
CALL FUNCTION 'ZRFC_UPDATE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for update
DESTINATION rfc_det
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
WHEN dl.
CALL FUNCTION 'ZRFC_DELETE_AIRLINE_CODE'
IN BACKGROUND TASK AS SEPARATE UNIT " calling a tRFC for delete
DESTINATION rfc_det
EXPORTING
ls = ls.
IF sy-subrc = 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
ENDIF.
ENDCASE.
WRITE : /'Check Transaction SM58 for tRFC call'.
WRITE : /'Check Transaction SMQS for Scheduler'.
WRITE : /'Check table : ARFCSSTATE '.
ELSE.
WRITE :/' please provide valid I/P details'.
ENDIF.
Step8. Sender system : go to Tcode- SM58 and execute it.
Step9. Sender system : Currently there is no tRFC call waiting in SM58.
Step10. Sender system : Go to tcode- SMQS to see the outbound queue scheduler.
Step11. Sender System: So right now this is the status.
Step12.Sender system: Go to tcode- SE11 and open the below table. Provide our RFC destination name.
Step13. Sender System: put a debug point in the program as shown and execute it.
Step14. Sender system: Enter input details, select create radio button and execute.
Step15. Sender System: So here the debugger stops. press F5. so we are on the line to execute commit work statement. When the TRFC function module ( in background task as separate unit - makes a rfc as tRFC) is execute, the source code inside it in the target system doesn't run. But a commit work statement makes it executable. Now again press F5 .
Step16. Sender system: So the commit work triggers this FM.Hold the debugger here and don't press F8.
Step17. Sender system: Open Tcode- SM58 and here we have a entry here.
Step18. Sender System: go to the table ARFCSSTATE & provide the RFC destination name and execute it. So we have the same call of the tRFC is present. SM58 reads this table and shows the record.
Step19. Sender system. Go to our hold debugger and press F7 so that the commit work statement execution is finished.
Step20. Sender System: Once the commit work statement is finished, the tRFC call entry is removed from the table ARFCSSTATE & from SM58 and the Scheduler puts it for the execution. Go to Tcode- SMQS and here one entry with our RFC destination name is present in waiting status. This waiting status indicates that the target FM is in process and execution has not yet finished.
Step21. Sender system: So the commit work statement execution finished.
Step22. Target System: As previously we have set a debug in the target RFC FM, the scheduler runs the RFC FM and the status is in waiting state.
Step23.Target System: As the debugger holds the execution of the FM, the status in SMQS (in sender system) is waiting. Press F8 and finish the execution of the FM.
Step24.Sender System: Refresh. So now the status is changed to inactive. As the scheduler is free, no call is to be processed.
Step25. Sender system: So we have the report output.
Step26. In target system: one more entry is created.
Step27. Sender System: After commit work the call of the tRFC FM is deleted from the SM58 transaction and forwarded to the scheduler to get processed.
Step28. Sender system: Also the temporary entry is deleted from the table.
--------------------------------------------------------------------------------------------------------------------------------------------
1 comment:
Very Nice Post.. Thanks a lot..
Post a Comment