SUBMIT Statement in SAP ABAP (Updated for HANA)

SUBMIT is a keyword in SAP ABAP where you can use to execute an ABAP program within an another ABAP Program. There are multiple variations how you can use SUBMIT statement in SAP ABAP. For example, with different variations of SUBMIT statement syntax, you can define how to set Selection Screen parameters of the calling program, define if you want to execute the ABAP program in background mode, or if you want to save the list results to ABAP Memory.

SAP Versions used in the illustration:

  • SAP S4 HANA Fashion 1709

We need to identify there are two programs when we discuss SUBMIT function.

  1. Calling Program: ABAP program which calls or executes the external ABAP program. This is the ABAP program we will implement the SUBMIT statement code.
  2. Executed (Called) Program: The Executable program we will execute from the Calling Program.

Types of ABAP Programs You Can SUBMIT.

Executable ABAP programs are the only programs we can execute using SUBMIT statement. Before coding your calling program you need to first check the type of the program you intend to execute.

Find the Type of the ABAP Program via Transaction se38.

You identify the type of the ABAP program from attributes of the program in transaction se38. Go to transaction se38 and enter the name of the ABAP program and select ‘Attributes’ and choose Display.

Find the ABAP Program type from Attributes of transaction se38
Find the ABAP Program type from Attributes of transaction se38

 

Find the Type of the ABAP Program using Transaction Code.

Maybe you are only aware of the Transaction code, not the ABAP program name. To find the the program name, go to transaction to se93 (Maintain Transaction) and find the the program name in the next screen. Finally, go to Transaction se38 to identify the program type.

Choose Display option in Transaction se93 to find the the ABAP program name of a transaction
Choose Display option in Transaction se93

 

ABAP Program name of the Transaction Code displayed in transaction se93.
ABAP Program name of the Transaction Code

Syntax of ABAP SUBMIT Statement.

Syntax of the SUBMIT statement is as follows.

SUBMIT

<Executed (called) program name>

<Selection Screen options>

<Output list options>

<Background job options>

[AND RETURN].

 

Executed (called) Program Name.

This option defines the name of the Executed (called) program. This program should be of type “Executable” as discussed previously. You define the name of the Executed program as a variable or hard-code the program name. Use an variable to define the program name if the program name should be derived dynamically at run-time.

Selection Screen Options

Executed (called) program might have a Selection Screen. If you require to set the Selection Screen parameters of the Executed program, use this syntax option. Here you can supply the values to the Selection Screen fields of the Executed program from the Calling Program.

Output List Options

Using Output list options, we can define how to handle the output of the program. Using addition, EXPORTING LIST TO MEMORY you can save the list in ABAP memory. Addition TO SAP-SPOOL creates a new Spool request with the Executed output list.

Background Job Options

Addition VIA JOB syntax allow us to execute the program in background mode.

AND RETURN

If you specify AND RETURN, Executed program is started in a new internal session. After the Executed program has run has been completed, Calling Program continue after the SUBMIT statement. We use this addition if we need to sequence the execution of the Calling program and Executed program at run-time. 


Sample ABAP Programs with SUBMIT Statement.

Let’s call transaction FBL5N (program rfitemar) which is used to check customer open items. I will call this report for company code 3000 and key date as at today.

In this example Calling program name is ‘zcalling_program‘ and the Executed program name is ‘rfitemar‘.

Company code parameter name is ‘DD_BUKARS’ and Key date selection screen parameter name is ‘PA_STIDA’.

SAP Version Sample ABAP Code was Implemented.

  • SAP ABAP PLATFORM 1809
  • SAP S/4HANA 1809
  • SAP S/4HANA FOUNDATION 1809

SUBMIT with WITH SELECTION-TABLE.

REPORT zcalling_program.

DATA: li_selection  TYPE TABLE OF rsparams,
      lwa_selection TYPE rsparams.

*Setting values for selection screen field Company Code
CLEAR lwa_selection.
lwa_selection-selname = 'DD_BUKARS'.  "Company Code selection field name
lwa_selection-kind = 'S'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'EQ'.
lwa_selection-low = '3000'.            "Company Code value
APPEND lwa_selection TO li_selection.

*Setting values for selection screen field Open Items at Key Date
CLEAR lwa_selection.
lwa_selection-selname = 'PA_STIDA'. "Open Items at Key Date screen field name
lwa_selection-kind = 'S'.
lwa_selection-sign = 'I'.
lwa_selection-option = 'EQ'.
lwa_selection-low = sy-datum.         "Open Items at Key Date value as system date
APPEND lwa_selection TO li_selection.

SUBMIT rfitemar WITH SELECTION-TABLE li_selection AND RETURN.

SUBMIT with Setting Values for Individual Parameters.

Set the values of individual Selection Screen parameters using WITH addition.

SUBMIT rfitemar WITH dd_bukrs-low EQ '3000' WITH pa_stida EQ sy-datum.

Operators EQ|NE|CP|NP|GT|GE|LT|LE passes single values while BETWEEN passes ranges to the selection parameters. IN can be used to pass a range of values. To pass a range, create a internal table with RANGE OF addition.


SUBMIT with a Variant
.

Use the following syntax to call the program with a Variant ‘TEST_VARIANT_1’. Assign the Company Code and Key date values in the variant.

SUBMIT rfitemar USING SELECTION-SET 'TEST_VARIANT_1'.

