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: 

How to Execuate Dialog program in backgroud

Former Member
0 Kudos

Hi,

I am doing with dialog program which going to save values in database using bapi, there is two buttons available in my program one is save and another one is background, when the user clicks save, values will be saved in online, suppose if the user clicks background, my dialog program should be run in background to store the values in database.

I appreciate if experts provide tips to overcome this issue.

3 REPLIES 3

Former Member
0 Kudos

hi,

normally in reports after checking i usually press F9 which takes care for background processing..Dont know abt dialog program how it works just have a try..

regards,

praveen

Former Member
0 Kudos

Hi ,

user PAI will be something like

when 'SAVE' .

         perform online 

when 'BGRN'.
        perform background.
       
form background.

Submit Zxxx using ....
and return . 

endform. 

say now u hit hte background button .

function code calls BGRN option and here my idea would be to call a report by submitting the data what you have in bapi.

use submit statement passing the content to this report so that a job is created and processed .

here the ZXXX report will be coded as

call function 'BAPI_********'

Hope this helps ..

regards,

vijay.

former_member189059
Active Contributor
0 Kudos

Hello,

Submit the same program in background mode and pass all the required parameters

*part for background processing
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 = 'ZPGM_NAME'. " your pgm name goes here

* used to avoid spaces in the display
DATA: lv_job_name_string TYPE string.
lv_job_name_string = lv_job_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  " parameters start here
        WITH p_lines = p_lines
        WITH rfc_dest = rfcdest
        WITH p_selmtd = lv_selmtd
        WITH px_shsim = px_shsim
        WITH px_sherr = px_sherr " parameters end here
        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_string , 'called successfully' NO-GAP.
  WRITE: / 'You can check the job in transaction SM37'.