cancel
Showing results for 
Search instead for 
Did you mean: 

Mass upload of documents under SAP Record Mangement (DPF)

Former Member
0 Kudos

Hi Experts,

I have a requirement of mass upload of files into DPF.

We need to pick the files from a given Unix location and create the records in employees DPF.

I am aware of the solution of creating archieve links and link them to DPF.

However, our requirement is to store documents in SAP RM under the same repository where the files in DPF gets stored.

As far as I know, only records from HCM process and forms sits in SAP RM.

I Also tried Creating the document and linking them to record. But could not execute the FM SRM_DOCUMENT_CHECKIN_VIA_TAB.

My question to the forum is, whether such requirement is feasible to map using custom code?

Please help!

Regards,

Mukesh

Accepted Solutions (0)

Answers (2)

Answers (2)

kriti_daga
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Experts,

We have a requirement where-in we have to upload files to RMS from existing attachments in purchase requisition created in ECC or documents from a legacy environment.

Can we do that using a BAPI?  Is it possible to do that with BAPI_RECORD_CREATE?

Please suggest.  Will be great if you could share an example for this function in order to analyze this scenario.

Thanks,

Kriti

Pragya_Pande
Contributor
0 Kudos

Please use BAPI for Documents. And it will be 2 step process - create document and upload content for it. BAPI is at the object level so your program will need to loop for all documents to be created.

Please create separate thread for new question.

Pragya_Pande
Contributor
0 Kudos

Dear Mukesh,

I hope you know that you require a content model which has been linked to the repository you want the documents to be stored in.

For creating a document & linking, the steps are : create document(SRM_DOCUMENT_CREATE), assign content to it(SRM_DOCUMENT_CHECKIN_VIA_TAB), link to the record(SRM_RECORD_ADDELEMENT) & then commit.

Best Regards,

Pragya

Former Member
0 Kudos

Dear Pragya,

Thanks for the reply.

I have content model and rest of the config settings in place.

I can create the document and retrieve using Organizer. Also, I can see the document using SRM_RECORD_DISPLAY.

I have written the code as below but getting sy-subrc = 3 (model_not_found) while executing the  'SRM_RECORD_CREATE'


CALL FUNCTION 'GUID_CREATE'
   
IMPORTING
      ev_guid_32
= guid_32. "documentid.

 
MOVE guid_32 TO documentid.

 
CALL FUNCTION 'SRM_DOCUMENT_CREATE'
   
EXPORTING
      rms_id                       
= 'ASR_DPF'
      sps_id                       
= 'ASR_SPS_PERSFILE_DOCUMENT'
      documentid                   
= documentid "'TEST_9001'
      description                  
= 'TEST_9003'
      do_commit                    
= 'X'

IMPORTING
    
return                        = return
     objectid                     
= objectid
     documentclass                
= documentclass

   EXCEPTIONS
     internal_error               
= 1
     parameter_error              
= 2
     doc_id_not_unique            
= 3
     not_authorized               
= 4
     customizing_error            
= 5
    
OTHERS                        = 6            .
 
IF sy-subrc <> 0.
 
ENDIF.

  bin_size
= lv_length.
  wa_comp
-comp_count = 1.
  wa_comp
-comp_id = 'STACK1.xls'.
  wa_comp
-mimetype = 'application/vnd.ms-excel'. " Always lowercase
  wa_comp
-comp_size = bin_size. "File size in bytes
  wa_comp
-binary_flag = 'X'.
  wa_comp
-comp_num = 1.

 
APPEND wa_comp TO lt_comp.

 
DATA : lt_bin TYPE TABLE OF bapiconten,
         lw_bin
TYPE  bapiconten,
         lw_doc_created
TYPE bapisrmdoc-boolean.

 
LOOP AT rec INTO lw_rec.
   
MOVE lw_rec TO lw_bin-line.
   
APPEND lw_bin TO lt_bin.
 
ENDLOOP.

 
CALL FUNCTION 'SRM_DOCUMENT_CHECKIN_VIA_TAB'
   
EXPORTING
      objectid               
= objectid
      documentclass          
= documentclass
     as_new_version         
= 'X'
     do_commit              
= 'X'
  
IMPORTING
     x_new_doc_created      
= lw_doc_created
    
return                  = return
   
TABLES
     components             
= lt_comp
     bin_content            
= lt_bin
  
EXCEPTIONS
     internal_error         
= 1
     parameter_error        
= 2
     not_authorized         
= 3
     doc_not_found          
= 4
     yet_locked             
= 5
    
OTHERS                  = 6 .
 
IF sy-subrc <> 0.
 
ELSE.
   
WRITE: 'Document created'.
   
WRITE lw_doc_created.
 
ENDIF.

  MOVE objectid TO documentid.

  CALL FUNCTION 'SRM_RECORD_CREATE'
   
EXPORTING
      rms_id                       
= 'ASR_DPF'
      sps_id                       
= 'ASR_SPS_RECORD'
      documentid                   
= documentid

     description                   = 'TEST_9003'
      model_sps_id                 
= 'ASR_SPS_PERSFILE_MODEL'
      model                        
= '49E535536B6D01C1E10080000A54206E'

IMPORTING
  
return                           = return
   objectid                        
= objectid
   documentclass                   
= documentclass
EXCEPTIONS
   not_authorized                      
= 1
   parameter_error                     
= 2
   model_not_found                     
= 3
   model_corrupt                       
= 4
   registration_number_not_unique      
= 5
   model_status_invalid                
= 6
   internal_error                      
= 7
  
OTHERS                               = 8.
 
IF sy-subrc <> 0.
 
ENDIF.

Regards,

Mukesh Dhakar

