cancel
Showing results for 
Search instead for 
Did you mean: 

Odata download file problem getstream

user4sap
Participant
0 Kudos
I have an oData service for File Download functionality. I have to include $value parameter to oData call to trigger GET_Stream at backend.
I see when I set a external breakpoint on get_stream method, that I the method is triggered. But the file download doesnt work. I get a http response 200 which means it is all ok but I dont see any data or row of information. Nothing it is empty the gw client response.
So I debug and see that at the end of the get_stream method there is a parameter changing with these lines:
COPY_DATA_TO_REF(
EXPORTING IS_DATA = LS_STREAM
CHANGING CR_DATA = ER_STREAM)

So in ls_stream there should two columns (column1 and cloumn2)
One of the columns is set and the other is empty. No matter what I do what for value I give to column2 it is still empty. Maybe I dont get any information at gw client request because of the parameter column2 is empty? Can you give me a suggestion?

My redefined methods are:
_DPC_EXT:
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM
FileSET_GET_ENTITYSET

_MPC_EXT:

DEFINE

View Entire Topic
rahulkumar_sankla
Participant

Hi,

Column1 should have the mime type of the attachment. I hope you are filling it correctly. Column2 should have binary content of the file itself. without the binary content, the file will not be downloaded/display.

COPY_DATA_REF only copies the content of the structure to a data reference and so should never lose data at all in the ER_STREAM while using this method.

Also set the file name in the header response as well. you can use the code below:

define the variables as

ls_stream TYPE ty_s_media_resource,

ls_response_header TYPE ihttpnvp,
lv_filename TYPE string.

user4sap
Participant
0 Kudos

Hey thx firstly. Now, your code seems similar to my code. I have here one ls_stream data that I write it at the end of coding in COPY_DATA_REF. But I see there is a problem with my ls stream. the value doesnt assigned correctly to my ls_stream variable. Here is the screenshot.

And I saw that the technical type of Mime_type is CString and the technical type of VALUE is XSTRING. So I have implemented a before copy_data_ref another Function. This converting Function but it doesnt work. After this I still dont get a value into ls_stream. But I have to say that I dont give the lv_xstring a value somewhere before that function

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_length
IMPORTING
buffer = lv_xstring
TABLES
binary_tab = lt_data.

ls_stream-value = lv_xstring.

Sandra_Rossi
Active Contributor
0 Kudos

user4sap What contains lv_length and lt_data just before CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'? lv_length indicates the number of bytes to transfer from lt_data to lv_xstring. Moreover, be careful, only the first component of lt_data is transferred (for example, declare lt_data of type SOLIX_TAB or SDOKCNTBINS which have lines with only one component).

user4sap
Participant
0 Kudos

Hey thx. I add the code here from getstream. I want to say if I not commented the part of CALL FUNCTION 'SCMS_AO_TABLE_GET' then the gwclient give me a Error Internal Server error 500. If comment it the code runs and I get from gwclient 200 but without an result, empty screen

METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
   DATA: ls_stream          TYPE /iwbep/if_mgw_appl_types=>ty_s_media_resource,
            ls_entity          TYPE zcl_porder_doc_mpc=>ts_attachment,
            ls_images          TYPE toa01,
            lt_images          TYPE TABLE OF toa01,
            lv_xstring         TYPE xstring,
            ls_lheader         TYPE ihttpnvp,
            lv_filename        TYPE string,
            lv_length          TYPE i,
            lt_data            TYPE TABLE OF tbl1024,
            ls_archive         TYPE toa01,
            lv_porder_id TYPE saeardoid,
            lv_doctype         TYPE saearoname.
  FIELD-SYMBOLS:<fs_key> TYPE /iwbep/s_mgw_name_value_pair.
  READ TABLE it_key_tab ASSIGNING <fs_key> INDEX 1.
  lv_porder_id = <fs_key>-value.

  SELECT SINGLE * FROM toa01 INTO CORRESPONDING FIELDS OF ls_archive WHERE arc_doc_id = lv_porder_id .
  IF sy-subrc NE 0.
    mo_context->get_message_container( )->add_message_text_only( iv_msg_type = 'E'
                                                                 iv_msg_text = 'Document not found.' ).
    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
      EXPORTING
        message_container = mo_context->get_message_container( ).
  ENDIF.

