Why do we use CALL FUNCTION ..IN BACKGROUND TASK and CALL FUNCTION ...STARTING NEW TASK?

What is the difference?

Answers were Sorted based on User's Feedback



Why do we use CALL FUNCTION ..IN BACKGROUND TASK and CALL FUNCTION ...STARTING NEW TASK? What is ..

Answer / sathish kumar

The IN BACKGROUND TASK statement allows you to execute remote enabled function modules in a background task asynchronously. Be careful thought as it might not quite work as it appears too i.e. If you debug the ABAP program logic it will step over the FM onto the next line of code, not waiting for this function module to finish it processing. But this doesn�t mean it has gone off to start the processing at this point as it has not!! It has simply created the background task ready for processing and will not actually be executed until a commit work is reached in the current logical unit of work. 




So basically if you want it to go off and perform this background processing straight away you need to add a commit work after the call function� in background task command. 




Just in case you are interested in the technical details when you make the call using the in background task addition SAP stores the FM name, destination and any parameters in tables ARFCSSTATE & ARFCSDATA for the current Logical unit of work. These entries can also been seen using tcode SE58. Please note this data is not available here after the task has finished processing. 




Although this may seem strange at first it does allow you to perform other functionality first and only triggers the background task if all is well with that and it is committed to the database ok. Also the background tasks will be processed in the order they have been registered. 




AS SEPARATE UNIT 
The �as separate unit� addition is used if you are calling the same FM multiple times or FM�s within the same function group. It basically ensures each call is processed within its own context and is not affected by global data changes from other function calls. 




DESTINATION 
This simple allows you to specify a different RFC destination 




Example ABAP code to Execute FM in background task




CALL FUNCTION 'Z_FMODULE' IN BACKGROUND TASK
  EXPORTING
    P_UNAME       = sy-uname.








*IN BACKGROUND TASK additional options
CALL FUNCTION 'Z_FMODULE' IN BACKGROUND TASK
      AS SEPARATE UNIT
      DESTINATION 'NONE'
  EXPORTING
    P_UNAME       = sy-uname.








break-point. "does not wait and continues with next line of ABAP code




Commit Work. "Background task is only triggered at this point.




"loop at itab into wa_itab.
"...
"endloop.

The STARTING NEW TASK statement allows you to call a function module but it will be executed in a separate processing task asynchronously so the ABAP program logic does not wait for this FM to finish its processing but continues with the next line of abap code. The clever thing about this statement is that once the FM has finished processing it will then execute the specified FORM within the original program to continue processing. 




This small example is actually the basis for reports which auto-refresh themselves. i.e. the program calls a function module in a new task which then waits a few seconds (WAIT 10 seconds). Once it returns to the program and performs the return form it basically re-runs the whole report again. This especially creates an endless loop so report keeps updating itself until it is cancelled by the user.




Execute FM in update task within separate unit of work




CALL FUNCTION 'Z_FMODULE'
  starting new task 'UPDATE'
             destination 'NONE'
              performing processing_done on end of task
  EXPORTING
    P_UNAME       = sy-uname.




"program does not wait for FM to finish processing and continues with next line of ABAP code
break-point.
"...perform display_report.












FORM processing_done.
* In the mean time once processing of FM Z_FMODULE is complete this abap FORM is then executed.
WIthin here you can perform any processing you like, including re-displaying a report




"...perform display_report.
ENDFORM.

Is This Answer Correct ?    0 Yes 0 No

Why do we use CALL FUNCTION ..IN BACKGROUND TASK and CALL FUNCTION ...STARTING NEW TASK? What is ..

Answer / sampath

functions used background are job_open,job_submit and job_close.

Is This Answer Correct ?    0 Yes 8 No

Post New Answer

More SAP ABAP Interview Questions

Why do we use types statement in abap programming?

0 Answers  


how can u write in single program call transaction and session method logic? if u write logic in call transaction ,is there any errors ? how can u see in session ?

2 Answers   Satyam,


How to Raise a Particular Ticket in Realtime ?

0 Answers   IBM,


in which event validation is done?

1 Answers   CTS,


Events in Reports?

4 Answers   Atos Origin,






Explain about drill down report?

0 Answers  


HOW MANY IMPLEMENTATIONWE CAN CREATE IN BADI? WHAT IS THE USE OF REUSABLE IN BADI? HOW MANY IMPLEMENTATION IS ACTIVE IN PRODUCTION SYSTEM AT A TIME?

2 Answers   Siemens,


how to use table control in bdc, plz somebody tell me.

1 Answers   Cap Gemini,


What is the main difference between Smartforms and SAP scripts?

19 Answers   Accenture, Deloitte,


What is the MM Flow with Transaction Codes

2 Answers  


In a transaction there are 5 screens (say) but while recording you could see only 3 screens.what will u do to avoid such situation?will u save it like that?

5 Answers   TCS,


1.what aer the text modules. 2.what is function module in report. 3.what is the land scape in u r projwct.

4 Answers   Cap Gemini,


