Running ABAP Program in Background
Hi,
I need to write a program which could run in background mode based on some condition. For example, I have two radio buttons, Excel and Spool. If I select Excel the program should run normally in foreground mode. If I select spool the program should run in background mode and save the out put in spool.
How can I do this?
Thanking you in advance
Regards,
Eswar
Hi,
long time ago, I found this coding at http://www.4ap.de.
This coding ask in a popup for running in background, when the select-option fields
s_carrid and s_connid are intitial.
Hope it helps you....
Stefan
TABLES: sflight.
DATA: BEGIN OF i_sflight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
currency LIKE sflight-currency,
paymentsum LIKE sflight-paymentsum,
zielbetrag LIKE sflight-paymentsum,
END OF i_sflight.
DATA: sw_int(1) TYPE p.
DATA answer.
DATA: job LIKE tbtcjob-jobname.
DATA: num LIKE rsjobinfo-jobnumb.
SELECT-OPTIONS: s_carrid FOR sflight-carrid,
s_connid FOR sflight-connid.
PARAMETERS: p_curr LIKE tcurr-tcurr OBLIGATORY DEFAULT 'EUR'.
AT SELECTION-SCREEN.
CLEAR answer.
CHECK sy-batch IS INITIAL AND sy-ucomm NE 'JOBS'.
IF s_carrid[] IS INITIAL AND
s_connid[] IS INITIAL.
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
textline1 = 'Sie haben nichts eingeschränkt!'(001)
textline2 = 'Das Programm wird voraussichtlich'(002)
textline3 = 'länger laufen.'(003)
text_option1 = 'Im Hintergrund'(004)
text_option2 = 'Trotzdem ausführen'(005)
titel = 'Achtung, Langläufer!'(006)
IMPORTING
answer = answer
EXCEPTIONS
OTHERS = 1.
CASE answer.
WHEN '1'.
CONCATENATE sy-uname sy-repid INTO job SEPARATED BY '_'.
CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = job
IMPORTING
jobcount = num
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
SUBMIT (sy-repid)
TO SAP-SPOOL
VIA SELECTION-SCREEN
VIA JOB job NUMBER num
WITH s_carrid IN s_carrid
WITH s_connid IN s_connid
WITH p_curr = p_curr
AND RETURN.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = num
jobname = job
strtimmed = 'X'
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
OTHERS = 8.
IF sy-subrc = 0.
MESSAGE s311(tg) WITH job num.
* Der Batch Job & wurde mit der Nummer & eingeplant
ELSE.
MESSAGE e102(ss).
* Fehler bei der Joberzeugung
ENDIF.
WHEN '2'.
WHEN 'A'.
SET CURSOR FIELD s_carrid-low.
MESSAGE e055(c/).
* Die Selektion ist zu umfangreich. Bitte einschränken.
ENDCASE.
ENDIF.
START-OF-SELECTION.
CHECK sy-ucomm NE 'JOBS' AND answer NE '1'.
SELECT carrid connid fldate currency paymentsum
INTO TABLE i_sflight
FROM sflight
WHERE carrid IN s_carrid.
LOOP AT i_sflight.
FORMAT COLOR COL_NORMAL INTENSIFIED = sw_int.
sw_int = 1 - sw_int.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
date = sy-datum
foreign_amount = i_sflight-paymentsum
foreign_currency = i_sflight-currency
local_currency = p_curr
IMPORTING
local_amount = i_sflight-zielbetrag
EXCEPTIONS
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
OTHERS = 5.
MODIFY i_sflight TRANSPORTING zielbetrag.
WRITE: / i_sflight-carrid,
i_sflight-connid,
i_sflight-fldate,
i_sflight-paymentsum CURRENCY i_sflight-currency,
i_sflight-currency,
i_sflight-zielbetrag CURRENCY p_curr,
p_curr,
AT sy-linsz ''.
AT END OF connid.
SUM.
FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
WRITE: / i_sflight-carrid,
i_sflight-connid,
10 'Summe',
i_sflight-zielbetrag CURRENCY p_curr
UNDER i_sflight-zielbetrag,
p_curr,
AT sy-linsz ''.
ENDAT.
AT END OF carrid.
SUM.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE: / i_sflight-carrid,
10 'Summe',
i_sflight-zielbetrag CURRENCY p_curr
UNDER i_sflight-zielbetrag,
p_curr,
AT sy-linsz ''.
NEW-PAGE.
ENDAT.
AT LAST.
SUM.
FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
WRITE: /10 'Gesamtsumme:',
i_sflight-zielbetrag CURRENCY p_curr
UNDER i_sflight-zielbetrag,
p_curr,
AT sy-linsz ''.
ENDAT.
ENDLOOP.
Similar Messages
-
Can We Run a ABAP Program in Background
Hi,
How to run an ABAP Program in Background.
Points willbe awarded.
Regards,
JayasimhaHi,
<b>Please see this document also
http://help.sap.com/saphelp_nw04/helpdata/en/fa/096ccb543b11d1898e0000e8322d00/content.htm
Easy Job Scheduling Using BP_JOBVARIANT_SCHEDULE</b>
To schedule a job from within a program using the express method, you need only call the BP_JOBVARIANT_SCHEDULE function module.
The express method has the following characteristics:
Simplified job structure: The function module schedules a job that includes only a single job step.
The function module uses default values for most job-processing options. You cannot, for example, specify a target printer as part of the call to the function module. Instead, the job step uses the print defaults of the scheduling user.
Only ABAP reports can be scheduled. You must use the "full-control" method to start external programs.
The range of start-time options is restricted. Event-based scheduling is not supported.
The function module works as follows:
You name the report that is to be scheduled in your call to the function module.
The function module displays a list of variants to the user. The user must select a variant for the report.
You must ensure that the variants required by your users have already been defined.
The user picks either "immediate start" or enters a start date and start time. Optionally, the user can also make the job restart periodically. The job is then scheduled.
Example
You could use the following code to let users schedule report RSTWGZS2 for checking on the status of online documentation:
call function 'BP_JOBVARIANT_SCHEDULE'
exporting
title_name = 'Documentation Check' " Displayed as title of
" of scheduling screens
job_name = 'DocuCheck' " Name of background
" processing job
prog_name = 'RSTWGZS2' " Name of ABAP
" report that is to be
" run -- used also to
" select variants
exceptions
no_such_report = 01. " PROG_NAME program
" not found.
call function 'BP_JOBVARIANT_OVERVIEW' " List the jobs that
exporting " have been scheduled
title_name = 'Documentation Check' " Displayed as title
" of overview screen
job_name = 'DokuCheck' " Jobs with this name
" are listed
prog_name = 'RSTWGZS2'
exceptions
no_such_job = 01.
Regards, ABY -
Is there any way to run abap program in dialog process with process chain?
Hi.
I just want to run custom abap program in every 30min.
so I made process chain and connect abap program.
but it returns NOTHING when background running.
the program has ABSOLUETLY no problem when it's running DIALOG process.
custom program is modified from sap standard program for my use.
so complicated and hard to read that I cann't figure out what's problem in backgound job and even hard to debug in background process.
is there any way to run abap program in dialog process in every 30 min.?
or call BSP page or call function.
any solution will be helpful that excuting PROGRAM or FUNCTION or BSP PAGE in schedule job and should running dialog process.
thanks.
Lee.Hi,
did you try using sm36 transaction?
1Give these values in Gereral data
Create one sample job "SAMPLE JOB"
Priority "A"
Execu target - Your application server
2Click start conditon
schedule according to ur requirements.
3.Click Step button
Give your ABAP program name.
fill variants if it has any variants.
if it is useful assign points
Regard,
Senthil Kumar.P -
To run a program in BACKGROUND using SUBMIT
I need to run a program in background using the SUBMIT option. Here i have to pass an internal table form one program to another which will be used to update sales orders using BDC.
Questions
1} Can we execute a program in background using SUBMIT?
2} I am sending data to a MEMORY ID , if i run the program in background will the memory id work. As in do memory IDs work in the background.
Thanks in Advancerefer same thread.
Re: Problem with SUBMIT in Background -
How to run a program in background and how to check the output
I have to run my program as background job... it has a selection screen...... and i need to check the output after its complete.
hi,
u need to create one program for this.
tables:btcevtjob.
parameters:job(32).
data:count like btcevtjob-jobcount.
call the function modules JOB_OPEN,JOB_SUBMIT AND JOB_CLOSE
and pass the parameters in those function modules.
once u execute this program,
go with sm37->provide jobname->select the option scheduled
->execute
selct the entry->go with release option.
under releasae select immediate option
save
select the job name again
go with release
status is in finished stage
now go with spool option
give spool no
go for display
o/p displayed.
before this,go for se38->provide the name of program which u want to run in back ground->seelct variants->change->provide variant name->go for create->provide input value->go with attributes->provide description->save
this variant name u have to give in the job_submit fm.
or
se38->program->execute->in back ground
Reward points if useful,
Thanks,
Usha -
How to run a program in background?
Hi abapers,
I want to run a program in background using sm36 and sm37.But i am not aware of input in that tansaction.So kindly tell me the steps ho run a program in background.
Regards
AnsumanHi Ansuman Parhi,
by useing T-codes
First go to transaction SM36 to schedule the job.
When you enter the "Start condition" for job, do as follow.
Select processing by "Date/Time".
Enter date as current date.
Let us say you are scheduling this job today then give date 08/30/2007.
Check "periodic job" checkbox.
Hit "periodic value" button and select to run "Daily"
Also have a look on below thread
Re: How to run program in background?
This is how to do it through code
data: lv_job_name like tbtco-jobname,
lv_job_nr like tbtco-jobcount,
lv_job_released type c,
lv_job_start_sofort type c,
lv_print_parameters type pri_params.
lv_job_name = 'Z_test'. " your background program name
call function 'JOB_OPEN'
exporting
jobname = lv_job_name
importing
jobcount = lv_job_nr
exceptions
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
others = 4.
if syst-subrc = 0.
*submit job with all the selection screen params...
submit (lv_job_name)
with applfile = applfile
with p_lines = p_lines
with rfc_dest = rfcdest
with p_selmtd = lv_selmtd
with px_shsim = px_shsim
with px_sherr = px_sherr
user syst-uname
via job lv_job_name number lv_job_nr and return.
if sy-subrc = 0.
call function 'JOB_CLOSE'
exporting
jobcount = lv_job_nr
jobname = lv_job_name
strtimmed = 'X'
importing
job_was_released = lv_job_released
exceptions
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
others = 8.
if syst-subrc 0.
message i162(00) with
'An error occured while closing the background job.'.
stop.
endif.
endif.
endif.
skip 1.
write: / 'Background process', lv_job_name ,
'called successfully' no-gap.
write: / 'You can check the job in transaction SM37'.
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7 -
Running ABAP Report in background
Hello,
I am getting timed out error when I execute my report program.
I believd running the report can do it for now.
Can you please tell me detils on how I should proceed on dev, qa and production environment.
Regards,
Sameer.Hello Sameer,
You need to schedule the ABAP program in SM36 transaction.
Following are the steps:
1. Fill general data like Job Name, Job class and click on step button from application menu
2. Fill ABAP program details on this screen like ABAP Report Name, Variant Name (If any) and save it.
3. Go to SM37 transaction (Background Job monitor)
4. On initial screen newly created job will be filtered by user name or using job name.
5. it will be listed in job queue with Scheduled status.
6. Select the Job from listing and click on Release button from application toolbar
7. depending on your requirement you can release job immediately and it will start running as an when background wp is allocated to this job.
8. Or else you can schedule it with some frequency using other options like Date/Time, or using other events to trigger it.
Check if this can help.
Thanks,
Augustin. -
Running abap programs using the macros
In our DP implementation we have faced several issues in the extraction of the data from the demand planning to one of the legacy system. We have written the ABAP program and would be using the read planning book bapi. I wanted to run the ABAP program using the macro could some one please let me know what is the structure of the macro builder that is used to fire the ABAP program. this is being fired from the macros as some comparison is to be done to run the macro.
Hi,
Some more information on macro function
REPORT_SUBMIT()
REPORT_SUBMIT( 'program_name' ; <'job_name'> ; <'job_number'>; <'newmode'>) causes the specified program to be executed. Use the optional arguments, job name and job number, if you wish the program to run in the background. If you set the argument 'newmode', the results are displayed in a new window.
Hope this will helps you.
Regards,
Sunitha. -
How tu run the program in background
Hi SapAll.
actually iam new to ABAP ,i just want to know on how i can run the particular program in background .
can any one explain me in steps .
i also want to know on how to delete the particular job which has been already created in sm36 .
will be waiting for best response.
regards.
VarmaHi
Find the below steps to be defined.
1. Go to SM36 -
> Give the Program Name
2. If you have priority defined that to in Job class
3. Click -
> Start Condition
4. Select Data/Time Tab
5. Give the Date and Time for the job execution. (If you want to certain intervale provide it) -
Running BDC program in background for the transaction VL02N
Hi All,
I have coded a BDC program (call transaction method) for the transaction code VL02N. I can able to run the program manually & successfully. But if I execute the program in background(SM36), it is going to dump giving CNTL_ERROR.
Note: I am not using any of the GUI_UPLOAD, GUI_DOWNLOAD funciton modules in the program. But I am using the FTP command funtion modules like( FTP_COMMAND, FTP_CONNECT, FTP_DISCONNECT and FTP_SERVER_TO_R/3).
<removed_by_moderator>
Thanks in advance.
Ramesh.
Edited by: Julius Bussche on Jul 8, 2008 5:55 PMVL02N is an enjoy transaction. You cant run it in background. Please try VL02.
Thanks
Romit -
Run java program in background
I want to run a java program in background in windowsXP...can anyone help please......can anyone suggest an easy software for running java program as windows service...i tried one but without any success
How many of the links here have you tried while you were waiting for an answer?
http://www.google.com/search?q=running+java+program+as+windows+service
(Note that the query is a direct copy/paste from your post.) -
How to run ABAP programs in another client?
Hi:
If one user wants to run his ABAP program that resides in Client 900 with the data in Client 500, can he do it? both the clients reside in the same SAP system (the same physical SAP server).
If you've some idea about this, please help.
Thuan NguyenHi Christoph:
Thanks a lot for your help on this.
If the Client 900 is for ABAP development (the user creates ABAP programs inside this client) and the Client 500 stores the data, can the user log in the client 500 and run his ABAP programs in Client 500?
Thanks
Thuan Nguyen -
Hello All,
I have selection screen where i have parameters for programs, classes and filename.
When i give program name and filename and execute. A Popup appears and asks the path for the file to be saved in xml format. This is done through foreground. It is working correctly in foreground and the file saves in xml format in specified location.
I have tried using the JOB Schedule for background but it is not working.
My requirement is to do the same process in background. How can i achieve the same process as foreground for the given programs and classes to save the file in xml format through background process.
Could anybody help me in this issue.
ThanksHello Indrakaran Reddy,
You cannot run the programs which involves the user intervention,pop-up displays etc., in the background mode.
For this, you need to have the file in the application server not on the desktop(presentation server).
Once, your file is in the application server, give the class and path of the file in the selection screen and then save it as a variant.
Then, schedule the program in the background using the transaction SM36.
This is how it works. Hope you understood the concept clearly.
Thanks,
Babu Kilari -
Problem in running a program in Background
Hi Guys,
Execution of a report interactively gave no errors. We tried to schedule job in background, with variants for the respective cases. But this resulted in the
following error in the joblog: "Error in function module POPUP_TO_CONFIRM"
I know this function module expects a user input.How can I supress this
dialog when I run the report in background.
Thanks and Regards,
Rajanyou have to check before the FM call is the report runs in background/foreground:
IF sy-batch IS INITIAL.
=> foreground, you cam call POPUP_TO_CONFIRM.
ELSE.
=> background
ENDIF. -
Running a program in background
Dear all,
I have to execute a database upload program in background while clicking a pushbutton.
Ho to do this ?
<b>note : No input parameters for the program</b>.when 'Update'.
perform update.
and in the perform , u have to put a logic to upload DB table.
Regards
Prabhu
Maybe you are looking for
-
Vendor Selection in Shopping Cart
Hi We are having nearly 20 company codes with in SAP and 5 company codes are using EBP. At the moment, all vendors designated for EBP are available when creating a shopping cart. Problem: User doesn't knows by looking at the vendor whether that vendo
-
ReWire?! Just doesnt seem to work!!!!
Following GarageBand help on rewiring Reason into GarageBand, the 'Reason Hardware Interface' module in Reason still says "Core Audio" rather than "ReWire". Anyone who uses Reason with the rewire feature going into another sequencer knows that this s
-
Freehand MX crashes when trying to open Freehand 10 files
Hello, I hope someone out there has some suggestions. I need to open some Freehand 10 documents in Freehand MX. When I try to open the FH10 files in Freehand MX it crashes. The icon it self looks like a blank page as if MX doesn't recognize it. I rei
-
How can I download gps-master in my macbook?
How can I download gps-master in my macbook? Thanks.
-
Where to find drivers for 3000 H210 / 5355AFU?
I don't see this system listed. I just bought it and would like to find the support link for both Vista and Windows 7 drivers. Is this system too new that they don't have it listed? Thanks