2006 Jun 06 3:50 PM
Hi Gurus,
How to run the FM in background.
Someone was telling me their is another FM for this.If anybody could give details about this or any other way to do this.That will be gr8 help.
Thanks in advance.
Arshad
Hi Gurus,
How to run the FM in background.
Someone was telling me their is another FM for this.If anybody could give details about this or any other way to do this.That will be gr8 help.
Thanks in advance.
Arshad
2006 Jun 06 3:52 PM
Use the syntax:
CALL FUNCTION func IN BACKGROUND TASK.
<b>See the example:
REPORT RS41503F.
/* This program performs a transactional RFC.
TABLES: SCUSTOM.
SELECT-OPTIONS: CUSTID FOR SCUSTOM-ID DEFAULT 1 TO 2.
PARAMETERS: DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE',
MODE DEFAULT 'N',
TIME LIKE SY-UZEIT DEFAULT SY-UZEIT.
DATA: CUSTITAB TYPE TABLE OF CUST415,
TAMESS TYPE TABLE OF T100,
WA_CUSTITAB TYPE CUST415.
SELECT ID NAME TELEPHONE INTO CORRESPONDING FIELDS OF TABLE CUSTITAB
FROM SCUSTOM WHERE ID IN CUSTID ORDER BY ID.
PERFORM READ_CUSTITAB.
EDITOR-CALL FOR CUSTITAB TITLE 'Editor for table CUSTITAB'.
PERFORM READ_CUSTITAB.
CALL FUNCTION 'TRAIN415_RFC_CALLTRANSACTION'
IN BACKGROUND TASK
DESTINATION DEST
EXPORTING
TAMODE = MODE
TABLES
CUSTTAB = CUSTITAB.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
STARTDATE = SY-DATUM
STARTTIME = TIME
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 1.
EXIT.
ENDIF.
COMMIT WORK.
CALL TRANSACTION 'SM58'.
----
FORM READ_CUSTITAB *
----
FORM READ_CUSTITAB.
WRITE: / 'System ID:', SY-SYSID.
SKIP.
LOOP AT CUSTITAB INTO WA_CUSTITAB.
WRITE: / CUSTITAB-ID, CUSTITAB-NAME,
WA_CUSTITAB-TELEPHONE.
ENDLOOP.
ULINE.
ENDFORM.</b>
Regards,
Ravi
2006 Jun 06 3:53 PM
JOB_OPEN
JOB_SUBMIT
JOB_CLOSE
<b>Check this sample code which I got from this forum and kindly reward points if it helps.</b>
report zrich_0004 .
data: sdate type sy-datum,
stime type sy-uzeit,
l_valid,
ls_params like pri_params,
l_jobcount like tbtcjob-jobcount,
l_jobname like tbtcjob-jobname.
start-of-selection.
Get Print Parameters
call function 'GET_PRINT_PARAMETERS'
exporting
no_dialog = 'X'
importing
valid = l_valid
out_parameters = ls_params.
Open Job
l_jobname = 'ZRICH_0005'.
call function 'JOB_OPEN'
exporting
jobname = l_jobname
importing
jobcount = l_jobcount.
Submit report to job
submit zrich_0005
via job l_jobname
number l_jobcount
to sap-spool without spool dynpro
spool parameters ls_params
and return.
Kick job off 30 seconds from now.
sdate = sy-datum.
stime = sy-uzeit + 30.
Schedule and close job.
call function 'JOB_CLOSE'
exporting
jobcount = l_jobcount
jobname = l_jobname
sdlstrtdt = sdate
sdlstrttm = stime
strtimmed = 'X'
Message was edited by: Rahul Kavuri
2006 Jun 06 3:53 PM
Hii
If your aim is to run a FM in background, the you can use the syntax:
<b>CALL FUNCTION func IN BACKGROUND TASK.</b>
Transactional RFC before release 7.0
<b>1. CALL FUNCTION func IN BACKGROUND TASK
[DESTINATION dest]
parameter_list
[AS SEPARATE UNIT].</b>
Transactional RFC as of release 7.0
<b>2. CALL FUNCTION func IN BACKGROUND UNIT
parameter_list.</b>
otherwise
<b>Create a report and call the function module.
The schedule that report in backgroud in SM37.</b>
check this link
Regards
Naresh
2006 Jun 06 3:58 PM
Thank you all..
Sorry i missed to tell you that ..Actually i want to test my FM without calling it in any report.
2006 Jun 06 3:55 PM
You can call this FM in a program and run that program in background. I think this is the simplest way.
Peter
2006 Jun 06 3:57 PM
Refer the following SAP program.
REPORT RS41503F.
/* This program performs a transactional RFC.
TABLES: SCUSTOM.
SELECT-OPTIONS: CUSTID FOR SCUSTOM-ID DEFAULT 1 TO 2.
PARAMETERS: DEST LIKE RFCDES-RFCDEST DEFAULT 'NONE',
MODE DEFAULT 'N',
TIME LIKE SY-UZEIT DEFAULT SY-UZEIT.
DATA: CUSTITAB TYPE TABLE OF CUST415,
TAMESS TYPE TABLE OF T100,
WA_CUSTITAB TYPE CUST415.
SELECT ID NAME TELEPHONE INTO CORRESPONDING FIELDS OF TABLE CUSTITAB
FROM SCUSTOM WHERE ID IN CUSTID ORDER BY ID.
PERFORM READ_CUSTITAB.
EDITOR-CALL FOR CUSTITAB TITLE 'Editor for table CUSTITAB'.
PERFORM READ_CUSTITAB.
CALL FUNCTION 'TRAIN415_RFC_CALLTRANSACTION'
IN BACKGROUND TASK
DESTINATION DEST
EXPORTING
TAMODE = MODE
TABLES
CUSTTAB = CUSTITAB.
CALL FUNCTION 'START_OF_BACKGROUNDTASK'
EXPORTING
STARTDATE = SY-DATUM
STARTTIME = TIME
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 1.
EXIT.
ENDIF.
COMMIT WORK.
CALL TRANSACTION 'SM58'.
*------------------------------------------------------------*
* FORM READ_CUSTITAB *
*------------------------------------------------------------*
FORM READ_CUSTITAB.
WRITE: / 'System ID:', SY-SYSID.
SKIP.
LOOP AT CUSTITAB INTO WA_CUSTITAB.
WRITE: / CUSTITAB-ID, CUSTITAB-NAME,
WA_CUSTITAB-TELEPHONE.
ENDLOOP.
ULINE.
ENDFORM.
<b>Reward points if it helps.</b>
2007 Feb 01 12:33 PM
Hello,
does anybody have a WORKING example for the usage of CALL FUNCTION IN BACKGROUND UNIT oref
Especially I'm wondering how to set the RFC destination in reference variable oref