Skip to Content

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

/wp-content/uploads/2016/08/1_1022231.png

Provide the Description as shown below .Save and Activate

/wp-content/uploads/2016/08/2_1022232.png

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

/wp-content/uploads/2016/08/3_1022233.png

Provide the Entity Name as Add_File

/wp-content/uploads/2016/08/4_1022252.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.

/wp-content/uploads/2016/08/5_1022253.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

/wp-content/uploads/2016/08/6_1022254.png

Provide the properties as shown below

/wp-content/uploads/2016/08/7_1022255.png

Click on the Generate run time Objects

/wp-content/uploads/2016/08/8_1022256.png

Default Classes of the service will be generated.

/wp-content/uploads/2016/08/9_1022257.png

Save and activate the classes

/wp-content/uploads/2016/08/10_1022258.png

Classes are generated Successfully

/wp-content/uploads/2016/08/11_1022259.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 DEFINE and write the below code inside it.

/wp-content/uploads/2016/08/12_1022260.png

/wp-content/uploads/2016/08/14_1022262.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 DPC extension class

/wp-content/uploads/2016/08/15_1022263.png

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

/wp-content/uploads/2016/08/16_1022264.png

/wp-content/uploads/2016/08/17_1022265.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_auxdocnumber,
lv_filename 
TYPE dbmsgorafilename,
lv_filename1
TYPE sdbahactid,
lv_extension
TYPE sdbadfunct,
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_filesdocfile       = 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_returntype CA ‘EA’.
ROLLBACK WORK.
MESSAGE ID ’26’ TYPE ‘I’ NUMBER ‘000’
WITH ls_returnmessage.
ELSE.
COMMIT WORK.
ENDIF.

CONCATENATE lv_filename ‘Uploded Sucessfully’ INTO ls_filefilename.

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.

/wp-content/uploads/2016/08/18_1022266.png

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

/wp-content/uploads/2016/08/19_1022267.png

Testing the Service

Go to the T.code /IWFND/MAINT_SERVICE

Filter the service which we created just now.

/wp-content/uploads/2016/08/20_1022268.png

Add the file

/wp-content/uploads/2016/08/21_1022269.png

/wp-content/uploads/2016/08/22_1022270.png

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

/wp-content/uploads/2016/08/23_1022271.png

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

/wp-content/uploads/2016/08/24_1022272.png

Before Adding the Files

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

/wp-content/uploads/2016/08/25_1022276.png

/wp-content/uploads/2016/08/26_1022277.png

After Adding the Files

/wp-content/uploads/2016/08/27_1022278.png

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply