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: 

SUBMIT program VIA JOB and SET/GET parameter

joo_gaia
Explorer
0 Kudos

Hi All

I need to pass the content of a variable from the program 'A' to program 'B'.

Program A uses JOB_OPEN , SUBMIT program VIA JOB jobname NUMBER jobnumber AND return, JOB_CLOSE.

I tried to use import/export memory but it didn't work. Then I am trying to use set/get parameters but it also did not work.

Program A is going to run in any server and program B will run in the central instance (it is determined in the FM JOB_CLOSE, parameter target_server).

Program does not have selection-screen.

Is it possible use set/get parameter with submit via job?

Could you please advise?

Thanks in advance.

João Gaia

1 ACCEPTED SOLUTION

Former Member

Here a simple code

*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
                             'TRANSFER DATA'.
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 value 'X'.

* 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.

Then... for import/export of a variable, you can use Import Memory and Export Memory function.

Like this:

REPORT A:
  IF NOT it_dlist_out IS INITIAL.
    EXPORT it_dlist_out TO MEMORY ID 'TEST1234'.
  ELSE.
* Clearing memory
    FREE MEMORY ID 'TEST1234'.
  ENDIF.

REPORT B:
IMPORT it_dlist_out TO lt_dlist_out FROM MEMORY ID 'TEST1234'.

Edited by: spantaleoni on Jan 11, 2011 3:21 PM

Edited by: spantaleoni on Jan 11, 2011 3:23 PM

5 REPLIES 5

Former Member
0 Kudos

Hello,

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

archive_mode = c_archive

destination = syst-pdest

IMPORTING

out_archive_parameters = l_archi_parameters

out_parameters = l_print_parameters

valid = l_valflag

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

SUBMIT (x_txw_c_v0-view_prog) TO SAP-SPOOL

SPOOL PARAMETERS l_print_parameters

ARCHIVE PARAMETERS l_archi_parameters

WITHOUT SPOOL DYNPRO

VIA JOB l_jobname NUMBER l_jobnumber

AND RETURN.

Thanks.

Ramya.

Former Member

Here a simple code

*Submit report as job(i.e. in background)
data: jobname like tbtcjob-jobname value
                             'TRANSFER DATA'.
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 value 'X'.

* 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.

Then... for import/export of a variable, you can use Import Memory and Export Memory function.

Like this:

REPORT A:
  IF NOT it_dlist_out IS INITIAL.
    EXPORT it_dlist_out TO MEMORY ID 'TEST1234'.
  ELSE.
* Clearing memory
    FREE MEMORY ID 'TEST1234'.
  ENDIF.

REPORT B:
IMPORT it_dlist_out TO lt_dlist_out FROM MEMORY ID 'TEST1234'.

Edited by: spantaleoni on Jan 11, 2011 3:21 PM

Edited by: spantaleoni on Jan 11, 2011 3:23 PM

0 Kudos

Hi spantaleoni

Thanks a lot! Problem solved with your example.

Regards

João Gaia

0 Kudos

Hi spantaleoni

Thanks a lot! Problem solved with your example.

Regards

João Gaia

Former Member
0 Kudos

Hi Joao,

For using EXPORT/IMPORT use below syntax,

If internal table needs to be exported then in Program A

EXPORT gi_final TO MEMORY ID 'GI_DATA'.

In Program B use

IMPORT gi_final TO gi_final1 FROM MEMORY ID 'GI_DATA'.

(Here gi_ginal1 will have same type as of gi_final).

Hope this helps you.

Best Regards,

Akanksha.