---
title: "sap submit and return"
author: "evangxli"
date: "2011-04-13T19:47:38Z"
tags: []
categories: ["编程语言"]
slug: "sap-submit-and-return"
draft: false
lastmod: "2011-04-13T19:50:26Z"
id: 1002108
url: "https://sapabap.iteye.com/blog/1002108"
---

转自： [Barry 白](http://blogold.chinaunix.net/u1/40527/showart.php?id=1119919)
<span style="color:brown">SUBMIT的几种情况</span>
 
 
 
<span style="color:red">1、最普通的用法</span>

<span style="color:blue">*Code used to execute a report</span>
SUBMIT Zreport.


<span style="color:red">2、带select-options程序的Submit的用法</span>

<span style="color:blue">*Code used to populate 'select-options' & execute report</span>
DATA: seltab type table of rsparams,
      seltab_wa like line of seltab.

  seltab_wa-selname = 'PNPPERNR'.
  seltab_wa-sign    = 'I'.
  seltab_wa-option  = 'EQ'.

<span style="color:blue">* load each personnel number accessed from the structure into
* parameters to be used in the report</span>
  loop at pnppernr.
    seltab_wa-low = pnppernr-low.
    append seltab_wa to seltab.
  endloop.
  SUBMIT zreport with selection-table seltab
                                via selection-screen.

<span style="color:red">3、带parameters程序的Submit的用法</span>

<span style="color:blue">*Code used to populate 'parameters' & execute report</span>

 SUBMIT zreport with p_param1 = 'value'
                with p_param2 = 'value'.

<span style="color:red">4、其他情况</span>

<span style="color:blue">*Submit report and return to current program afterwards</span>


 SUBMIT zreport AND RETURN.

<span style="color:blue">*Submit report via its own selection screen</span>
 SUBMIT zreport VIA SELECTION-SCREEN.

<span style="color:blue">*Submit report using selection screen variant</span>
 SUBMIT zreport USING SELECTION-SET 'VARIANT1'.

<span style="color:blue">*Submit report but export resultant list to memory, rather than
<span style="color:blue">*it being displayed on screen</span></span>
 SUBMIT zreport EXPORTING LIST TO MEMORY.
<span style="color:blue">*  Once report has finished and control has returned to calling
*  program, use function modules LIST_FROM_MEMORY, WRITE_LIST and
*  DISPLAY_LIST to retrieve and display report.</span>

<span style="color:blue">*Example Code (Retrieving list from memory)</span>
DATA  BEGIN OF itab_list OCCURS 0.
        INCLUDE STRUCTURE abaplist.
DATA  END OF itab_list.

DATA: BEGIN OF vlist OCCURS 0,
        filler1(01)   TYPE c,
        field1(06)    TYPE c,
        filler(08)    TYPE c,
        field2(10)    TYPE c,
        filler3(01)   TYPE c,
        field3(10)    TYPE c,
        filler4(01)   TYPE c,
        field4(3)     TYPE c,
        filler5(02)   TYPE c,
        field5(15)    TYPE c,
        filler6(02)   TYPE c,
        field6(30)    TYPE c,
        filler7(43)   TYPE c,
        field7(10)    TYPE c,
      END OF vlist.

SUBMIT zreport EXPORTING LIST TO MEMORY.

CALL FUNCTION 'LIST_FROM_MEMORY'
  TABLES
    listobject = itab_list
  EXCEPTIONS
    not_found  = 4
    OTHERS     = 8.

CALL FUNCTION 'LIST_TO_ASCI'
  EXPORTING
    list_index         = -1
  TABLES
    listasci           = vlist
    listobject         = itab_list
  EXCEPTIONS
    empty_list         = 1
    list_index_invalid = 2
    OTHERS             = 3.

IF sy-subrc NE '0'.
  WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.
ENDIF.

<span style="color:red">5、Submit为后台执行</span>

<span style="color:blue">*Submit report as job(i.e. in background)</span>

data: jobname like tbtcjob-jobname value
                             ' TRANSFER TRANSLATION'.
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.

<span style="color:blue">* Job open</span>
  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.

<span style="color:blue">* Insert process into job</span>
 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.

<span style="color:blue">* Close job</span>
  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.