Quantcast
Channel: SAP Gateway
Viewing all articles
Browse latest Browse all 137

How to add files to the existing document info data in DMS server using the SAP Net Weaver Gateway

$
0
0

Scenario: When we want to add some additional files to the document info which is already created in the DMS through CV01N .This particular functionality can be achieved by the below mentioned process.


Procedure:

Go to the T.code SEGW, Click on create project to create new Project

1.png

Provide the Description as shown below .Save and Activate

2.png

Right Click on the Entity Types to create the entity type as shown below

3.png

Provide the Entity Name as Add_File

4.png

Click on the Media type Check Box

Mandatory Note:A normal entity type will act as media entity type when you flag it is media by selecting the check box.

5.png

Expand the Entity type Add_Files it will navigate to the Properties double click on the properties, on the right hand side you can find the option insert row Click on the insert row to add the filed names to the Entity type

6.png

Provide the properties as shown below

7.png

Click on the Generate run time Objects

8.png

Default Classes of the service will be generated.

9.png

Save and activate the classes

10.png

Classes are generated Successfully

11.png

 

Setting Entity Type as Media is not sufficient we also need to set manually via coding. To do so, go to the MPC extension class and redefine the method DEFINEand write the below code inside it.

12.png

14.png

 

METHOD define.
super
->define( ).

DATA: lo_entity     TYPE REF TO  /iwbep/if_mgw_odata_entity_typ,
lo_property
TYPE REF TO  /iwbep/if_mgw_odata_property.

lo_entity
= model->get_entity_type( iv_entity_name = 'Add_File' )."Entity Name

IF lo_entity IS BOUND.

lo_property
= lo_entity->get_property( iv_property_name = 'Filename' )."Key Value(SLUG)
lo_property
->set_as_content_type( ).

ENDIF.
ENDMETHOD.

 

  Now go to the DPCextension class

15.png

Click on the CREATE_STREAM method to redefine as we are about the create the document and write the following coding

16.png

17.png


method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.

METHOD /iwbep/if_mgw_appl_srv_runtime~create_stream.

DATA: lt_files     TYPE TABLE OF bapi_doc_files2,
ls_files    
TYPE bapi_doc_files2,
ls_return   
TYPE bapiret2,
lv_docnum   
TYPE bapi_doc_aux-docnumber,
lv_filename 
TYPE dbmsgora-filename,
lv_filename1
TYPE sdbah-actid,
lv_extension
TYPE sdbad-funct,
ls_file     
TYPE zcl_zadd_fiLes_dms_doc_mpc=>ts_add_file.

*Passing the SLUG value to the Filename

lv_filename
= iv_slug.

* Function Module to split and get file name and extension

CALL FUNCTION 'SPLIT_FILENAME'
EXPORTING
long_filename       
= lv_filename
IMPORTING
pure_filename       
lv_filename1
pure_extension      
lv_extension.


ls_files
-docfile       = lv_filename1.
ls_files
-wsapplication = lv_extension.
APPEND ls_files TO lt_files.

CALL FUNCTION 'BAPI_DOCUMENT_SETCOMMITMODE'
EXPORTING
auto_commit
= 'X'.

*Function Module to add
CALL FUNCTION 'BAPI_DOCUMENT_CHECKIN2'
EXPORTING
documenttype           
= 'DOC'
documentnumber         
= '0000010000000000000000105'
documentpart           
= '000'
documentversion        
= '00'
*   HOSTNAME                = ' '
*   STATUSINTERN            = ' '
*   STATUSEXTERN            = ' '
*    statuslog              = ' '
*   REVLEVEL                = ' '
*   AENNR                   = ' '
*   PF_FTP_DEST             = ' '
*   PF_HTTP_DEST            = ' '
IMPORTING
return                  = ls_return
TABLES
documentfiles          
= lt_files
*   COMPONENTS              =
*   DOCUMENTSTRUCTURE       =.
.
IF ls_return-type CA 'EA'.
ROLLBACK WORK.
MESSAGE ID '26' TYPE 'I' NUMBER '000'
WITH ls_return-message.
ELSE.
COMMIT WORK.
ENDIF.

CONCATENATE lv_filename 'Uploded Sucessfully' INTO ls_file-filename.

copy_data_to_ref
(
EXPORTING
is_data
ls_file
CHANGING
cr_data
= er_entity ).
ENDMETHOD.

 

Double Click on the Service Maintenance on the right hand side you can see the option Register .Select the system and register the service.

18.png

Assign the package and click on continue to register the service.

19.png

Testing the Service

Go to the T.code /IWFND/MAINT_SERVICE

Filter the service which we created just now.

20.png

Add the file

21.png

22.png

To upload the attachment we must maintain SLUG value as shown below

23.png

Click on execute the response will be shown on the right hand side

24.png

 

Before Adding the Files

Go to the T.code CV03N and provide the details as given below

25.png

26.png

 

After Adding the Files

27.png


Viewing all articles
Browse latest Browse all 137

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>