*  CALL FUNCTION 'SCMS_AO_TABLE_GET'
*   EXPORTING
*      arc_id  = ls_archive-archiv_id
*      doc_id  = lv_porder_id 
*      comp_id = ' '
*    IMPORTING
*      length  = lv_length
*    TABLES
*      data    = lt_data.
*  IF sy-subrc NE 0.
*    mo_context->get_message_container( )->add_message_text_only( iv_msg_type = 'E'
*                                                                 iv_msg_text = 'Document not found.' ).
*    RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
*      EXPORTING
*        message_container = mo_context->get_message_container( ).
*  ENDIF.

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
    EXPORTING
      input_length = lv_length
    IMPORTING
      buffer       = lv_xstring
    TABLES
      binary_tab   = lt_data.

  ls_stream-value = lv_xstring.

  IF ls_archive-reserve = 'FAX'.
    ls_archive-reserve = 'PDF'.
  ENDIF.
  ls_stream-mime_type = ls_archive-reserve.
  TRANSLATE ls_stream-mime_type TO LOWER CASE.

  SELECT SINGLE objecttext FROM toasp INTO lv_doctype WHERE ar_object = ls_images-ar_object AND language = sy-langu.
  IF sy-subrc IS NOT INITIAL.
    lv_filename = 'Invoice'.
  ENDIF.
  CONCATENATE lv_doctype ls_archive-object_id INTO lv_filename SEPARATED BY space.

  lv_filename = escape( val = lv_filename
                    format = cl_abap_format=>e_url ).

  ls_lheader-name = 'Content-Disposition'.
  CONCATENATE 'inline; Filename="' lv_filename '.' ls_stream-mime_type '";' INTO ls_lheader-value.

  set_header( is_header = ls_lheader ).

  copy_data_to_ref( EXPORTING is_data = ls_stream
      CHANGING cr_data = er_stream ).
ENDMETHOD.<br>

I debug now and saw that lv_length and lt_data contains 0 values before CALL FUNCTION 'SCMS_BINARY_TO_XSTRING and after that function until copydataref. And I think my problem is that my ls_stream contains 0 values too as the code arrives the copy_data_ref. This screenshot is from the state when copy_data_ref is arrived.

rahulkumar_sankla
Participant
0 Kudos

Try the following code. BTW, I have hardcoded the value for l_porder_id, so you need to change it.

DATA: l_porder_id        TYPE saeardoid VALUE 'E0C23141BA9246F1B0A50014C2585EB9',
      ls_archive         TYPE toa01,
      c_len              TYPE sapb-length VALUE '999999999',
      l_bound_size_alloc TYPE abap_msize,
      lt_archive         TYPE TABLE OF docs,
      lt_binary          TYPE TABLE OF tbl1024,
      l_size             TYPE i,
      l_content          TYPE xstring,
      l_doctype          TYPE toadd-doc_type,
      l_extension        TYPE sdok_fnext,
      ls_lheader         TYPE ihttpnvp,

DATA: ls_stream TYPE /iwbep/if_mgw_appl_types=>ty_s_media_resource.

SELECT SINGLE * FROM toa01 INTO CORRESPONDING FIELDS OF @ls_archive WHERE arc_doc_id = @l_porder_id .
IF sy-subrc IS INITIAL.
  IF ls_archive-reserve = 'FAX'.
    ls_archive-reserve = 'PDF'.
  ENDIF.

  l_doctype = ls_archive-ar_object.

  "Get binary format of attached PDF
  CALL FUNCTION 'ARCHIVOBJECT_GET_BYTES'
    EXPORTING
      archiv_id                = ls_archive-archiv_id
      archiv_doc_id            = ls_archive-arc_doc_id
      document_type            = l_doctype
      length                   = c_len
      offset                   = 0
    TABLES
      archivobject             = lt_archive
      binarchivobject          = lt_binary
    EXCEPTIONS
      error_archiv             = 1
      error_communicationtable = 2
      error_kernel             = 3
      OTHERS                   = 4.
  IF lt_archive IS NOT INITIAL AND sy-subrc = 0 AND lt_binary IS NOT INITIAL.

    l_extension = to_lower( ls_archive-reserve ).

    SELECT SINGLE * FROM sdokmime INTO @DATA(l_ext) WHERE extension = @l_extension.

    CALL METHOD cl_abap_memory_utilities=>get_memory_size_of_object
      EXPORTING
        object           = lt_binary
      IMPORTING
        bound_size_alloc = l_bound_size_alloc.

    l_size = l_bound_size_alloc.

    CLEAR l_content.
