cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading images using SAP NW Gateway

Former Member
0 Kudos

Hi experts,

I'm working at a client who has images located on a network drive for their materials. A part of my job is to show the images that correspond to the material in a custom sap fiori application.

A material can have multiple images and the images are named by their material number ( ex.1000001). When a material has more photos they are named 1000001_01, 1000001_02 , ...

The directory is exposed via a file directory in AL11. So what i'm planning on doing is to try to read the images via OPEN DATASET ( check if there is an image and if so try to read a next one or not at all) based on a material number and return them somehow via an odata service to my application.

I saw some tutorials on how to expose an image but this was always done via a function module that got the image from SAP not from a network drive. In these tutorials they always returned 1 image because they used the getEntity method.

My question for you experts is how you would do this? And if it is possible to return multiple images( for one single material) via an odata service. Other solutions?

Kind regards,

Ian Desmet

Accepted Solutions (1)

Accepted Solutions (1)

kammaje_cis
Active Contributor
0 Kudos

That is right. At a time an OData URL can return only one image. If you need multiple images at a time, you can combine multiple requests in a $batch request.

Former Member
0 Kudos

Hi Krishna,

Thank you, I will use that ! Any idea on how to get files ( images here) from al11 and expose them via an odata service?

Kind regards,

Ian

kammaje_cis
Active Contributor
0 Kudos

Ripped from Sandra's response from here.

DATA binary TYPE xstring.

OPEN DATASET fullpath FOR INPUT IN BINARY MODE.

if sy-subrc = 0. 

   READ DATASET zfile INTO binary.

Copy this binary into response's xstring variable (in *DPC_EXT class GET_STREAM method).

Former Member
0 Kudos

Thank you krishna !

In the GET_STREAM method it should be something like this right?

ls_stream-value = ls_photo-content.                           <<<<<< Here i need to put the xstring response

        ls_stream-mime_type = ls_photo-mimetype.

        lv_filename = ls_photo-filename.

        lv_filename = escape( val = lv_filename

                              format = cl_abap_format=>e_url ).

        ls_lheader-name = 'Content-Disposition'.

        ls_lheader-value = |inline; filename="{ lv_filename }"|.

        set_header( is_header = ls_lheader ).

        copy_data_to_ref( EXPORTING is_data = ls_stream

                          CHANGING  cr_data = er_stream ).

Ripped from Peter Marcely from http://scn.sap.com/docs/DOC-56891.

Kind regards,

Ian Desmet


kammaje_cis
Active Contributor
0 Kudos

Yes, that is my understanding.

Former Member
0 Kudos

Thnx Krishna, I got it working !

Answers (0)