How to add files to the existing document info data in DMS server using the SAP Net Weaver Gateway
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
Provide the Description as shown below .Save and Activate
Right Click on the Entity Types to create the entity type as shown below
Provide the Entity Name as Add_File
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.
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
Provide the properties as shown below
Click on the Generate run time Objects
Default Classes of the service will be generated.
Save and activate the classes
Classes are generated Successfully
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 DEFINE and write the below code inside it.
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 DPC extension class
Click on the CREATE_STREAM method to redefine as we are about the create the document and write the following coding
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.
Assign the package and click on continue to register the service.
Testing the Service
Go to the T.code /IWFND/MAINT_SERVICE
Filter the service which we created just now.
Add the file
To upload the attachment we must maintain SLUG value as shown below
Click on execute the response will be shown on the right hand side
Before Adding the Files
Go to the T.code CV03N and provide the details as given below
After Adding the Files
Hi
Let me know about CHeck-in Functionality in DMS .
how to lock that attachment through serviceĀ ? .