Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 

Here I will explain file handing in NW Gateway in few simple steps.

1) Create a NetWeaver Gateway project in SEGW.

2) Create an Entity type “File” (you can choose any name)

Create an Entity Set for the Entity Type by checking the check  box.

Mark Entity Type “File” as Media

3) Create one property “FileName” mark it as key and type as String

4) Generate run-time objects (or artifacts)

5) Go to data provider extension class in edit mode and redefine method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM and

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_STREAM. Then add below code.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM for download file

DATA: ls_stream  TYPE ty_s_media_resource,

              ls_upld    TYPE zzupld.

READ TABLE it_key_tab ASSIGNING FIELD-SYMBOL(<fs_key>) INDEX 1.

DATA: lv_filename TYPE char30.

lv_filename = <fs_key>-value.

SELECT SINGLE * FROM zzupld INTO ls_upld WHERE filename = lv_filename.

  IF ls_upld IS NOT INITIAL.

ls_stream-value = ls_upld-value.

ls_stream-mime_type = ls_upld-mimetype.

copy_data_to_ref( EXPORTING is_data = ls_stream

                    CHANGING  cr_data = er_stream ).

ENDIF.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~UPDATE_STREAM for upload file

DATA: lw_file TYPE zzupld.

READ TABLE it_key_tab ASSIGNING FIELD-SYMBOL(<fs_key>) INDEX 1.

lw_file-filename = <fs_key>-value.

lw_file-value    = is_media_resource-value.

lw_file-mimetype = is_media_resource-mime_type.

lw_file-sydate  = sy-datum.

lw_file-sytime  = sy-uzeit.

MODIFY zzupld FROM lw_file.

I have created a Z table ZZUPLD to store/extract the file

6) Register the service & service is ready for use

7) Test the service from GW client. Upload the file into the Z table and extract it.

      /sap/opu/odata/sap/ZDEMO_FILE_SRV/FileSet(lor.jpg)/$value

😎 Browse your local file system and select your file. Once you upload the file SAP with automatically change the HTTP method as PUT . Execute the method. lor.jpg file got uploaded with ~status_code = 204.

File got updated in Z table

9) To download the file, just change the HTTP method to GET and execute. Program will read the existing file from the Z table as per FileName.

      Here we are passing lor.jpg so GET operation will download the file we uploaded in Z table.

Similarly you can upload any file type to the Z table and can download them.  In my next blog I will upload files from my UI5 application.

43 Comments
Former Member
0 Kudos

READ TABLE it_key_tab ASSIGNING FIELD-SYMBOL(<fs_key>) INDEX 1.


replace above code with below code.

FIELD-SYMBOLS:<fs_key> TYPE /IWBEP/S_MGW_NAME_VALUE_PAIR.

READ TABLE it_key_tab ASSIGNING <fs_key> INDEX 1.


also use this link to upload /sap/opu/odata/sap/ZDEMO_FILE_SRV/FileSet('lor.jpg')/$value


it will work fine...thank you  Amaresh Pani

Regards

0 Kudos

Thanks Rajesh. 

READ TABLE it_key_tab ASSIGNING FIELD-SYMBOL(<fs_key>) INDEX 1.

Is inline data declaration. From ABAP 7.4 onward it would work fine.  

former_member191161
Participant
0 Kudos

Hi,

 

I have followed every step when click execute as you said that. I'm getting this error.

 

 

 

and my update_stream method not triggering.

 

Here is my Entity type and its properties.

 

Please check it once and help me.

0 Kudos

Hi Siva - You need to contact your Basis team, they will update virus scan profile then it should work. Our basis team fixed it for me. If you have proper authorization then follow the steps here: http://help.sap.com/saphelp_nw70/helpdata/en/ee/50773f12f14a18e10000000a114084/content.htm?frameset=...

 

Amaresh Pani

Former Member
0 Kudos

HI,Amaresh:

          I need to upload a excel by sap ui5 and I read your article.when I followed every step of your article says and meet this errors:

 

It says:'The server is refusing to process the request because the entity has an unsupported format'.......how to do with it?

 

and I also want to ask for another questions....Just for my scenario,I look for many articles and references,some of that tell me that I need to use 'create_stream' or 'get_stream'.and what you says 'update_stream',Is there three above methods all can resolve my scenario?

 

Thanks!!!

 

Regards

Cao

0 Kudos

Hi Zhiyu - How did you upload your file? Did you use "Add File" button from the left panel to upload your file as given below?

 

With Regards

Amaresh Pani

Former Member
0 Kudos

