Skip to Content
Technical Articles
Author's profile photo sreeram gottapu

要求提交Report/ Program through the Odata Service

Hi All,

All of you know the Alv report and OData service individually. Coming to this scenario some of the members don’t aware how to use theReportthroughSubmitinODataservice.

So I am trying to explain how do we use Submit report in Netweaver gate way services.

Note: Please follow the following steps

Create the custom program:

Step1: Go to t-code SE38

Step2 : Create one sample report with the required fields like below.

REPORT zsubmit_demo81.

** Data declarations
DATA: lv_vbeln TYPE vbeln_va,
o_alv TYPE REF TO cl_salv_table.

** Select options
SELECT-OPTIONS: s_vbeln FOR lv_vbeln.

** Get data
SELECT vbeln, posnr, matnr
FROM vbap
UP TO 10 rows
INTO TABLE @DATA(lt_vbap)
WHERE vbeln IN @s_vbeln .

** Assign internal table to method
cl_salv_table=>factory(
IMPORTING
r_salv_table = oval
CHANGING
t_table = lt_vbap ).

** Display Data
o_alv->display( ).

Execute :

Output:

Use the Report in OData service through SUBMIT :

Step3: Create the project with t-code ‘SEGW’.

Step4: Create the method and redefine it

Step5: Use the already created program SUBMIT as like below.

METHOD sales_detailset_get_entityset.

** Data declarations
DATA: lt_seltab TYPE TABLE OF rsparams,
ls_seltab LIKE LINE OF lt_seltab,
list_tab TYPE TABLE OF abaplist,
ls_data TYPE REF TO data.
FIELD-SYMBOLS: TYPE table.

** Passing the values
ls_seltab-selname = ‘S_VBELN’.
ls_seltab-kind = ‘S’.
ls_seltab-sign = ‘I’.
ls_seltab-option = ‘EQ’.
ls_seltab-low = ‘4970’.

** Disable the display and metadata
cl_salv_bs_runtime_info=>set(
display = abap_false
metadata = abap_false
data = abap_true ).

** Passing the i/p values to internal table
APPEND ls_seltab TO lt_seltab.

** Using the report through Submit
SUBMITzsubmit_demo81WITH SELECTION-TABLElt_seltabEXPORTING LIST TO MEMORY AND RETURN.

IF sy-subrc = 0.

** Getting the internal table data
cl_salv_bs_runtime_info=>get_data_ref(
IMPORTING r_data = ls_data ).

ASSIGN ls_data->* TO .
MOVE-CORRESPONDING TO et_entityset.

ENDIF.

ENDMETHOD.

Step6: Go to the maintain services T-code ‘/ n / iwfnd / maint_services‘ and execute it.

Step7: Find the project andexecuteit.

Note:Here we displayed the same data as like got the data in report

I hope it will be helpfull to you

Thanks,

Sreeram G.

Assigned Tags

      3 Comments
      You must beLogged onto comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      So, today we learned that calling a report by using SUBMIT command is in no way different in OData service than in any other program.

      It's nice of you to share but I feel it should be pointed out that building an OData "wrapper" around a custom ALV report is not a great idea, in general. This is how we work ourselves into more and more technical debt.

      We should have been separating UI and DB operations all along but, sadly, traditional ABAP development hasn't pushed anyone in that direction. In this scenario, data should've been served by a global class and this global class then could be utilized by both ALV report and OData service.

      展示的场景可能在非常罕见的c是有效的ases, such as calling a standard report when we can't / don't want to re-engineer its business logic. But this really should not be used with the custom reports. I'd rather update the ALV report itself to split the DB code from it than use this type of workaround, unless the client insists on inflicting such self-harm.

      Author's profile photo Sweta Gohil
      Sweta Gohil

      Dear Sreeram,

      Can you please explain what you have done in following steps for existing example you have taken.

      Step3: Create the project with t-code ‘SEGW’.

      Step4: Create the method and redefine it

      Thanks & Regards,

      Sweta Gohil.

      Author's profile photo Bhavya Garg
      Bhavya Garg

      Hi Sreeram,

      I created a Remote Function Module which I wrapped under an Odata service. It was working fine.

      But, as soon as I tried "Submit Report" statement inside my function Module, my OData service doesn't work anymore (and gives a meesageRFC call ended with "System Failure" exception).

      Can you please elaborate how you achieved Step 4 of your blog !!

      Regards,

      Bhavya