Call Report and Export the List to Memory.

In this variation of SUBMIT, we call the program and export the output list to memory. Next we read the list from memory and write to screen.

REPORT zcalling_program.

DATA list_tab TYPE TABLE OF abaplist.

SUBMIT rfitemar USING SELECTION-SET 'TEST_VARIANT_1' EXPORTING LIST TO MEMORY
              AND RETURN.

*Read the output list of the program from memory.
CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = list_tab
  EXCEPTIONS
    not_found  = 1
    OTHERS           = 2.

IF sy-subrc = 0.
*Write list to memory
  CALL FUNCTION 'WRITE_LIST'
    TABLES
      listobject = list_tab.
ENDIF.

In this method you can export the result of the report output to memory. This memory can be read by function modules LIST_FROM_MEMORY, WRITE_LIST , and DISPLAY_LIST.

Export the SUBMIT List Results to Spool.

TO SAPSPOOL allow you to create a new Spool request with the results. In this method use Function Module ‘GET_PRINT_PARAMETERS’ to fetch the print parameters of the program.

REPORT zcalling_program_spool.

DATA: print_parameters TYPE pri_params,
      valid_flag       TYPE c.

*Get print parameters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
  EXPORTING
    report         = 'rfitemar'
  IMPORTING
    out_parameters = print_parameters
    valid          = valid_flag.

IF valid_flag <> space.
  SUBMIT rfitemar USING SELECTION-SET 'TEST_VARIANT_1' TO SAP-SPOOL WITHOUT SPOOL DYNPRO
                  SPOOL PARAMETERS print_parameters .
ENDIF.

New Spool request created will be displayed as a information message in the calling program. Go to transaction sp01 to view the created spool request.

New spool request created.
New spool request created.

 

Display spool request under transaction sp01
Display spool request under transaction sp01

Call Report (program) in Background Mode via a Batch Job.

Another important variation is executing a program in background mode. This calling program submit the executed program via a batch job named ‘SUBMIT_BATCHJOB’.

Addition VIA JOB can be only used with AND RETURN.

*&---------------------------------------------------------------------*
*& Report ZCALLING_PROGRAM_JOB
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zcalling_program_job.

DATA: job_number       TYPE tbtcjob-jobcount,
      job_name         TYPE tbtcjob-jobname VALUE 'SUBMIT_BATCHJOB',    "Batch job name
      print_parameters TYPE pri_params.

*Open batch job
CALL FUNCTION 'JOB_OPEN'
  EXPORTING
    jobname          = job_name
  IMPORTING
    jobcount         = job_number
  EXCEPTIONS
    cant_create_job  = 1
    invalid_job_data = 2
    jobname_missing  = 3
    OTHERS           = 4.

IF sy-subrc = 0.

*Call program in background via a batch job
  SUBMIT rfitemar USING SELECTION-SET 'TEST_VARIANT_1' VIA JOB job_name NUMBER job_number
                    AND RETURN.


  IF sy-subrc = 0.
    
*Close batch job
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = job_number
        jobname              = job_name
        strtimmed            = '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.

  ENDIF.
ENDIF.

Go to transaction sm37 to monitor the status of the background job created from the calling program.

Background job created from the SUBMIT calling program displayed in transaction sm37.
Background job created from the SUBMIT calling program.

If not specified, default behavior is Batch Job created under the login User and Logon language. You can change the Batch Job user name and language with additions USER and LANGUAGE to the SUBMIT statement.

Practical Issues with SUBMIT Statement.

Suppress Pop-up Windows.

Unfortunately, pop-up windows of Executed program cannot be suppressed in SUBMIT. This is an issue specially if the Executed program is a standard program. If you are calling a custom Z program, you can change the code or copy the program to a new program and change to code to accommodate SUBMIT function.


Have you come across other variations of SUBMIT statement that came in handy? If you have any questions on how to use SUBMIT statement in SAP ABAP, please leave a comment below.

6 thoughts on “SUBMIT Statement in SAP ABAP (Updated for HANA)

  1. Maruthi says:

    HI

    If any information is there ..the pop up coming and stoping the programme thereonly….how to do that
    with submit…

  2. Pubudu says:

    HI Isuru,

    im using submit with selection as follows,

    SUBMIT abc_pgm WITH SELECTION-TABLE li_selection AND RETURN.

    Question:
    How to over-ride default parameter in abc_pgm, when abc_pgm has following.
    Parameters: Test like Test default ‘X’.

    • Pubudu says:

      this is already in place.

      “Test
      CLEAR lwa_selection.
      lwa_selection-selname = ‘Test’.
      lwa_selection-kind = ‘P’.
      lwa_selection-low = abap_false .
      APPEND lwa_selection TO li_selection.

  3. Pubudu says:

    HI Isuru,

    im using submit with selection as follows,

    SUBMIT abc_pgm WITH SELECTION-TABLE li_selection AND RETURN.

    Question:
    How to over-ride default parameter in abc_pgm, when abc_pgm has following.
    Parameters: Test like Test default ‘X’.

    following is already in place,
    “Test
    CLEAR lwa_selection.
    lwa_selection-selname = ‘Test’.
    lwa_selection-kind = ‘P’.
    lwa_selection-low = abap_false .
    APPEND lwa_selection TO li_selection.

Leave a Reply

Your email address will not be published. Required fields are marked *