0% found this document useful (0 votes)
1K views14 pages

Upload Document Into DMS Server Using Net Weaver Gateway - SAP Blogs

This document provides steps to upload documents into an SAP DMS server using SAP NetWeaver Gateway. It describes creating a Gateway project and entity type to represent documents. Logic is added to a class to upload the document file to DMS using BAPI calls when the service is executed. The service is tested using the Gateway client by passing a file name in the SLUG parameter, which returns a document number if successful.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views14 pages

Upload Document Into DMS Server Using Net Weaver Gateway - SAP Blogs

This document provides steps to upload documents into an SAP DMS server using SAP NetWeaver Gateway. It describes creating a Gateway project and entity type to represent documents. Logic is added to a class to upload the document file to DMS using BAPI calls when the service is executed. The service is tested using the Gateway client by passing a file name in the SLUG parameter, which returns a document number if successful.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Community

Ask a Question Write a Blog Post Login

Former Member
August 22, 2016 6 minute read

Upload document into DMS Server using Net Weaver Gateway


Follow RSS feed Like

4 Likes 6,035 Views 3 Comments

Scenario:

Why and when we use DMS?

DMS is used to read the content of storage documents (external data server but not SAP content server).Here I am
going to explain one of mine client requirement to upload the document after/while creating the Purchase requisition
in item level. So in order to achieve the functionality we need to upload the le from non-SAP server into DMS
(CV01N) using Gateway.

By Using this Blog, you can upload a wide range of documents like Word Documents,Excel Sheets, PDF, Text Files and
Images and many more through Gateway service.

Procedure:

Goto SEGW TCode and Create Project as shown below.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 1/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Provide Project Details.

Create En ty Type with the required fields.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 2/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

For Upload_Doc : Provide the following details.

Created Entity Type as shown below.

Double click on Entity Type created and put tick mark on Media type check box (mandatory).

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 3/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Double click on Properties and Click on Insert Row to add fields.

Insert field and check as key field (mandatory).

Click on Save

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 4/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Now click on Generate button.

Then we will get below screen, click on continue

It displays generated OBJECTS SUCCESSFULLY.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 5/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

And at that time it generates all classes automatically.

Then Redefine the DEFINE method in the *MPC_EXT Class and add the below logic.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 6/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Method DEFINE.

super->DEFINE( ).

DATA: lo_en ty type REF TO /IWBEP/IF_MGW_ODATA_ENTITY_TYP,

lo_property type REF TO /IWBEP/IF_MGW_ODATA_PROPERTY.

lo_en ty = model->GET_ENTITY_TYPE( IV_ENTITY_NAME = ‘ Upload_Doc’ ).”En ty Name

IF lo_en ty is BOUND.

lo_property = lo_en ty->GET_PROPERTY( IV_PROPERTY_NAME = ‘DocName’ ).”Key Value(SLUG)

lo_property->SET_AS_CONTENT_TYPE( ).

ENDIF.

Endmethod.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 7/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Right Click on ZCL_ZUPLOAD_DOC_DMS_DPC_EXT class and select Go to ABAP Workbench.

Rede ne CREATE_STREAM Method and implement the below logic to upload document into the DMS Server from ODATA Service.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 8/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Code:

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.
DATA :  ls_documentdata TYPE  bapi_doc_draw2,
ls_DOCUMENTNUMBER TYPE  BAPI_DOC_AUX–DOCNUMBER,
ls_DOCUMENTTYPE TYPE  BAPI_DOC_AUX–DOCTYPE,
ls_DOCUMENTPART TYPE  BAPI_DOC_AUX–DOCPART,
ls_DOCUMENTVERSION TYPE  BAPI_DOC_AUX–DOCVERSION,
ls_RETURN TYPE  BAPIRET2,
lv_filename TYPE DBMSGORA–FILENAME,
lv_PURE_FILENAME TYPE SDBAH–ACTID,
lv_PURE_EXTENSION TYPE SDBAD–FUNCT.

DATA:  lt_files TYPE TABLE OF BAPI_DOC_FILES2,