* Convert the current table entries to line of XSTRING format
    CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
      EXPORTING
        input_length = l_size
      IMPORTING
        buffer       = l_content
      TABLES
        binary_tab   = lt_binary
      EXCEPTIONS
        failed       = 1
        OTHERS       = 2.
    IF sy-subrc IS INITIAL.

      ls_stream-mime_type = l_ext-type.
      ls_stream-value = l_content.

  SELECT SINGLE objecttext FROM toasp INTO @data(lv_doctype) WHERE ar_object = @ls_archive-ar_object AND language = @sy-langu.
  IF sy-subrc IS NOT INITIAL.
    data(lv_filename) = 'Invoice'.
  ENDIF.
  CONCATENATE lv_doctype ls_archive-object_id INTO lv_filename SEPARATED BY space.

  lv_filename = escape( val = lv_filename
                    format = cl_abap_format=>e_url ).

  ls_lheader-name = 'Content-Disposition'.
  CONCATENATE 'inline; Filename="' lv_filename '.' ls_stream-mime_type '";' INTO ls_lheader-value.

  set_header( is_header = ls_lheader ).

  copy_data_to_ref( EXPORTING is_data = ls_stream
      CHANGING cr_data = er_stream ).

    ENDIF.

  ENDIF.
ENDIF.

data in ls_stream is in the screenshot below:

Sandra_Rossi
Active Contributor
0 Kudos
user4sap

I guess you mean that your issue is only with SCMS_AO_TABLE_GET, not with OData service.

Try with this Test PDF below (to replace both SCMS_AO_TABLE_GET and SCMS_BINARY_TO_XSTRING) just to make sure this Test PDF displays correctly via gw client:

  DATA lv_pdf_hex TYPE STRING.
