tags:

views:

1997

answers:

3

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?

+1  A: 

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.
Esti
Thanks, but this doesn't work. The particular program has a warning after selection, and trying this brings up the GUI to display the warning...
Which program/trans. are you calling? Submitting through a job id may allow you to bypass the warning, as it should write the warning to the job log. Alternatively SAP GUI has a user specific setting that allows you to turn off the pop-up for warnings (if the warning was implemented correctly).
Esti
A: 

If you want to suppress this functionality as a BAPI you have to wrap the functionality in a Remote Function Call (RFC) module. Just implement a RFC function module. Depending how the report is implemented, it may use ABAP objects, which can also be called from your RFC implementation. Given that case you have a quite good solution. Whenever the report is adjusted, also your BAPI will reflect the changes. In case it's a standard programm from SAP which cannot be wrapped, think about copying it into your namespace and adjusting it. Nevertheless this might give some hassle, when SAP performs an update via Support Package Stack and you won't realize it. The output of the two methods is different. Apart from that, if you want to call it from outside, there is nothing else possible than implementing a RFC module.

A submit report can not return the values outside. Reports are always only for GUI functionalities and not for exchanging data. In case your report uses select options, you somehow have to implement this feature "by hand" in your RFC, as this statements can not be used inside RFC modules. I would generally try to rework the report, modularize it and put the selection information in a central class or maybe another function module wich can be called from the report and your BAPI function module. The filters you are talking about can not be implemented in RFCs automatically. You have to implement those ranges manually. The warning which comes up cannot be suppressed, if you do a RFC call from a remote system and the popup with the warning comes up you'll end with a shortdump. Therefore, you have to rework the report and to re-implement it for your needs.

If you are just looking for bypassing it via job scheduling, create a variant and schedule the report with that variant but I suppose that's not the solution you're looking for.

Matthias Kneissl
A: 

You can use inbuilt BAPI also just write "Range" and press F4.

rahul