Technical Articles
Calling the Submit 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 the Report through Submit in OData service.
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: <lt_data> 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
SUBMIT zsubmit_demo81 WITH SELECTION-TABLE lt_seltab EXPORTING 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 <lt_data>.
MOVE-CORRESPONDING <lt_data> TO et_entityset.
ENDIF.
ENDMETHOD.
Step6: Go to the maintain services T-code ‘/n/iwfnd/maint_services‘ and execute it.
Step7: Find the project and execute it.
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.
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.
The scenario presented may be valid in very rare cases, 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.
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.
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 meesage RFC call ended with "System Failure" exception).
Can you please elaborate how you achieved Step 4 of your blog !!
Regards,
Bhavya