Application Development 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: 

Can a transaction be called in background dynamically using ABAP program??

Former Member
0 Kudos

Hi Experts,

Can a transaction be called in background dynamically using ABAP program without BDC???

Regards,

Mansi.

6 REPLIES 6

Former Member
0 Kudos

Hello SAPUSER,

Try this code..

REPORT  yh_sample.
PARAMETERS TCODE TYPE TCODE.
sy-batch = 'X'.
call transaction TCODE .

schedule this program in background using SM36 and give the variants.

Hope this helps you.

Indu.

0 Kudos

I cannot schedule the program in background since the program name wil change depending on the input from user.

So is it possible to call a program in background dynamically ??

0 Kudos

u can create job dynamically through programming..Try this sample code..

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 << Here it is a static call but u can make it dynamic

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.

Regards,

JOy.

0 Kudos

Hello sapuser,

Maybe you can try this for your requirement..

Try using the CALL FUNCTION <funct> IN BACKGROUND TASK.

This flags the function module funct to be run asynchronously. That is, it is not executed at once. Instead, the data passed using EXPORTING or TABLES is placed in a database table and the next COMMIT WORK executes it in another work process.

Hope it might help you

Regards

Indu.

BGarcia
Active Contributor
0 Kudos

Hello Mansi,

If it helps, I do that with SUBMIT statement (if applyable). But there, I don't call the transaction, but instead I call the program behind it.

Kind regards.

Bruno

Edited by: Bruno Garcia on Jul 14, 2008 11:19 AM

Former Member
0 Kudos

hi

good

I dont think you can call a Transaction Code in background without using the BDC.

Thanks

mrutyun^