Pragya_Pande
Contributor
0 Kudos

Dear Mukesh,

The model expects a document ID like SRMMOD02 <guid>. You have given the guid part only as input.

Best Regards,

Pragya

Former Member
0 Kudos

Dear Pragya,

I tried with the document ID as you suggested. But it still says model not found.

I am also executing second scenario wherein I can see the record in ORGANIZER for a PERNR created using PASR_DPF_CREATE transaction. I just need to upload documents under specific folder of the record.

In this case I am calling below FMs in sequence:

1. SRM_DOCUMENT_CREATE

2. SRM_DOCUMENT_CHECKIN_VIA_TAB

3.SRM_RECORD_ADDELEMENT

Till step2 it is all OK.

In step 3, I am getting sy-subrc = 8  Internal error.

I am getting below error log in SLG1:

Source: SAPLSRM_BAPI_RECORD , LSRM_BAPI_RECORDF04 ,       191

Source type \CLASS=CL_SRM_SP_DOCUMENT is not compatible, for the purposes of assignment, with target type \INTERFACE=IF_SRM_SP_R

Source: SAPLSRM_BAPI_RECORD , LSRM_BAPI_RECORDF04 ,         6

An exception with the type CX_SY_MOVE_CAST_ERROR occurred, but was neither handled locally, nor declared in a RAISING clause

Do I need to call SRM_RECORD_CREATE in this scenario?

Below is the code for SRM_RECORD_ADDELEMENT

  wa_element_sp_poid-name  = 'DOC_ID'.
  wa_element_sp_poid
-value = 'ASR_DOC03 '+ <Object ID from step2>

  APPEND wa_element_sp_poid TO element_sp_poid.

  wa_element_sp_poid
-name  = 'VARIANT'.
  wa_element_sp_poid
-value = '0'.
 
APPEND wa_element_sp_poid TO element_sp_poid.


  wa_element_sp_poid
-name  = 'VERSION'.
  wa_element_sp_poid
-value = '0'.
 
APPEND wa_element_sp_poid TO element_sp_poid.
* Fill element properties table
 
CLEAR element_properties.
  wa_element_properties
-name = 'ASR_PERSONNEL_NUMBER'.
  wa_element_properties
-value = '00225177'.
 
APPEND wa_element_properties TO element_properties.

  wa_element_properties
-name = 'SRM_DOCUMENT_ID'.
  wa_element_properties
-value = objectid." From step2
 
APPEND wa_element_properties TO element_properties.

  wa_element_properties
-name = 'ASR_FORM_SCENARIO'.
  wa_element_properties
-value = 'Z031'.
 
APPEND wa_element_properties TO element_properties.

  wa_element_properties
-name = 'ASR_PROCESS'.
  wa_element_properties
-value = 'Z031'.
 
APPEND wa_element_properties TO element_properties.

  wa_element_properties
-name = 'STORAGE_CATEGORY'.
  wa_element_properties
-value = 'ASR03'.
 
APPEND wa_element_properties TO element_properties.

CALL FUNCTION 'SRM_RECORD_ADDELEMENT'
   
EXPORTING
      objectid              
= objectid
      documentclass         
= documentclass
      sps_id                
= 'ASR_SPS_PERSFILE_DOCUMENT'

     description            = 'TEST_9004'
      anchor                
= 'Z031'

   IMPORTING
    
return                            = return
  
TABLES
     element_sp_poid                  
= element_sp_poid
     element_properties               
= element_properties

   EXCEPTIONS
     anchor_not_found                 
= 1
     not_authorized                   
= 2
     parameter_error                  
= 3
     container_not_found              
= 4
     container_is_locked              
= 5
     max_number_of_elements           
= 6
     poid_is_wrong                    
= 7
     internal_error                   
= 8
     record_is_frozen                 
= 9
    
OTHERS                            = 10 .

I have tried adding the element using model ID as well but gives the same result 'Internal_error'

Am I missing some important property here?

Regards,

Mukesh Dhakar

Pragya_Pande
Contributor
0 Kudos

Dear Mukesh,

The record you are adding the document to, has to exist. Have you created the record you are using in

SRM_RECORD_ADDELEMENT?

My suggestion would be to create a record in ORGANIZER & then use that for this program of yours. Try not creating everything on the fly, the very first time.

Best Regards,

Pragya

Former Member
0 Kudos

Hi Mukesh,

I was getting same error model_not_found in similar scenario, until I provided model name found in Records Modeler (ORGANIZER) that was configured (in my case it was RM_RE_OBJECT) and not generated unique id.

I have also hit 'Source type \CLASS=CL_SRM_SP_MODEL is not compatible, for the purposes of assignment, with target type \INTERFACE=IF_SRM_SP_RECORD' error, that was fixed by providing correct SPS name. It looks like you are using Document SPS when calling 'SRM_RECORD_ADDELEMENT'. Try to use Record SPS instead.

Best,

Alexey

Former Member
0 Kudos

Hi Mukesh,

Can you send me the complete program I too have a similar requirement. Struggling to upload documents.

Thanks in advance

Ravindar.

Former Member
0 Kudos

Hi Ravindar,

It wouldn't be possible for me to provide the code snippet since I am working in a different project and client now.

I assume your requirement is to store the documents in SAP repository.

My approach was slightly different.

I followed the archive link approach.

FM - ARCHIVOBJECT_CREATE_TABLE and then creating a link to the DPF.

So that's how the documents were stored on a content server, and through the DPF link we could access them.

I would suggest you to open a new thread for your query, since the thread is quite old and closed.

I hope we have DPF Gurus on the forum who can help you to store the documents in SAP repository.

Regards,

Mukesh Dhakar