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 Program in Background

Former Member
0 Likes
9,996

Hi Friends,

I have a SAP standard program SDRQCR21 which has select-option S_DOCUS. I have written a custom program ZABCD where in I am extracting the data from VBBE and VBUK tables for getting the sales orders and passing it to the selection screen of SAP standard program. Till here it is working fine. But, I want to SUBMIT the SAP standard program in background and execute automatically to get my required output. I researched using F1 for SUBMIT command. But, I am little bit confused in submitting my SAP standard program in back ground. I would really appreciate if someone could help me how to do this.

Here is my code which I have written.

   SELECT VBBE~VBELN INTO TABLE GT_VBBE
                    FROM VBBE INNER JOIN VBUK ON VBBE~VBELN = VBUK~VBELN
                              WHERE VBBE~VBELN IN S_VBELN
                                AND VBBE~MATNR IN S_MATNR
                                AND VBBE~WERKS IN S_WERKS
                                AND VBBE~MBDAT IN S_MBDAT
                                AND VBUK~WBSTK IN S_WBSTK
                                AND VBUK~LFSTK IN S_LFSTK.

  IF NOT GT_VBBE IS INITIAL.

    CLEAR S_VBELN.
    REFRESH S_VBELN.

    LOOP AT GT_VBBE INTO WA_VBBE.
      S_VBELN-SIGN   = GC_I.
      S_VBELN-OPTION = GC_EQ.
      S_VBELN-LOW    = WA_VBBE-VBELN.
      APPEND S_VBELN TO S_VBELN.
    ENDLOOP.

   SUBMIT SDRQCR21 VIA SELECTION-SCREEN WITH S_DOCUS IN S_VBELN

   ENDIF.

ENDFORM.                    " SELECT_DATA

Thanks in Advance.

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
3,643

Put your submit between a JOB_OPEN and a JOB_CLOSE, use SUBMIT option of VIA JOB job NUMBER n. Look at FMs documentation or Abap online documentation like SUBMIT - job_options

Regards,
Raymond

Read only

0 Likes
3,643

Hello Raymond,

Thanks for the reply. Here is what I have done. But, I still can see the selection screen of SAP standard program SDRQCR21 (which I do not want.). On the selection screen, I am clicking SCHDULE JOB (which I want to be done automatically), then I am getting my reqired o/p.  Please advise.

   FORM SELECT_DATA.

  SELECT VBBE~VBELN INTO TABLE GT_VBBE
                    FROM VBBE INNER JOIN VBUK ON VBBE~VBELN = VBUK~VBELN
                              WHERE VBBE~VBELN IN S_VBELN
                                AND VBBE~MATNR IN S_MATNR
                                AND VBBE~WERKS IN S_WERKS
                                AND VBBE~MBDAT IN S_MBDAT
                                AND VBUK~WBSTK IN S_WBSTK
                                AND VBUK~LFSTK IN S_LFSTK.

  IF NOT GT_VBBE IS INITIAL.

    CLEAR S_VBELN.
    REFRESH S_VBELN.

    LOOP AT GT_VBBE INTO WA_VBBE.
      S_VBELN-SIGN   = GC_I.
      S_VBELN-OPTION = GC_EQ.
      S_VBELN-LOW    = WA_VBBE-VBELN.
      APPEND S_VBELN TO S_VBELN.
    ENDLOOP.

* Job open
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        JOBNAME          = GV_JOBNAME
      IMPORTING
        JOBCOUNT         = GV_JOBCOUNT
      EXCEPTIONS
        CANT_CREATE_JOB  = 01
        INVALID_JOB_DATA = 02
        JOBNAME_MISSING  = 03
        OTHERS           = 4.

    IF SY-SUBRC = 0.

* Insert process into job
      SUBMIT SDRQCR21 VIA SELECTION-SCREEN WITH S_DOCUS IN S_VBELN
                      VIA JOB GV_JOBNAME
                      NUMBER GV_JOBCOUNT
                      AND RETURN.

      IF SY-SUBRC = 0.

* Close job
        CALL FUNCTION 'JOB_CLOSE'
          EXPORTING
            JOBCOUNT             = GV_JOBCOUNT
            JOBNAME              = GV_JOBNAME
            STRTIMMED            = GC_X
          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.

        ENDIF.

      ENDIF.

    ENDIF.

  ENDIF.

ENDFORM.                    " SELECT_DATA

Thank you.

Read only

0 Likes
3,643

Hi

Remove VIA SELECTION SCREEN addition to avoid selection screen dispaly

SUBMIT SDRQCR21 WITH S_DOCUS IN S_VBELN

                      VIA JOB GV_JOBNAME

                      NUMBER GV_JOBCOUNT

                      AND RETURN.

Thanks,
Chandra

Read only

0 Likes
3,643

Yes, VIA SELECTION-SCREEN force display of the screen, where USING SELECTION-SCREEN only specifies the selection screen, so remove this option. (SUBMIT - selscreen_options)

Regards,
Raymond