cancel
Showing results for 
Search instead for 
Did you mean: 

EXPORT INTERNAL TABLE TO EXCEL THROUGH ODATA SERVICE

shiva_krishna93
Explorer
0 Kudos

Hi all,

I have requirement that i have to export the entries from internal table to excel through ODATA for this  i created an FM ZTEST  using GUI_DOWNLOAD in that , which is working fine when we run the FM ZTEST but when we through the Odata Service the FM ZTEST  , GUI_DOWNLOAD is not getting triggered, it gives the sy-subrc = 6 which is an unknown error exception.Can you please suggest an alternative FM or help me get to the requirement ?

Accepted Solutions (0)

Answers (1)

Answers (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Shiva,

Not sure about what exactly is the scenario here as problem statement describes exporting data to excel through GW but you are also talking about using GUI_DOWNLOAD for uploading an excel as attachment. Being more specific on what is needed will help here.

I could not get if you want to upload an excel through GW, extract that data inside your ABAP code and use it further OR just download your internal table entries as an excel from GW.


However using GUI_DOWNLOAD will not work here for uploading. Its for SAP GUI only.

Below will give you some idea. Please have a look.

If at all, all you need is to simply download your internal table entries as excel through GW, then you just need to add ' $format=xlsx ' in your URI and GW itself will download the table entries as excel.

Excel Support - SAP Gateway Foundation (SAP_GWFND) - SAP Library

Sample -

/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection?$format=xlsx

Regards,

Ashwin

shiva_krishna93
Explorer
0 Kudos

Hello Ashwin,

Thanks for the reply.

To be more specific , user will click on the button download from UI5 .Button action is to generate the excel with the pre filled data coming form backend.Hope this clears your point.

AshwinDutt
Active Contributor
0 Kudos

Hello Shiva,

In that case i see 2 possible ways :

1. Assuming UI layer already holding data from Backend and now on click of button you would like to download as excel - Then no GW involvement here as GW has given data to your application and now UI layer should have some logic/code to download the already available data as excel.

2. Assuming UI layer does not holding data from backend and now on click of button you would like to download as excel - Then you can call the service directly ( as i shared in previous response - excel support in GW ) which will give back the data as part of excel.

Excel Support - SAP Gateway Foundation (SAP_GWFND) - SAP Library

Sample -

/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT/FlightCollection?$format=xlsx

Regards,

Ashwin