Skip to Content

Requirement


There may be a requirement wherein developer have to PROGRAMMATICALLY create a copy of existing DOKNR (Document Number) along with its content i.e. copying all the files/originals existing within the DOKNR and creating new FILE ID for each newly created file.

Document is in context to DMS content management system, which can be accessed via TCODE CV01N, CV02N etc.

Pictorial view for the requirement is below:

 

Challenges


  • No FM available which can directly perform this task.

 

 

Pre-requisite


Understanding on:

  • DMS server
  • ABAP

 

 

Facts


  • Authorization for Read/Write operation on DMS content management system.

 

 

Steps


  1. Reading files from Previous Document Number (DOKNR)
Action Taken Call FM CVAPI_DOC_GETDETAIL with importing parameter as OLD_DOKNR
Code Snippet CALL FUNCTION ‘CVAPI_DOC_GETDETAIL’
     EXPORTING
                  pf_dokar  = DOKAR (Document Type)
                  pf_doknr  = OLD_DOKNR
                  pf_dokvr  = ’00’
                  pf_doktl   = ‘000’
     TABLES
                  pt_files    = lt_files_previous
     EXCEPTIONS
                  not_found = 1
                  no_auth    = 2
                  error         = 3
                  OTHERS    = 99.
Outcome LT_FILES_PREVIOUS parameter will have list of all the files inside DOKNR

 

  1. Reading the content of individual file
Action Taken Call FM CVAPI_DOC_CHECKOUTVIEW with importing parameter as OLD_DOKNR.
Loop at outcome of Step1 and pass reference of individual FILE through LT_FILES_PREVIOUS_IND.
Code Snippet CALL FUNCTION ‘CVAPI_DOC_CHECKOUTVIEW’
      EXPORTING
            pf_dokar                 = DOKAR (Document Type)
            pf_doknr                 = OLD_DOKNR
            pf_dokvr                 = ’00’
            pf_doktl                  = ‘000’
            pf_ftp_dest             = ‘SAPFTPA’
            pf_http_dest           = ‘SAPHTTPA’
            pf_content_provide  = ‘TBL’
      IMPORTING
            psx_message          = ls_message
      TABLES
            pt_files                  = lt_files_previous_ind
            ptx_content           = lt_drao_ind.
Outcome LT_DRAO_IND parameter will have content of individual file which is passed through LT_FILES_PREVIOUS_IND

 

  1. Creating a new Document number (DOKNR)
Action Taken Call FM CVAPI_DOC_CREATE with importing parameter as Document Type / Storage Category / TCODE.
Code Snippet ls_draw-dokar = DOKAR (Document Type).
ls_draw-dokvr = ’00’.
ls_draw-doktl = ‘000’.
ls_draw-dokst = ‘IA’.
lv_storage_cat = ‘DMS_C1_ST’.
ls_api_ctrl-tcode = ‘CV01N’.

CALL FUNCTION ‘CVAPI_DOC_CREATE’
      EXPORTING
        ps_draw         = ls_draw
        ps_api_control = ls_api_ctrl
      IMPORTING
        psx_message   = ls_message
        pfx_doknr        = lv_documentnumber.

Outcome Post execution of FM, lv_documentnumber will have newly created DOKNR.

 

  1. Creating the content of individual file
Action Taken Loop at DRAO internal table and populate DOKAR/DOKNR/DOKVR/DOKTL with relevent values. Additionally also populate APPNR (Application number) which is available from TABLE parameter “PT_FILES” inside FM  CVAPI_DOC_CHECKOUTVIEW.
Code Snippet LOOP AT lt_drao_ind ASSIGNING <fs_drao>.
        <fs_drao>-dokar = DOKAR (Document Type).
        <fs_drao>-doknr = NEW_DOKNR.
        <fs_drao>-dokvr = ’00’.
        <fs_drao>-doktl  = ‘000’.
        <fs_drao>-appnr = ls_files_previous_ind-appnr.
ENDLOOP.
Outcome  

 

  1. Attaching the new file to DOKNR
Action Taken Call FM CVAPI_DOC_CHECKIN with importing parameter as NEW_DOKNR
Code Snippet CALL FUNCTION ‘CVAPI_DOC_CHECKIN’
      EXPORTING
                    pf_dokar              = DOKAR (Document Type)
                    pf_doknr              = NEW_DOKNR
                    pf_dokvr              = ’00’
                    pf_doktl               = ‘000’
                    ps_api_control       = ls_api_ctrl
                    pf_content_provide = ‘TBL’
                    pf_ftp_dest           = ‘SAPFTPA’
                    pf_http_dest         = ‘SAPHTTPA’
       IMPORTING
                    psx_message       = ls_message
       TABLES
                    pt_files_x             = lt_files_previous_ind
                    pt_comp_x           = lt_comp_x
                    pt_content           = lt_drao_ind.
Outcome Post execution of FM, LT_FILES_PREVIOUS_IND will have new file id created.

 

Note: In Step section wherever BOLD/ITALIC is used or variables which are used, that needs to be defined and managed.

 

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