cancel
Showing results for 
Search instead for 
Did you mean: 

Handling File Upload/Download using NW Gateway and SAP R/3 with attached DMS

Former Member
0 Kudos

Hey everyone,

first time posting here. I'm new to the SAP world (aside from my study years which were 10 years ago) and only have little experience in ABAP and SAP in general.

I currently have a requirement to have an oData Service which is capable of uploading / downloading files from SAP.

To be more precise: Documents (Word, Excel, PowerPoint, PDF, etc) shall be attached to internal orders as business documents and sent to the archive System, which is IXOS. I have already done some research and found out that my oData Service has to call 'ARCHIV_CONNECTION_INSERT' RFC at some point to link the document in the archive to the business document (internal order). But I have no idea how i can put the document there in the first place.

I have already created a Service with CRUD operations on internal orders (using COAS table, the RFCs i found didn't allow for update) which is working find. I need some guidance how i can extend this Service (or create a new one) to upload/download documents and send them to IXOS. The service shall later be consumed by an ASP.NET application.

Any hint into the right direction will be greatly appreciated!

Cheers.

Accepted Solutions (0)

Answers (1)

Answers (1)

EkanshCapgemini
Active Contributor
0 Kudos

Hi,

You may be interested in the following links:

For file upload/download part:

For archiving part:

Regards,

Ekansh    

Former Member
0 Kudos

Hello Ekansh,

thanks for the Links, the second one is really good and explains how to get the file into the IXOS archive. However this guide implies that the file to transfer is already present on the application Server. I don't like the idea of the first guide to create new tables for saving the documents, because they don't need to be stored on the application Server at all.

Is it possible to create a custom entity set which is not connected to any table/bapi/Interface and use this for receiving and sending file requests? I would then try to redefine CREATE_STREAM and GET_STREAM, receive the bytes from the http request and use Satishs example to send them to IXOS. But i'm still not sure how to connect the file to a specific Internal Order to see it from the SAP GUI. Is that what "ARCHIV_CONNECTION_INSERT" does?

EkanshCapgemini
Active Contributor
0 Kudos

Hi Niels,

Is it possible to create a custom entity set which is not connected to any table/bapi/Interface and use this for receiving and sending file requests?

Yes, you can create the entity/entityset without referring to any BAPI/Table/Interface and use it for receiving and sending the files. You will get the files in CREATE_STREAM method from the HTTP request where you can write your own logic to send it to IXOS system. The idea of first guide was just to point you towards uploading/downloading features even he has stored it in tables just to make our life easier while testing the things for the first time.

I am not sure about the FM you stated.

Hope this helps.

Regards,

Ekansh

Former Member
0 Kudos

Hi Ekansh,

thanks for the help, really appreciate it. I'll try that out and report my results here, or ask if I have problems or additional questions

The FM i mentioned is from your second link with the description:


Following functional module updated the table entry in the archive key tables. This is insertion of the link between the SAP document number and archive key is very important to read back the image into SAP. CALL FUNCTION 'ARCHIV_CONNECTION_INSERT'...

So my guess was that this one is used to "attach" the filelink to the internal order. Only that i don't know what exporting Parameters i have to pass.

Former Member
0 Kudos

Ok, this is what i got so far:

  • I created a new Entity Type (InternalOrderFile) and checked the "Media" checkbox
  • I created a corresponding Entity Set calles InternalOrderFileService, checked Addressable and Creatable
  • Generated runtime objects
  • I redefined "DEFINE" method in the model Provider class as explained in the blog and pointed to my entity type and MimeType property.
  • I redefined "CREATE_STREAM" and "GET_STREAM" in the Extended data Provider class, without actually adding functionality
  • I set a breakpoint in the CREATE_STREAM method to see what happens.

In Gateway Client I created a POST Request to the URL of the Service and attached a PDF file and set the "slug" Header to the Name of my file. I reached the breakpoint in CREATE_STREAM and checked the is-media-struct. To my surprise it just worked I got the Mime Type and the Binary Data of the PDF in that struct.

Now i wonder how i can post addintional metadata needed to my entity type. If i supply the key in the URL like "<service-URL>(OrderId='8000170')" I get a 405 reponse saying the specified http method is not allowed. How can i pass additional Parameters needed to the request? I gues i can't put them into the Body for media type.

Additionally, when i execute the request I get this as a result in GW Client (although i was able to break at CREATE_STREAM):

Is that because i have no functionality in my method and don't fill any Parameters like er_entity?

EkanshCapgemini
Active Contributor
0 Kudos

Hi Niels,

Its good to know that you are able to receive the file in the CREATE_STREAM method.

How can i pass additional Parameters needed to the request?

Suppose you need to pass OrderID along with the file. You have to pass it in the slug itself. For now you may be passing file name in the slug, now you should consider passing file name + order no separated by any symbol like '|'. You can split the slug in the create_stream method and will get both the parameters.

Is that because i have no functionality in my method and don't fill any Parameters like er_entity?

Yes, you are right for this.

Regards,

Ekansh

Former Member
0 Kudos

Hello there,

it's been a while and i have done some Research and tested a few things.

I have changed the code to use the GOS API. With GOS_API_GET_ATTA_LIST i can succesfully retrieve the attachments for an internal order. In the GET_STREAM method i receive the Content of the attachments and they Display correctly in the Gateway Client. Sadly this is only true for GOS attachments which are not stored in the Archive System.

GOS_API_GET_ATTA_LIST Returns GOS attachments as well as ARL documents (the ones i'm interested in). Unfortunately, I don't get the arc_doc_id for the documents which i Need to retrieve the document from the repository. This is the result i get for an ARL document from GOS_API_GET_ATTA_LIST:

All ARL documents look the same (except the CrDate), the AttaId is actually the ID of the SAP Business object. Without the arc_doc_id i am not able to distinguish them. Om the other Hand, this is table TOA01 filtered for the same Business object:

When i use Transaction KO03 and open the attachment list, i get the same result as the GOS FM Returns. All archived documents have the same generic Name and no filename or creation time. However when i doubleclick on one of them it opens the correct document, so there must be some kind of link from the GOS attachment list to the ArchiveLink tables, but i don't know how to get this Connection.

Further, i have tried to get the binary Content for an archived file. I use ARCHIV_GET_CONNECTIONS to get all ArchiveLink entries for a specific Business object. This funtion works fine and Returns the same result as the screenshot i posted above. But i'm not able to get the actual Content of These files. The first function i tried was "ARCHIV_GET_TABLE" which had a sy-subrc of 3 although i don't know if i passed the correct Parameters (i used the "sap_object" and "ar_object" from the screenshot above and took arc_doc_id as object_id).

The second attempt was "SCMS_AO_TABLE_GET" where i used the arc_doc_id for arc_id and sap_object for doc_id, this was not successful as well (sy-subrc = 2).

Any advice would be really appreciated as i'm running against a wall and have no idea (read: not enough SAP knowledge) to further investigate this.

Cheers.