* PDF from http://www.tagg.org/pdftest.pdf University of Liverpool CONCATENATE '255044462D312E32200D0A25E2E3CFD30D0A200D0A392030206F626A0D0A3C3C0D0A2F4C656E677468203130203020520D0A' '2F46696C746572202F466C6174654465636F6465200D0A3E3E0D0A73747265616D0D0A4889CD90D14AC33014869F20EFF07B' 'A7B266E7244D93ED6ED216062D148D82901B115B266A658AE2DBDBA40CF17E822417C9C9FF7DC9C98517AC496A05ABACCC73' 'C0978210C77E8058D6042D5D2CF78224591B97F7D329FC274EAB7508AD31219C84C05619D93F9FC13F0A9E62315262629CD2' '89C948B25BB99954443A239E26D8ADD9CC58AEA6F80F69E7BB24716E66AC83BF1B8605B65DBBC0F5CBEEE361FFB67BFFC2D8' 'A3899BD7717C4AAA4C73115D9951D21449B8AC196AEE8425AF8C39D8E960DFE0A6BABCC555BB691A74658D7ADB249B92DA16' 'BF1A4F6542C6C492D2AFE1B852E5FE407ADC97FAF3FF67AABCF8063CF5A1AA0D0A656E6473747265616D0D0A656E646F626A' '0D0A31302030206F626A0D0A3234360D0A656E646F626A0D0A342030206F626A0D0A3C3C0D0A2F54797065202F506167650D' '0A2F506172656E742035203020520D0A2F5265736F7572636573203C3C0D0A2F466F6E74203C3C0D0A2F4630203620302052' '200D0A2F4631203720302052200D0A3E3E0D0A2F50726F635365742032203020520D0A3E3E0D0A2F436F6E74656E74732039' '203020520D0A3E3E0D0A656E646F626A0D0A362030206F626A0D0A3C3C0D0A2F54797065202F466F6E740D0A2F5375627479' '7065202F54727565547970650D0A2F4E616D65202F46300D0A2F42617365466F6E74202F417269616C0D0A2F456E636F6469' '6E67202F57696E416E7369456E636F64696E670D0A3E3E0D0A656E646F626A0D0A372030206F626A0D0A3C3C0D0A2F547970' '65202F466F6E740D0A2F53756274797065202F54727565547970650D0A2F4E616D65202F46310D0A2F42617365466F6E7420' '2F426F6F6B416E74697175612C426F6C640D0A2F4669727374436861722033310D0A2F4C61737443686172203235350D0A2F' '576964746873205B203735302032353020323738203430322036303620353030203838392038333320323237203333332033' '33332034343420363036203235302033333320323530200D0A32393620353030203530302035303020353030203530302035' '3030203530302035303020353030203530302032353020323530203630362036303620363036200D0A343434203734372037' '3738203636372037323220383333203631312035353620383333203833332033383920333839203737382036313120313030' '3020383333200D0A383333203631312038333320373232203631312036363720373738203737382031303030203636372036' '36372036363720333333203630362033333320363036200D0A35303020333333203530302036313120343434203631312035' '3030203338392035353620363131203333332033333320363131203333332038383920363131200D0A353536203631312036' '3131203338392034343420333333203631312035353620383333203530302035353620353030203331302036303620333130' '20363036200D0A37353020353030203735302033333320353030203530302031303030203530302035303020333333203130' '3030203631312033383920313030302037353020373530200D0A373530203735302032373820323738203530302035303020' '36303620353030203130303020333333203939382034343420333839203833332037353020373530200D0A36363720323530' '2032373820353030203530302036303620353030203630362035303020333333203734372034333820353030203630362033' '333320373437200D0A3530302034303020353439203336312033363120333333203537362036343120323530203333332033' '36312034383820353030203838392038393020383839200D0A34343420373738203737382037373820373738203737382037' '373820313030302037323220363131203631312036313120363131203338392033383920333839200D0A3338392038333320' '3833332038333320383333203833332038333320383333203630362038333320373738203737382037373820373738203636' '3720363131200D0A363131203530302035303020353030203530302035303020353030203737382034343420353030203530' '302035303020353030203333332033333320333333200D0A3333332035353620363131203535362035353620353536203535' '36203535362035343920353536203631312036313120363131203631312035353620363131200D0A353536205D0D0A2F456E' '636F64696E67202F57696E416E7369456E636F64696E670D0A2F466F6E7444657363726970746F722038203020520D0A3E3E' '0D0A656E646F626A0D0A382030206F626A0D0A3C3C0D0A2F54797065202F466F6E7444657363726970746F720D0A2F466F6E' '744E616D65202F426F6F6B416E74697175612C426F6C640D0A2F466C6167732031363431380D0A2F466F6E7442426F78205B' '202D323530202D323630203132333620393330205D0D0A2F4D697373696E675769647468203735300D0A2F5374656D562031' '34360D0A2F5374656D48203134360D0A2F4974616C6963416E676C6520300D0A2F436170486569676874203933300D0A2F58' '486569676874203635310D0A2F417363656E74203933300D0A2F44657363656E74203236300D0A2F4C656164696E67203231' '300D0A2F4D6178576964746820313033300D0A2F4176675769647468203436300D0A3E3E0D0A656E646F626A0D0A32203020' '6F626A0D0A5B202F504446202F5465787420205D0D0A656E646F626A0D0A352030206F626A0D0A3C3C0D0A2F4B696473205B' '3420302052205D0D0A2F436F756E7420310D0A2F54797065202F50616765730D0A2F4D65646961426F78205B203020302036' '313220373932205D0D0A3E3E0D0A656E646F626A0D0A312030206F626A0D0A3C3C0D0A2F43726561746F722028313732352E' '666D290D0A2F4372656174696F6E446174652028312D4A616E2D332031383A3135504D290D0A2F5469746C65202831373235' '2E504446290D0A2F417574686F722028556E6B6E6F776E290D0A2F50726F647563657220284163726F626174205044465772' '6974657220332E303220666F722057696E646F7773290D0A2F4B6579776F7264732028290D0A2F5375626A6563742028290D' '0A3E3E0D0A656E646F626A0D0A332030206F626A0D0A3C3C0D0A2F50616765732035203020520D0A2F54797065202F436174' '616C6F670D0A2F44656661756C7447726179203131203020520D0A2F44656661756C7452474220203132203020520D0A3E3E' '0D0A656E646F626A0D0A31312030206F626A0D0A5B2F43616C477261790D0A3C3C0D0A2F5768697465506F696E74205B302E' '39353035203120312E30383931205D0D0A2F47616D6D6120302E32343638200D0A3E3E0D0A5D0D0A656E646F626A0D0A3132' '2030206F626A0D0A5B2F43616C5247420D0A3C3C0D0A2F5768697465506F696E74205B302E39353035203120312E30383931' '205D0D0A2F47616D6D61205B302E3234363820302E3234363820302E32343638205D0D0A2F4D6174726978205B302E343336' '3120302E3232323520302E3031333920302E3338353120302E3731363920302E3039373120302E3134333120302E30363036' '20302E37313431205D0D0A3E3E0D0A5D0D0A656E646F626A0D0A787265660D0A302031330D0A303030303030303030302036' '3535333520660D0A30303030303032313732203030303030206E0D0A30303030303032303436203030303030206E0D0A3030' '3030303032333633203030303030206E0D0A30303030303030333735203030303030206E0D0A303030303030323038302030' '30303030206E0D0A30303030303030353138203030303030206E0D0A30303030303030363333203030303030206E0D0A3030' '3030303031373630203030303030206E0D0A30303030303030303231203030303030206E0D0A303030303030303335322030' '30303030206E0D0A30303030303032343630203030303030206E0D0A30303030303032353438203030303030206E0D0A7472' '61696C65720D0A3C3C0D0A2F53697A652031330D0A2F526F6F742033203020520D0A2F496E666F2031203020520D0A2F4944' '205B3C34373134393531303433336464343838326630356638633132343232333733343E3C34373134393531303433336464' '343838326630356638633132343232333733343E5D0D0A3E3E0D0A7374617274787265660D0A323732360D0A2525454F460D' '0A00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' '000000000000000000000000000000' INTO lv_pdf_hex. lv_xstring = lv_pdf_hex. ls_stream-mime_type = 'application/pdf'.
user4sap
Participant
0 Kudos