hi,Amaresh:

       Yes,just like what you say,I click Add File Button  and upload my excel.

Regards

Cao

former_member191161
Participant
0 Kudos

Hi.

I activated virus scan profile.

Still unable to upload photo in gateway service and getting this error.

It says incorrect configuration for profile /SCMS/KPRO_CREATE.

 

 

Regards.

Siva R.

0 Kudos

Hi Zhiyu - It works fine for me. Can you please send a screenshot with "Content-Type" visible on it. Just like my above screenshot. 

 

Amaresh Pani

0 Kudos

Hi Siva - Please follow the steps in my recent blog Setting up Virus scan profile /SCET/GUI_UPLOAD for Gateway

 

Amaresh Pani

former_member191161
Participant
0 Kudos

Excellent effort. Thank you very much Amaresh Pani.

 

Now my service is working fine...

 

Regards,

Siva R.

Former Member
0 Kudos

hi,Amaresh:

this is my "Content-Type":



0 Kudos

Hi Zhiyu - I see in both of your screens the URI is not correct. It should be exactly /sap/opu/odata/sap/Z_LIT_EQUIMAINT_SRV/FileSet('')/$value . /$value is missing. try it, it should solve your issue.

 

Amaresh Pani

Former Member
0 Kudos

hi,Amaresh:


Thank you very much for your helpful suggestions.

 

I have been uploaded my excel into internal table successfully.

 

Regards,

Zhiyu

former_member191161
Participant
0 Kudos

Hi Amaresh,

 

I'm struggling when create file in service.

Please check it once.

This is my Entity type and Entity set in my service.

This is my DEFINE method.

And here is my create_stream method.

So when i add selected service I'm getting this warning.

And when click on EntitySets, displays this information message.

If i use Define method getting warning "Service was created but meta data could not be loaded" when add service.

Problem there is in DEFINE method i guess.

How can i resolve it.?

 

Thanks,

Siva R.

Former Member
0 Kudos

Hi Amaresh.

 

Thanks a lot for creating the document. Can you guide on the below requirement.

 

My requirement is to upload a PDF document from third part portal written in .net. The portal will create a signed PDF document and the same has to be stored in sap using GOS functionality.

 

My approach is

1. create a webservice using SEGW and consume the same in the portal.

2. The portal will convert the PDF file to binary format along with mime type and sent back to gateway.

3. This binary file will be attached to the GOS menu of the transaction.

 

I am doubt in point 2. Can you help me on this.

 

Thanks,

SK

Former Member
0 Kudos

Hi Amaresh,

 

Thanks for creating the document. I am not able to download .xlsx, .docx formats. Can you assist me in downloading these formats to respective file formats?


I are getting run time error as  'A character set conversion is not possible' while downloading.

thiru_siva
Explorer
0 Kudos

Very good and to the point information.

former_member184515
Participant
0 Kudos

Thanks  Amaresh, waiting for your next blog to upload files from ui5 application. The step by step screen shots have helped me lot.

 

Hi Experts,

 

Can you please share the code snippet to download the files using sap ui5. I'm able to upload/retrieve the file in the gateway server.

 

Thanks,

Laxman

former_member204370
Participant
0 Kudos

Hi Amaresh

 

I am following this blog to upload image. I am getting this error: "The request URI is not valid. The segment before '$value' must be a Media Link Entry". Below is the screenshot.

 

 

Can you let me know what could be the issue?

 

Thanks

thiru_siva
Explorer
0 Kudos


  The Entity should have the type 'Media' marked.

former_member204370
Participant
0 Kudos

Thanks for the response Siva I have missed it. It is processing now.

0 Kudos

Hi Zhiyu/Amaresh,

 

Could you please share your development thought on Excel upload into internal table.I also have the same requirement but i am not able to achieve.Which you got the error the same error i am getting

 

Thanks,

Syam

Former Member
0 Kudos

Hi Amaresh,

 

I am consuming this gateway service in ui5 and trying to upload from ui5 app to ztable.content not updating. Why any idea?

 

Regards,

Murthy,

Former Member
0 Kudos

Hi Amaresh,

Could you pls post the blog for Uploadinng and downloading the Files from SAP UI5 application. We are eagerly waiting for it.

 

Thanks

former_member204556
Participant
0 Kudos

Hi Amaresh,

 

Excellent document!! This made my work so easy that I finished it in few moments.

And you please share the same with UI5 application.

 

Regards,

Arpitha

Former Member
ajaygupta
Participant
0 Kudos

Amareesh - Thanks for a very informative blog. Could you please provide the link of  your next blog where you will link it to a sapui5 application.