Categories
  • SAP Basis Interview Questions SAP Basis (1262)
  • SAP ABAP Interview Questions SAP ABAP (3939)
  • SAPScript Interview Questions SAPScript (236)
  • SAP SD (Sales & Distribution) Interview Questions SAP SD (Sales & Distribution) (2716)
  • SAP MM (Material Management) Interview Questions SAP MM (Material Management) (911)
  • SAP QM (Quality Management) Interview Questions SAP QM (Quality Management) (99)
  • SAP PP (Production Planning) Interview Questions SAP PP (Production Planning) (523)
  • SAP PM (Plant Maintenance) Interview Questions SAP PM (Plant Maintenance) (252)
  • SAP PS (Project Systems) Interview Questions SAP PS (Project Systems) (138)
  • SAP FI-CO (Financial Accounting & Controlling) Interview Questions SAP FI-CO (Financial Accounting & Controlling) (2766)
  • SAP HR (Human Resource Management) Interview Questions SAP HR (Human Resource Management) (1180)
  • SAP CRM (Customer Relationship Management) Interview Questions SAP CRM (Customer Relationship Management) (432)
  • SAP SRM (Supplier Relationship Management) Interview Questions SAP SRM (Supplier Relationship Management) (132)
  • SAP APO (Advanced Planner Optimizer) Interview Questions SAP APO (Advanced Planner Optimizer) (92)
  • SAP BW (Business Warehouse) Interview Questions SAP BW (Business Warehouse) (896)
  • SAP Business Workflow Interview Questions SAP Business Workflow (72)
  • SAP Security Interview Questions SAP Security (597)
  • SAP Interfaces Interview Questions SAP Interfaces (74)
  • SAP Netweaver Interview Questions SAP Netweaver (282)
  • SAP ALE IDocs Interview Questions SAP ALE IDocs (163)
  • SAP Business One Interview Questions SAP Business One (110)
  • SAP BO BOBJ (Business Objects) Interview Questions SAP BO BOBJ (Business Objects) (388)
  • SAP CPS (Central Process Scheduling) Interview Questions SAP CPS (Central Process Scheduling) (14)
  • SAP GTS (Global Trade Services) Interview Questions SAP GTS (Global Trade Services) (21)
  • SAP Hybris Interview Questions SAP Hybris (132)
  • SAP HANA Interview Questions SAP HANA (700)
  • SAP PI (Process Integration) Interview Questions SAP PI (Process Integration) (113)
  • SAP PO (Process Orchestration) Interview Questions SAP PO (Process Orchestration) (25)
  • SAP BI (Business Intelligence) Interview Questions SAP BI (Business Intelligence) (174)
  • SAP BPC (Business Planning and Consolidation) Interview Questions SAP BPC (Business Planning and Consolidation) (38)
  • SAP BODS (Business Objects Data Services) Interview Questions SAP BODS (Business Objects Data Services) (49)
  • SAP BODI (Business Objects Data Integrator) Interview Questions SAP BODI (Business Objects Data Integrator) (26)
  • SAP Ariba Interview Questions SAP Ariba (9)
  • SAP Fiori Interview Questions SAP Fiori (45)
  • SAP EWM (Extended Warehouse Management) Interview Questions SAP EWM (Extended Warehouse Management) (58)
  • Sap R/3 Interview Questions Sap R/3 (150)
  • SAP FSCM Financial Supply Chain Management Interview Questions SAP FSCM Financial Supply Chain Management (101)
  • SAP WM (Warehouse Management) Interview Questions SAP WM (Warehouse Management) (31)
  • SAP GRC (Governance Risk and Compliance) Interview Questions SAP GRC (Governance Risk and Compliance) (64)
  • SAP MDM (Master Data Management) Interview Questions SAP MDM (Master Data Management) (0)
  • SAP MRS (Multi Resource Scheduling) Interview Questions SAP MRS (Multi Resource Scheduling) (0)
  • SAP ESS MSS (Employee Manager Self Service) Interview Questions SAP ESS MSS (Employee Manager Self Service) (13)
  • SAP CS (Customer Service) Interview Questions SAP CS (Customer Service) (0)
  • SAP TRM (Treasury and Risk Management) Interview Questions SAP TRM (Treasury and Risk Management) (0)
  • SAP Web Dynpro ABAP Interview Questions SAP Web Dynpro ABAP (198)
  • SAP IBP (Integrated Business Planning) Interview Questions SAP IBP (Integrated Business Planning) (0)
  • SAP OO-ABAP (Object Oriented ABAP) Interview Questions SAP OO-ABAP (Object Oriented ABAP) (70)
  • SAP S/4 HANA Finance (Simple Finance) Interview Questions SAP S/4 HANA Finance (Simple Finance) (143)
  • SAP FS-CD (Collections and Disbursements) Interview Questions SAP FS-CD (Collections and Disbursements) (0)
  • SAP PLM (Product Lifecycle Management) Interview Questions SAP PLM (Product Lifecycle Management) (0)
  • SAP SuccessFactors Interview Questions SAP SuccessFactors (33)
  • SAP Vistex Interview Questions SAP Vistex (0)
  • SAP ISR (IS Retail) Interview Questions SAP ISR (IS Retail) (28)
  • SAP IdM (Identity Management) Interview Questions SAP IdM (Identity Management) (0)
  • SAP IM (Investment Management) Interview Questions SAP IM (Investment Management) (0)
  • SAP UI5 Interview Questions SAP UI5 (59)
  • SAP SCM (Supply Chain Management) Interview Questions SAP SCM (Supply Chain Management) (51)
  • SAP XI (Exchange Infrastructure) Interview Questions SAP XI (Exchange Infrastructure) (49)
  • SAP Cloud Platform Interview Questions SAP Cloud Platform (34)
  • SAP Testing Interview Questions SAP Testing (89)
  • SAP SolMan (Solution Manager) Interview Questions SAP SolMan (Solution Manager) (63)
  • SAP MaxDB Interview Questions SAP MaxDB (116)
  • SAP GUI Interview Questions SAP GUI (15)
  • SAP AllOther Interview Questions SAP AllOther (329)