hey Rahul, i have now an error with your code

Statuscode 404

Ressource not found for segment 'Entityname'

user4sap
Participant
0 Kudos

The big problem is however what I write or assign to ls_stream-value. It still doesnt get any value it is always empty.

rahulkumar_sankla
Participant

I have tried your code to display file. and it is working fine with me.

Can you also redefine the method "DEFINE" in your "_MPC_EXT" class and add the following code:

    DATA: lo_entity   TYPE REF TO /iwbep/if_mgw_odata_entity_typ,
          lo_property TYPE REF TO /iwbep/if_mgw_odata_property.
    super->define( ).

    lo_entity = model->get_entity_type( iv_entity_name = 'your entity name for files' ). "In my case it is 'file'

    IF lo_entity IS BOUND.
      lo_property = lo_entity->get_property( iv_property_name = 'key field of the entity'). "in my case it is filename
      lo_property->set_as_content_type( ).
    ENDIF.<br>
user4sap
Participant
0 Kudos

It is crazy. Same code here it doesnt work I dont ubderstand it. I have still redefined the Define method like your coding sample. It still doesnt work the ls_stream-value is empty

Sandra_Rossi
Active Contributor
0 Kudos

user4sap then create quickly a very simple OData service from scratch and see if it works. If not then create the same simple one again and do a ScreenToGif and attach it here.

user4sap
Participant
0 Kudos

I have a question. My Properties are: mimetype, filename (my key) and porder.

which one have I to declare in Define method as property?

Sandra_Rossi
Active Contributor
0 Kudos

user4sap

It's not mandatory to implement DEFINE in MPC_EXT if you just want to do a quick test to download the Test PDF I indicated above. I just did it in few clicks and it works without any issue. Just implemented GET_STREAM with 4 ABAP statements (value of lv_pdf_hex taken from above comment), and it's successfully downloaded from the browser (or GW client if you prefer).

  METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
    DATA: ls_stream  TYPE /iwbep/if_mgw_appl_types=>ty_s_media_resource,
          lv_pdf_hex TYPE string.
* PDF from http://www.tagg.org/pdftest.pdf University of Liverpool
    CONCATENATE
          '255044462D312E32200D0A25E2E3CFD30D0A200D0A392030206F626A0D0A3C3C0D0A2F4C656E677468203130203020520D0A'
          ...
          '000000000000000000000000000000'
          INTO lv_pdf_hex.
    ls_stream-value = lv_pdf_hex.
    ls_stream-mime_type = 'application/pdf'.
    copy_data_to_ref( EXPORTING is_data = ls_stream
                      CHANGING  cr_data = er_stream ).
  ENDMETHOD.