ajaygupta
Participant
0 Kudos

How Can I Use This in a Sapui5 Application for upload purpose. I am trying to use Fileuploader

Former Member
0 Kudos
Hi,

I am getting an error while uploading...

Call of service /sap/opu/odata/sap/Myservice/AttachmentsSet terminated because of an error. The following error text was processed in system dGW : Field symbol has not been assigned yet.The error occurred on the application server dgw. The termination type was: RABAX_STATE.If the termination type is RABAX_STATE, you will find more information on the cause of termination in system DGW in transaction ST22. If the termination type is ABORT_MESSAGE_STATE, you will find more information on the cause of termination on the application server vdgw in transaction SM21. If the termination type is ERROR_MESSAGE_STATE, you can search for further information in the trace file for the work process in transaction ST11 on the application server vdgw. You may also need to analyze the trace files of other work processes. If you do not yet have a user ID, contact your system adminmistrator.

Please help to resolve this issue..

Thanks & Regards
Muthukumaran
Explorer
0 Kudos
Hi,

I got an error like "Invalid Key predicate",

when using below URL:  /sap/opu/odata/SAP/ZUPLOAD_FILE_SRV/fileUploadSet('thor.jpg')/$value

then i changed to /sap/opu/odata/SAP/ZUPLOAD_FILE_SRV/fileUploadSet('thor.jpeg')/$value, it works fine.

It is basically checking the file format also?

 

Thanks,

Muthu

 

 

 

 
Former Member
0 Kudos

Hi, As I am new to sapui5 technology i got a requirement that from the ui5 screen i need to upload a file to backend i,e oData service.

all the different files with different extensions should be added when i perform upload operation from front end.

here is the odata service url:    /sap/opu/odata/sap/ZOD_FILEATTACH_CRUD_SRV/fileSet(‘TextFileUpload’)/$value

so please guys do help me.If any one good at sapui5.

<mvc:View
controllerName="namespace.controller.fileup_View1"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:l="sap.ui.layout"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:u="sap.ui.unified">
 <App>
  <pages>
   <Page title="{i18n>title}">
    <content>
     <l:VerticalLayout>
      <u:FileUploader id="fileUploader"
      name="myFileUpload"
      tooltip="Upload your file to the local server"
      uploadComplete="handleUploadComplete"
      uploadUrl="upload/" width="400px"/>
      <Button press="handleUploadPress" text="Upload File"/>
     </l:VerticalLayout>
    </content>
   </Page>
  </pages>
 </App>
</mvc:View>

 

Former Member
0 Kudos
Hi ,that's a great document. I have a doubt..why you used http PUT method for uploading? cann't we use POST method? if not can u please mention the reason.I am searching for days but i didn't get solution. and Could you please post the blog for Uploading and downloading the Files from SAP UI5 application??? please share any updates at shreenivaspatro@gmail.com

Thanks in advance
Former Member
0 Kudos
Hi Amaresh pani

I have one small doubt when i was trying to upload text file into gateway services but it won't take large text .It was taken some limited text only.Can please suggest me how can i rectify those problem.
Former Member
0 Kudos
hi Amaresh ,

I am executing this code and i followed all you document but this error is coming .

Former Member
0 Kudos
kindly help in this .
former_member186852
Contributor
0 Kudos
please pass filename FileSet('name')/$value
0 Kudos
HI,

Could some one help me out,i am facing an issue here.

rahulabrol
Explorer
0 Kudos
A Wonderful post,

Just with one correction in calling get_stream / update_stream we need to pass the filename in single quotes.

/sap/opu/odata/SAP/ZRA_IMAGE_SRV/FileSet('first.jpeg')/$value

 

Thanks a lot
0 Kudos

Hi

I have an issue to retrieve image file. Its not return in image file. I had follow all the steps as well as in SEGW, type Edm.Guid and entity type is tick as media. When I click GET it returns to error 'Malformed URI literal syntax'. Below screenshot is when I click ADD FILE.

Please help me on this.

 

 

 

 

shalinee_gupta
Explorer
0 Kudos
Hi,

I am trying to store XML file as Xstring and trying to get it through get_stream method. But its not showing the file in Gateway client. Can we store XML file also in Xstring in Database and get it through get_stream?
MauriSoberanes
Explorer
0 Kudos
Great this is what I am looking for but ... ¡Where is the next part!, looking for the UI5 part where uses this gateway service.

 

Thanks
umesh_1212
Explorer
0 Kudos
Hello All,

Is anyone working on Post odata for Excel file data upload in sap tables?
Labels in this area