Execute a program via SUBMIT, with GUI suppression

user26652 picture user26652 · Oct 22, 2008 · Viewed 13.4k times · Source

I want to expose the functionality of an SAP program (transaction) as a BAPI. I need to call a report and supply range filters such that the GUI is bypassed.

Does anyone have a working example of the SUBMIT ... WITH ... ABAP construct, or other suggestions on how to accomplish what I need to do?

Answer

Esti picture Esti · Oct 23, 2008

Here is a working example:

SUBMIT SAPF140 
    TO SAP-SPOOL                         "optional"
    SPOOL PARAMETERS print_parameters    "optional"
    WITHOUT SPOOL DYNPRO                 "optional (hides the spool pop-up)"
    VIA JOB jobname NUMBER l_number      "optional"
    AND RETURN                           "optional - returns to the calling prog"
    WITH EVENT   =  REVENT
    WITH BUKRS   IN RBUKRS
    WITH BELNR   IN lRBELNR
    WITH GJAHR   IN RGJAHR
    WITH USNAM   =  SY-UNAME
    WITH DATUM   =  SAVE_DATUM
    WITH UZEIT   =  SAVE_UZEIT
    WITH DELDAYS =  RDELDAYS
    WITH KAUTO   =  'X'
    WITH RPDEST  =  SAVE_PDEST
    WITH TITLE   =  TITLE.

All the "WITH" statements relates to selection fields on the called program where I use = it is a PARAMETER statement (single field), where I use IN it is a SELECT_OPTIONS statement (range)

Here is a simple example of how to fill a range:

REFRESH lrbelnr.
lrbelnr-sign = 'I'.
lrbelnr-option = 'EQ'.
lrbelnr-low = HBKORM-belnr.
CLEAR lrbelnr-high.
append lrbelnr.