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 Report and execute pushbutton, in background

former_member201275
Active Contributor
3,044

I have a program, PGM_A, which when executed runs another program PGM_B, which outputs a list and a number of pushbuttons along the top one named 'TEST' and the other 'UPDATE'.

I want to be able to run PGM_A in background mode in such a way that it executes PGM_B and executes the code for the pushbutton 'UPDATE'.

Is this done with, in PGM_A, Submit PGM_B with param = 'UPDATE'?

All help greatly appreciated!

1 ACCEPTED SOLUTION
Read only

Nawanandana
Active Contributor
1,911

Hi,

Try bellow code .

 PROGRAM test.

  DATA : v_jobhead      LIKE tbtcjob.
  DATA : v_jobcount     LIKE tbtcjob-jobcount.
  DATA : v_eventparm    LIKE tbtcjob-eventparm.
  DATA : v_flg_released TYPE c.
  DATA : e_error.
  DATA : running        LIKE tbtcv-run.


  TYPES: esp1_boolean   LIKE boole-boole.


  CONSTANTS: esp1_false TYPE esp1_boolean VALUE ' ',
             esp1_true  TYPE esp1_boolean VALUE 'X'.

  CONSTANTS: lv_true    TYPE boolean VALUE esp1_true,
             lv_false   TYPE boolean VALUE esp1_false.


  DATA      : v_jobnam  LIKE tbtcjob-jobname VALUE 'ZPGM_A', "Background Job Name
              v_report  LIKE sy-repid        VALUE 'PGM_B', "Second program name which you need to run on background 
              v_varian  LIKE raldb-variant,
              v_uname   LIKE sy-uname.

  v_uname = sy-uname.
*  v_varian = sy-slset.
* Add the new job
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
*     delanfrep        = 'X'
      jobname          = v_jobnam
    IMPORTING
      jobcount         = v_jobcount
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.


  IF sy-subrc <> 0.
    e_error = 'X'.
    MESSAGE 'Background job scheduling fail' TYPE 'E'.
    EXIT.
  ELSE.

    CALL FUNCTION 'JOB_SUBMIT'
      EXPORTING
        authcknam               = v_uname
        jobcount                = v_jobcount
        jobname                 = v_jobnam
        report                  = v_report
        variant                 = v_varian
      EXCEPTIONS
        bad_priparams           = 1
        bad_xpgflags            = 2
        invalid_jobdata         = 3
        jobname_missing         = 4
        job_notex               = 5
        job_submit_failed       = 6
        lock_failed             = 7
        program_missing         = 8
        prog_abap_and_extpg_set = 9
        OTHERS                  = 10.
    IF sy-subrc <> 0.
      MESSAGE 'Background job scheduling fail' TYPE 'E'.
      EXIT.
    ELSE.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
*         EVENT_ID             = IC_WWI_WORKPROCESS_EVENT
*         EVENT_PARAM          = V_EVENTPARM
*         EVENT_PERIODIC       = 'X'
          jobcount             = v_jobcount
          jobname              = v_jobnam
          strtimmed            = 'X'
        IMPORTING
          job_was_released     = v_flg_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 sy-subrc <> 0.
        MESSAGE 'Background job scheduling fail' TYPE 'E'.
        EXIT.
      ELSE.
        MESSAGE 'Background job scheduled' TYPE 'S'.
      ENDIF.
    ENDIF." job submit
  ENDIF. "jon open
5 REPLIES 5
Read only

Nawanandana
Active Contributor
1,912

Hi,

Try bellow code .

 PROGRAM test.

  DATA : v_jobhead      LIKE tbtcjob.
  DATA : v_jobcount     LIKE tbtcjob-jobcount.
  DATA : v_eventparm    LIKE tbtcjob-eventparm.
  DATA : v_flg_released TYPE c.
  DATA : e_error.
  DATA : running        LIKE tbtcv-run.


  TYPES: esp1_boolean   LIKE boole-boole.


  CONSTANTS: esp1_false TYPE esp1_boolean VALUE ' ',
             esp1_true  TYPE esp1_boolean VALUE 'X'.

  CONSTANTS: lv_true    TYPE boolean VALUE esp1_true,
             lv_false   TYPE boolean VALUE esp1_false.


  DATA      : v_jobnam  LIKE tbtcjob-jobname VALUE 'ZPGM_A', "Background Job Name
              v_report  LIKE sy-repid        VALUE 'PGM_B', "Second program name which you need to run on background 
              v_varian  LIKE raldb-variant,
              v_uname   LIKE sy-uname.

  v_uname = sy-uname.
*  v_varian = sy-slset.
* Add the new job
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
*     delanfrep        = 'X'
      jobname          = v_jobnam
    IMPORTING
      jobcount         = v_jobcount
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.


  IF sy-subrc <> 0.
    e_error = 'X'.
    MESSAGE 'Background job scheduling fail' TYPE 'E'.
    EXIT.
  ELSE.

    CALL FUNCTION 'JOB_SUBMIT'
      EXPORTING
        authcknam               = v_uname
        jobcount                = v_jobcount
        jobname                 = v_jobnam
        report                  = v_report
        variant                 = v_varian
      EXCEPTIONS
        bad_priparams           = 1
        bad_xpgflags            = 2
        invalid_jobdata         = 3
        jobname_missing         = 4
        job_notex               = 5
        job_submit_failed       = 6
        lock_failed             = 7
        program_missing         = 8
        prog_abap_and_extpg_set = 9
        OTHERS                  = 10.
    IF sy-subrc <> 0.
      MESSAGE 'Background job scheduling fail' TYPE 'E'.
      EXIT.
    ELSE.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
*         EVENT_ID             = IC_WWI_WORKPROCESS_EVENT
*         EVENT_PARAM          = V_EVENTPARM
*         EVENT_PERIODIC       = 'X'
          jobcount             = v_jobcount
          jobname              = v_jobnam
          strtimmed            = 'X'
        IMPORTING
          job_was_released     = v_flg_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 sy-subrc <> 0.
        MESSAGE 'Background job scheduling fail' TYPE 'E'.
        EXIT.
      ELSE.
        MESSAGE 'Background job scheduled' TYPE 'S'.
      ENDIF.
    ENDIF." job submit
  ENDIF. "jon open
Read only

0 Likes
1,911

Thank you for your answer.

The PGM_A has a selection screen which I will fill out, and then I will choose, from the Menu Options, execute in background. And then inside PGM_A I need to execute PGM_B which should then force the opcode for 'UPDATE' push button.

Can I send the value of which Push Button to select via JOB_SUBMIT?

Read only

0 Likes
1,911

Hi,

If you need to pass parameters as well , no need to call JOB_SUBMIT FM. but other two FM have to call . Look at bellow sequnce

1. CALL FUNCTION 'JOB_OPEN'

2. SUBMIT PGM_B AND RETURN
        WITH p_ifux = p_ifux
        WITH p_ofux = p_ofux
        WITH p_acc  = p_acc
        WITH p_payr = p_payr
        USER sy-uname
     VIA JOB v_jobnam
      NUMBER v_jobcount.

3 .CALL FUNCTION 'JOB_CLOSE'
Read only

Sandra_Rossi
Active Contributor
1,911

Did you try batch input (call transaction ... using .../SHDB)?

Read only

former_member226519
Active Contributor
1,911

I'm afraid, not. You cannot store a pressed button in a variant, can you?

maybe you can add a hidden parameter in PGM_B an pass this.

PGM_B:

parameters: p_upd as checkbox no-display.
if p_upd = 'X'.
  perform my_code.
endif.