ls_files TYPE          BAPI_DOC_FILES2,
* Short Texts
lt_drat TYPE TABLE OF bapi_doc_drat,
* Object links
lt_drad TYPE TABLE OF bapi_doc_drad,
LS_DOC TYPE ZCL_ZUPLOAD_DOC_DMS_MPC=>TS_UPLOAD_DOC.
* Pass SLUG value

lv_filename = IV_SLUG.

* Function Module to split and get le name and extension

CALL FUNCTION ‘SPLIT_FILENAME’


EXPORTING
long_filename = lv_filename
IMPORTING
PURE_FILENAME =  lv_PURE_FILENAME
PURE_EXTENSION =  lv_PURE_EXTENSION.

* Allocate document data


ls_documentdata–documenttype = ‘DOC’.
ls_documentdata–documentversion = ‘000’.
ls_documentdata–documentpart = ’00’.

ls_documentdata–wsapplication1 = lv_PURE_EXTENSION.
ls_documentdata–wsapplication2 = lv_PURE_EXTENSION.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 9/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

* Check original 1 into the SAP data base at the same time
REFRESH lt_files.
CLEAR lt_files.

ls_ les–originaltype = ‘1’.


ls_files–WSAPPLICATION = lv_PURE_EXTENSION.
ls_files–SOURCEDATACARRIER = ‘SAP-SYSTEM’.
ls_files–docfile = IV_SLUG.
APPEND ls_files to lt_files.

* BAPI to Upload document into DMS Server


CALL FUNCTION ‘BAPI_DOCUMENT_CREATE2’
EXPORTING
DOCUMENTDATA = ls_documentdata
IMPORTING
DOCUMENTTYPE = ls_DOCUMENTTYPE
DOCUMENTNUMBER = ls_DOCUMENTNUMBER
DOCUMENTPART = ls_DOCUMENTPART
DOCUMENTVERSION = ls_DOCUMENTVERSION
RETURN                     = ls_RETURN
TABLES
DOCUMENTDESCRIPTIONS = lt_drat
OBJECTLINKS = lt_drad
DOCUMENTFILES = lt_files.
IF ls_return–type CA ‘EA’.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.

ELSE.

CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’


EXPORTING
wait = ‘X’.

LS_DOC–DOCNAME = ls_DOCUMENTNUMBER.

copy_data_to_ref(
EXPORTING
is_data =  LS_DOC
CHANGING
cr_data = er_entity ).
ENDIF.

endmethod.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 10/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

All input Values we have to get into the SLUG parameter from the UI Side. If you have multiple input parameter values then
concatenate multiple parameter values with delimiter we have to get the values in SLUG parameter.

Testing Our Service:

Now we will test our service in Gateway Client transaction /IWFND/MAINT_SERVICE

Select the entityset and Upload a le through add le button which is on left side corner as shown in the below screen shot.

Pass SLUG values(mandatory) le name as shown in the below screen shot.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 11/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Now click on POST HTTP Method and Execute.

Service Response:

It will generate a document number as shown below.

Successfully uploaded document in DMS Server.

Result:

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 12/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

Go to CV03N Transaction and provide document number and document type and click enter as shown below.

To open the le double click on it.

File got opened successfully as shown.

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 13/16
11/6/2019 Upload document into DMS Server using Net Weaver Gateway | SAP Blogs

In the same way we can upload any type of document into DMS.

Thanks&Regards,

Prasanna Addula

Alert Moderator

Assigned tags

SAP Gateway | gateway | upload dms |

Related Blog Posts

How to add les to the existing document info data in DMS server using the SAP Net Weaver Gateway
By Madhulatha Gummadi , Aug 25, 2016

Batch Process in SAP Net Weaver Gateway


By HariKrishna Malladi , Mar 23, 2017
File Upload/Download in CRM WebUI Using Net weaver Gateway/OData Services
By Former Member , Nov 12, 2014

https://blogs.sap.com/2016/08/22/upload-document-into-dms-server-using-net-weaver-gateway/ 14/16

You might also like