Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Submit a program to execute in background.

Former Member
12,380

Hi Everyone,

Is there a way to submit a program to execute in background. So that the runtine is fast. Any help on this will be great.

Thanks,

Prabhu.

15 REPLIES 15
Read only

Former Member
0 Likes
3,549

Hi,

If you are looking to execute one program from another use SUBMIT statment.

If you are looking to execute the program in background, schedule that program as a background job using SM36. Using this you can schedule jobs in various ways (daily, weekly, start time, etc.,)

Deepak

Read only

0 Likes
3,549

Hi Deepak,

I actually have selection screen program, wherein if i press the pushbutton, it calls a form, i want to execute this form in background, how do i do this. Could u please suggest me the best method.

Thanks,

Prabhu.

Read only

0 Likes
3,549

Hi,

Since you are asking about to submit a form in background,I suggest to you to create a report containing the form.Then export necessary parameters for that report from the first report.Then submit the report which contains the form.I hope you know that how to submit a report it background.Then import the parameters from the form.

Read only

0 Likes
3,549

Hi,

I tried the submit, Here's the code what i did,

<b>

Form xxxx.

submit report1 and return.

perform yyy.

endform.</b>

So the form which i wanted to execute in background, i created that in a seperate program and execute it, it works well, and in the program where i wanted to execute that one in a form i submitted that as shown above. but it does not work.

Then how else should i give.

Any help will be great.

Thanks,

Prabhu.

Read only

0 Likes
3,549

I believe that we talked about calling a form in the background the other day. I suggested putting your code in a RFC function module and kicking it off to the background. Did this not work for you? Or are you trying to acheive something different?

Regards,

Rich Heilman

Read only

0 Likes
3,549


Form xxxx.

submit report1 and return.
perform yyy.

endform.

Your code above will not do anything in the background. It is just running the code inside of the "REPORT1" program in the same task that the calling program is running in.

Regards,

Rich Heilman

Read only

0 Likes
3,549

Hi Rich,

I created a RFC function module but it did not work, my requirement is i must not use RFC so without that is it possible to execute it background.

Thanks,

Prabhu.

Read only

0 Likes
3,549

Is your requirement that....

User presses pushbutton on selection screen, a form(subroutine) is triggered, which submits some report which is to be sent to background task so that the calling program can continue with its own processing.

Is this your requirment, if so, you do no that once to fire the code to a background task, that it has been disconnected from the caller and you will not be able to retrieve any data from that program running in background.

When you are submitting a program inside your form. All you are doing is running that program in the same task as the caller.

For example.

1) Caller program is running.

2) Caller program submits a program.

3) Caller program is waiting for the submitted program to finish.

4) When the submitted program is finished, then the caller program continues processing its own code.

Regards,

Rich Heilman

Regards,

Rich Heilman

Read only

0 Likes
3,549

Hi Rich,

My requirement is as u have told.

1) Caller program is running.

2) Caller program submits a program.

3) Caller program is waiting for the submitted program to finish.

4) When the submitted program is finished, then the caller program continues processing its own code.

The form which has to execute in background inserts records in the table. Then I have another pushbutton which will access this table to display the records as per the user's selection options.

So my question is why should i enable it as RFC, is there not any way to execute the form in background. in my program.

Thanks,

Prabhu.

Read only

0 Likes
3,549

Hi Prabhu,

As per the program flow you confirmed, your program is synchronous in nature. Thus, you have to wait for the results before you can continue.

In this case, running your report in background (workprocess) will not work since this will change the nature of your program to asynchronous. Then your program will not wait for the results. Take a look at the documentation for CALL FUNCTION...IN BACKGROUND TASK | UPDATE TASK | and STARTING NEW TASK.

See if these help. Do get back if you have further queries.

Regards

Read only

Former Member
0 Likes
3,549

If you want to create a job to run in the background from an ABAP, look at function group BTCH , particularly FM simple_batch_job_submit.

Rob

Read only

sridevi_p
Active Contributor
0 Likes
3,549

Hi,

Check this code -

*Submit report as job(i.e. in background)

data: jobname like tbtcjob-jobname value

' TRANSFER TRANSLATION'.

data: jobcount like tbtcjob-jobcount,

host like msxxlist-host.

data: begin of starttime.

include structure tbtcstrt.

data: end of starttime.

data: starttimeimmediate like btch0000-char1.

  • Job open

call function 'JOB_OPEN'

exporting

delanfrep = ' '

jobgroup = ' '

jobname = jobname

sdlstrtdt = sy-datum

sdlstrttm = sy-uzeit

importing

jobcount = jobcount

exceptions

cant_create_job = 01

invalid_job_data = 02

jobname_missing = 03.

if sy-subrc ne 0.

"error processing

endif.

  • Insert process into job

SUBMIT zreport and return

with p_param1 = 'value'

with p_param2 = 'value'

user sy-uname

via job jobname

number jobcount.

if sy-subrc > 0.

"error processing

endif.

  • Close job

starttime-sdlstrtdt = sy-datum + 1.

starttime-sdlstrttm = '220000'.

call function 'JOB_CLOSE'

exporting

event_id = starttime-eventid

event_param = starttime-eventparm

event_periodic = starttime-periodic

jobcount = jobcount

jobname = jobname

laststrtdt = starttime-laststrtdt

laststrttm = starttime-laststrttm

prddays = 1

prdhours = 0

prdmins = 0

prdmonths = 0

prdweeks = 0

sdlstrtdt = starttime-sdlstrtdt

sdlstrttm = starttime-sdlstrttm

strtimmed = starttimeimmediate

targetsystem = host

exceptions

cant_start_immediate = 01

invalid_startdate = 02

jobname_missing = 03

job_close_failed = 04

job_nosteps = 05

job_notex = 06

lock_failed = 07

others = 99.

if sy-subrc eq 0.

"error processing

endif.

URL: http://www.sapdevelopment.co.uk/reporting/rep_submit.htm

Hope this code snippet helps you!

Read only

Former Member
0 Likes
3,549

Could you do something like:

Program1 submits program2

exporting list to memory

and return.

Program2 does whatever it does and produces a list

Program1 (after the submit statement) runs the FM LIST_FROM_MEMORY and tests the contents of the list to make sure everything is OK.

Program 1 then continues.

Rob

Read only

Former Member
0 Likes
3,549

FM LIST_FROM_MEMORY will retrieve the list from program1, but it won't be in a readable format. After calling that, you can call FM LIST_TO_TXT. This will convert the list to something you can test.

Rob

Read only

Former Member
0 Likes
3,549

hai

In use tcode se38 Abap report ...There is an option in the menu... to execute the report pgm as background process

...use that for background scheduling of reports