user4sap
Participant
0 Kudos

Oo thx I will test by a new test project tomorrow. I have a question more. I have not write it here. The whole time i am testing at https mode because my http at gwclient doesnt work. If I click execute at http mode I get the following popup error: icm_http_connection_failed. And there no error logs. So because of that I am testing at https mode. Is it possible that my odata dont work right regarding my http error/problem?

Sandra_Rossi
Active Contributor
0 Kudos

user4sap

sorry, I wasn't notified of your message (a comment below Rahul answer will notify Rahul only, by default), see below how it works.

Concerning the error you get, I have the same one because I didn't install a certificate on my test server, so I can't use /IWFND/GW_CLIENT. I did the test with my browser by using a basic authentication (not good, but at least it's behind VPN).

NB: If you want to target someone, if this person has posted an Answer, use the button COMMENT, if this person is the Original Poster of the question he/she will be automatically informed, otherwise copy/paste their hyperlinked name so that the person receives a warning (NB: @ doesn't work/but typing this character will suggest hyperlinked names).

rahulkumar_sankla
Participant

Hi user4sap,

is this resolved?

Rahul

user4sap
Participant
0 Kudos

No i didnt have a solution for that. Ls_stream-value is always empty, no matter what I am coding

user4sap
Participant
0 Kudos

@ Rahul Kumar Sankla

user4sap
Participant
0 Kudos

I have now created a odata from scratch. I follow this tutorial ; https://blogs.sap.com/2018/06/22/media-handling-in-odata-in-sap-ui5/

I done all steps except I have my table withot the mandt field created.

After my table is created I have create odata, set as mediatype, set my property filename as key, redefine DEFINE get_entityset and get_stream methods. Odata works except the get stream method. When I try to test the getstream method with gw client, I get a failure: invalid key predicate. I do my test like in the blog given what I do false?

user4sap
Participant
0 Kudos
hey I have news. if i create odata from scratch and put your code in then it works !!!
Interesting is that gwclient give me pdf test file even I dont write a keyvalue between the brackets in query. 

This works for example:
/sap/opu/odata/sap/ZFILEname_SRV/ZFILEnameSet('')/$value
METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
    DATA: ls_stream  TYPE /iwbep/if_mgw_appl_types=>ty_s_media_resource,
          lv_pdf_hex TYPE string.
* PDF from http://www.tagg.org/pdftest.pdf University of Liverpool
    CONCATENATE
          '255044462D312E32200D0A25E2E3CFD30D0A200D0A392030206F626A0D0A3C3C0D0A2F4C656E677468203130203020520D0A'
          ...
          '000000000000000000000000000000'
          INTO lv_pdf_hex.
    ls_stream-value = lv_pdf_hex.
    ls_stream-mime_type = 'application/pdf'.
    copy_data_to_ref( EXPORTING is_data = ls_stream
                      CHANGING  cr_data = er_stream ).
  ENDMETHOD.
    THIS CODE works!

but with my coding it doesnt work. where can be the issue?

my code:

METHOD /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM.
DATA : ls_stream TYPE ty_s_media_resource,
ls_upld TYPE table_1,
ls_archive TYPE table_1,
lv_doc_id TYPE field_1,
lv_filename TYPE FILENAME,
lv_test type string.

FIELD-SYMBOLS:<fs_key> TYPE /iwbep/s_mgw_name_value_pair.
READ TABLE it_key_tab ASSIGNING <fs_key> index 1.
  SELECT SINGLE * FROM table_1 INTO ls_upld WHERE doc_id = lv_doc_id.

IF ls_upld IS NOT INITIAL.
lv_test = lv_attachment_guid.
ls_stream-mime_type = 'application/pdf'.
ls_stream-value = lv_test.
copy_data_to_ref( exporting is_data = ls_stream changing cr_data = er_stream ).
ENDIF.
ENDMETHOD.
rahulkumar_sankla
Participant
0 Kudos

Hi user4sap, what is the value in variable lv_test? and what is the value in lv_attachment_guid? where are you getting binary for your file? the datatype for lv_test is, btw, wrong, it should be xstring and not string. can you check that?

and how are you reading the file content?

ayyappan_venugopal2
Participant
0 Kudos

Its working, thanks for posting the solution.