Skip to Content

Create an SAP DMS document attaching a file from the Application Server and checking in an FTP vault with automatic filename creation

Hi all,

So, as you can see from the title, I had a very specific requirement. I needed to be able to create a document (those you can open through CV03N) programmatically attaching a file from the application server and with an FTP server that automatically assigns filenames.

I searched google/scn extensively for a way to do this or an example and tried a few, but it seems that the configuration options for DMS are so vast that it was unlikely to find an example that suited my needs and my configuration. So I’m sharing my code and my example, hoping that maybe it will be helpful for someone else, and maybe I’ll even need it myself in the future.

The code ended up being extremely simple, but I assure you I tried so many really complex approaches that I don’t even want to remind myself of them again

  1. DATA:
  2.       lv_docty  TYPE dokar,
  3.       lv_docnr  TYPE doknr,
  4.       lv_docpr  TYPE doktl_d,
  5.       lv_docvr  TYPE dokvr,
  6.       ls_ret    TYPE bapiret2,
  7.       lt_files  TYPE TABLE OF bapi_doc_files2,
  8.       ls_files  LIKE LINE OF lt_files,
  9.       ls_documentdata TYPE bapi_doc_draw2.
  10. CLEAR ls_documentdata.
  11. ls_documentdata-documenttype = 'ZCL'.
  12. ls_documentdata-description = 'Testing DMS'.
  13. ls_documentdata-username = sy-uname.
  14. CLEAR ls_files.
  15. ls_files-originaltype = '1'.
  16. ls_files-storagecategory = '<VAULT NAME HERE>'.
  17. ls_files-docpath = '/tmp/'.
  18. ls_files-docfile = 'dms_test4.pdf'.
  19. ls_files-wsapplication = 'PDF'.
  20. APPEND ls_files TO lt_files.
  23.     documentdata    = ls_documentdata
  24.     pf_ftp_dest     = 'SAPFTPA'
  25.     pf_http_dest    = 'SAPHTTPA'
  27.     documenttype    = lv_docty
  28.     documentnumber  = lv_docnr
  29.     documentpart    = lv_docpr
  30.     documentversion = lv_docvr
  31.     return          = ls_ret
  32.   TABLES
  33.     documentfiles   = lt_files.
  34. IF ls_ret-type NE 'E'.
  36.     EXPORTING
  37.       wait = abap_true.
  38. ELSE.
  40. ENDIF.

And the result:

Display Document_ Basic Data Customer Claim (ZCL).png

I hope this will be helpful to someone!

Best regards,


Display Document_ Basic Data Customer Claim (ZCL).png
You must be Logged on to comment or reply to a post.
  • I am just struggling with this type of problem and was very happy to find your example. Unfortunately I get an upload error 😥

    In my case I am generating a file on the application server and it is to be stored in the SAP system/database (not using Knowledge Provider).

    When manually creating a document and attaching such a file it gets automatically assigned to SAP-SYSTEM as archive category. I have tried both with and without specification of this value to field “STORAGECATEGORY”, but have not solved the problem yet.

    Do you have any experience with that or a tip where I could start investigating?

    • Hi Kjetil!

      I’m glad my example made you happy somehow 🙂

      Like I said, before being successful I tried many more complex ways of achieving what I wanted. The best thing that I did was going home, sleeping, and coming back to office fresh the day after 🙂 My approach for the next day was: let’s simplify, and if it’s automatic, let’s leave it OUT of the equation.

      From what you’re telling me it seems you don’t have an FTP server configured, so, not only you should leave STORAGECATEGORY blank but also the pf_ftp_dest line should probably be commented out too, since there will be no FTP server (or at least that’s how it seems to me). You should also look around in configuration (SPRO – Cross-Application Components – Document Management – Control/General Data) to see how your DMS is configured, if you weren’t the one configuring it! 🙂

      It’s funny… your requirement seems to be easier than mine… but with SAP sometimes easier is more difficult! 😀

      Good luck… keep me posted of your results. I could actually extend my document to include your case and your solutions. This way it will be easy to find for us if we ever need it in the future! 🙂



      • In another thread (‘BAPI_DOCUMENT_CREATE2’: store attachment using ‘SAP-SYSTEM’) I found an important piece of information – the files which are not to be stored using Knowledge Provider are supplied as part of the document data (BAPI_DOC_DRAW2) structure.

        So, by filling the fields DOCFILE1, DATACARRIER1 (“SAP-SYSTEM”) and WSAPPLICATION1 the original file got added and checked in – at least so it appears.

        Now I get an error (26/254) when trying to display the original, but at least I got one step further – I think and hope.

        • Hi Kjetil,

          Glad you’re making some progress 🙂

          Error while opening the file… At first glance I would say maybe the file you are trying to open is not maintained in the workstation application customizing table. Check transaction code DC30 or search for “Define Workstation Application” in SPRO. That would be my best guess…

          I just looked at the error message… Error while checking out… so I don’t think it’s what I just said. Maybe debugging will help you? 🙁

          I don’t think I have this set up so that I can store documents in SAP-SYSTEM, otherwise I would try to have a look as well.

          Good luck!


          • After trying to solve the checkout problem for hours and hours without getting any wiser I debugged far enough down in the SAP code to discover that the check-in is the problem. There is no content in table DRAO for the originals I have attached after creating them on the server. 😥

          • Hi Kjetil,

            Well… at least that’s some progress!! 🙂

            I see table DRAO being used in Web Dynpro component LFS_SUST_FILEUPLOAD. If you look at method PROCESS_EVENT in its component controller you see very interesting code that might be helpful for you. Namely:


                        EXPORTING: buffer        = lf_content

                        IMPORTING: output_length = lv_len

                        TABLES:    binary_tab    = lt_binary.

            LOOP AT lt_binary ASSIGNING <fs>.

                     ls_draoorblk = <fs>line.

                     ls_draoorln  = lv_len.

                     APPEND ls_drao TO lt_content.

                     ADD 1 TO ls_draozaehl.


            See if that helps!!



  • Sorry about taking so long before updating this thread, but here is the solution that turned out to work in my case.

    First of all, the case can be described as follows:
    – Document type is not using Knowledge Provider

    – Original file is a small text file created on the fly in a web service implementation

    – Original file stored in the TMP area during web service execution

    The solution in our case ended along the following pseudo-code lines:

    1) Create original file on server TMP area (with fixed name)

    2) Call BAPI_DOCUMENT_CREATE2 – not passing on original created in step 1

    3) Call BAPI_TRANSACTION_COMMIT (if creation was successful, otherwise exit)

    4) Read file from server

    5) Convert text file contents to binary content format using SCMS_STRING_TO_XSTRING followed by SCMS_XSTRING_TO_BINARY

    6) Attach original to document using CVAPI_DOC_CHECKIN

    The first and fourth steps could probably be skipped, i.e. the file contents could be passed on directly to SCMS_STRING_TO_XSTRING, but I haven’t touched it much after I finally got it working 🙂

    • Hi kjetil/bruno,

                         i am also stuck up with same kind of,i am having the document content downloaded from xECm to my internal table in xstring,i want to store it in a word file in application server without saving it in presentation layer .can you please guide me.



      • Hi Krishna,

        I think the easiest way for you is to create this document in a temporary location in the application server using the OPEN DATASET statement, and then follow my instructions above.

        I believe that the OPEN DATASET need the data in binary format, but you should be able to find a way to convert easily by searching the forum.

        If you encounter any specific issues please share the code and maybe we help.

        Good luck.

        Kind regards,


        • Hi bruno,

               1. created a file in application server using the opendata set stmt.

                     open dataset dsn for output in binary mode .

          loop at lt_binary into wa_binary .

          transfer wa_binary to file .


          while sy-subrc = 0 .

          transfer file to result .


          close dataset file .

            now ,when i open the file in the al11 …it is opening in unreadable format.

          i want to display the file in word document .without downloading it in to presentation layer.

          • Hi Krishna,

            I’m not really sure what you are trying to achieve. To open and display a file you always have to create a local copy. For example, when you are browsing the internet and you choose to “open” a file instead of saving it, a local copy is created in your temporary files, and then eventually it gets deleted when you clear the temporary files from the browser cache.

            Best regards,


          • hi bruno ,

                         the requirment is to control the printing of the document ,previously while printing they are updating the document in the dms using ole.but,now the dms is replaced by xECM .from xecm we are getting the document attachment as xstring .

                        we can edit the document by downloading it into  presentation server .but the requirment is to control the printing of the document ,hence we have to achive printing of the document by user  without downloading  it into the presntation layer.

            please share your mail id ,so that i can share code also.



          • Hi Krishna,

            I don’t think I can help you much further with this. Try and open a new question and share your code (or the relevant parts). Hopefully you will get help from people more knowledgeable than me 🙂



    • Hi Omer,

      I do not, I’m sorry, and I don’t have the time right now to look into that. But regarding the e-mail part look into standard class CL_BCS. Class CL_ZIP is also useful if you want to send the attachments in ZIP format.

      Good luck and best regards,


  • Hi Bruno,

    Thanks a lot for the code. We do have a similar requirement.  The documents from one system have to be migrated to another system.

    Initially we are reading the DIR details using the FM “BAPI_DOCUMENT_GETDETAIL2 “.

    Then converting the document files data to xstring using the FM’s  ‘SDOK_PHIO_LOAD_CONTENT’ and ‘SCMS_XSTRING_TO_BINARY’ .

    Then I am saving the file to local system(Presentation server) using cl_gui_frontend_services=>gui_download . (This process of saving locally is to get the physical path for checking in the document using FM  ‘BAPI_DOCUMENT_CREATE2’


    So far the above procedure is working fine as it is foreground. But now the requirement is to run report in background. I am sure the gui_download will not wotk in background. Alternatively has to use opendataset and closedataset in application server.

    My query is, if I use the opendataset method here, how to use the SAPHTTPA and SAPFTPA .

    Thanks in advance.


    • Hi Siva!

      You are very welcome.

      I also use the application server. The path to the file in the application server should go in fields “docpath” and “docfile” in the “documentfiles” table.

      I guess the only difference from my scenario to your scenario, is that you don’t use a VAULT to store the file in SAP. I would try a code similar to mine but without populating the storage category (line 18 on my code).

      Give it a try… if it doesn’t work, I guess you’ll have to do a lot of debugging, like I did 🙂

      Best regards,


      • Hi Bruno,

        Thanks for the reply.

        I am able to save the file on application server and able to see in AL11 tcode. But when I am trying to checkin the document using the below FM.

             documentdata               = ls_doc
             pf_ftp_dest     = ‘SAPFTPA’
             pf_http_dest    = ‘SAPHTTPA’
            documenttype                  = ls_stbdokar
            documentnumber             = ls_stbdoknr
            documentpart                   = ls_stbdoktl
            documentversion              = ls_stbdokvr
            return                                = ls_return
              documentfiles              lt_documentfiles.

        It is throwing the follow error.

        Error while checking in and storing: /usr/sap/tmp/200372_001.TIF

        Please help me on this issue.


        Siva Krishna


        • Hi Siva,

          Very hard for me to help you 🙁 If you’d like to share the entire code I could try to run it when I have some spare time (very rare these days) and see if I can find anything, but the SAP DMS can be configured in many different ways, so I’m pretty sure my results wouldn’t be the same as yours.

          My advice to you is to do the same as I did, get some coffee, some relaxing music, and debug the standard step by step.

          Good luck,


    • Hi Siva,

      I am trying something similar. Lets say I have a doc no = 111. And it has 1 file as attachment.

      I want to get that file in xstring format so that I can show that in my web dynpro(FPM) application.

      How can I get the xstring format? Can you kindly detail it a bit.

      Many many thanks i advance.



  • Hello Bruno,

    nice example but i don’t get the part where you are attaching file from application server.

    I have my file on application server in directory DIR_HOME with path looks like  F:\usr\sap\T60\….. and

    ls_documentfilesSTORAGECATEGORY = ‘DMS_C1_ST’.

    ls_documentfilesWSAPPLICATION = ‘WW7’.

    ls_documentfilesDOCPATH = ‘F:/usr/sap/T60/DVEBMGS01/work/’.

    ls_documentfilesDOCFILE = ‘dms01.docx’.

    ls_documentfilesDESCRIPTION = ‘DOCUMENT WORD 3’.

    i get error: Error while checking in and storing:


    So my question is you have in your code:

    ls_filesdocpath = ‘/tmp/’.

    ls_filesdocfile = ‘dms_test4.pdf’.

    So where is this file located?



    • Hi Miro,

      As far as I know, when you are accessing a file from the application server, you don’t need the drive letter. So I think if you remove “F:” from the path, it should work.

      I would troubleshoot this trying simple examples with the OPEN DATASET statement.

      If you still have trouble, let me know, I can try to look further into this, but at the moment I’m a bit busy.

      Best regards,


        • Hi Miroslav,

          Not really, no 😕

          And even if I had the time to dig into it, my system is probably configured in a different way so I’m not sure if I would be able to replicate your issue.

          My only advice to you is to do the same thing I did… many hours of debugging… 🙂

          Cheers and good luck,


  • Hi Bruno,

    Great artcles.

    I am trying something similar. Lets say I have a doc no = 111. And it has 1 file as attachment.

    I want to get that file in xstring format so that I can show that in my web dynpro(FPM) application.

    How can I get the xstring format? Can you kindly detail it a bit.

    Many many thanks i advance.



    • Hi Saikat,

      This reply is almost one year too late but maybe it will be helpful for others.

      When you have your file in binary format (by using OPEN DATASET), you can use function module SCMS_BINARY_TO_XSTRING to convert it to XSTRING format.


  • Hi Bruno

    Nice document.It helped me a lot. Even i am getting the same error like mirosalv and siva was talking. Any heads up for this error and how it could be solved.  Error while checking in and storing: my file path. Thanks in advance.

  • Hi Burno

    Nice document and it was very helpful and thanks for it first of all. As mirosalv and siva saying even I am getting the same error “Error While Checking in and storing: my file path”. Any idea why I am getting this and how it could be solved if so please let me know and Thanks in advance.

    • Hi Jayadan,

      As already replied to others, there are so many different ways that DMS can be configured, I’m not sure I’d be able to replicate your error. But looking at the error message, it looks like there might be an issue in the way the file name is being generated? Also, if you use it via dialog, are you able to store files? Could be missing some customizing.

      Good luck,

  • Hi Burno,

    Nice knowledge sharing documents , I have work around it it help help to me upload document after refereing above document .

    thanks Burno.


  • Hi Bruno,

    I read all comment in this blog and find very helpful for other scenario. My scenario is little different.

    I have a program which runs daily to move all invoice attachment from GoS to Content server. In report i am using FM  ARCHIVOBJECT_CREATE_TABLE and  ARCHIV_CONNECTION_INSERT to move the attachment. After moving the attachment i am able to open the pdf document but not able to open word/excel file. content is getting corrupted and while opening the file it’s asking to convert. Please suggest if i am missing any config. I have configured the word file in DC30 tcode

    Below is DC30 line for word document. One more point.. after adding entry in DC30 it started working but after EHP8 upgrade it’s not working. Please suggest.

    WRD Word   A2


    Best Regards,



    • I don’t think I’m able to help, my apologies. If you would post more information, such as the code where you make the conversions from one format to another, maybe someone with more experience in that specific scenario would be able to help you. One thing I would be extremely careful with, is the actual “zeros and ones” of the files. Make sure the underlying file system is similar and use raw data as much as possible.


      • Hi Bruno,

        I have a small question on DMS..i am getting attachments from web service I see we need to store files temporarily(Desktop/Application server) if we use the FM 
        SPAN {
        font-family: “Courier New”;
        font-size: 10pt;
        color: #000000;
        background: #FFFFFF;
        BAPI_DOCUMENT_CREATE2  as we have file path as one of the Inputs for FM.

        is there any way we can avoid temporarily storing the files into the app server and can directly upload files to DMS..?

        I really appreciate your help on this.








          The application server is not a “front-end” desktop. This would be a huge problem. What I did, and I think this is mandatory, is to store the file in a temporary folder of the SAP system (application server), and after the file is checked-in to the vault server, I delete the temporary file.

          So, to answer your question, I think the answer is no, you have to store the file temporarily in the application server, but there’s no “desktop”, the path should be something like /usr/sap/tmp or something like that.


  • Hi Bruno,

    I am able to successfully create a DIR with the document in application server. If I want to pick the document from another FTP location/my computer’s local directory then what should i pass in the host name and how the RFC destination SAPFTPA  should be configured. Please advice. Also how should we pass the below values in case of FTP/local directory.

    1. ls_files-docpath = ‘/tmp/’.
    2. ls_files-docfile = ‘dms_test4.pdf’.





    • Hi,

      I may be wrong, but I think you need to keep in mind that the BAPI that was used is basically a programmatic  way of creating a document in SAP’s DMS (or basically, the same as transaction CV01N). So I guess you need to configure the FTP location in SAP’s DMS, but honestly I’m not an expert in this topic. I just stumbled upon a way of doing what I wanted to do, and shared in case someone has a similar requirement, but I can’t really support people on this.


  • Hi,

    one of my first post, hopefully I will not be out of scope 🙂

    I had a similar issue to create a Document info Record linked to an object and with files to be checked. The problem is that files are saved in an internal table as binaries and not stored somewhere on the server nor on the local PC of the user.

    So I wrote that function module which fulfilled my requirements:

    FUNCTION z_fm_ca_set_docments_to_dms.
    *"*"Local Interface:
      DATA: lt_objectlink     TYPE          tt_bapi_doc_drad,
            lt_objectlink_new TYPE          tt_bapi_doc_drad,
            lt_content        TYPE TABLE OF drao,
            lt_files          TYPE TABLE OF cvapi_doc_file,
            lt_comp_x         TYPE TABLE OF cvapi_doc_comp,
            lt_binary         TYPE TABLE OF orblk.
      DATA: ls_document TYPE bapi_doc_aux,
            ls_data     TYPE bapi_doc_draw2,
            ls_message  TYPE messages,
            ls_return   TYPE bapiret2.
      DATA: lv_file_size TYPE i.
      ls_data = is_document.
      IF ls_data-documenttype IS INITIAL.
        ls_data-documenttype    = zif_ps_cmt_m=>mc_dms_defaults-dms_type. "'GEN'
    * DMS document does not exist yet, create it.
      IF is_document-documentnumber  IS INITIAL AND
         is_document-documentpart    IS INITIAL AND
         is_document-documentversion IS INITIAL.
            documentdata    = is_document
            pf_ftp_dest     = zif_ca_constants=>gc_dms_ftp_rfc
            pf_http_dest    = zif_ca_constants=>gc_dms_http_rfc
            documenttype    = ls_document-doctype
            documentnumber  = ls_document-docnumber
            documentpart    = ls_document-docpart
            documentversion = ls_document-docversion
            return          = ls_return.
    *      TABLES
    *        objectlinks     = lt_objectlink.
        APPEND ls_return TO et_return.
        IF ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
              wait = 'X'.
      lt_objectlink_new = it_link.
      IF NOT lt_objectlink_new IS INITIAL AND ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
        CLEAR: ls_return.
            documenttype    = ls_document-doctype
            documentnumber  = ls_document-docnumber
            documentpart    = ls_document-docpart
            documentversion = ls_document-docversion
            return          = ls_return
            objectlinks     = lt_objectlink.
        APPEND ls_return TO et_return.
    *   Only add links that do not exist yet.
        LOOP AT lt_objectlink REFERENCE INTO DATA(lr_link).
          DELETE lt_objectlink_new WHERE objectkey  = lr_link->objectkey
                                     AND objecttype = lr_link->objecttype.
        IF NOT lt_objectlink_new IS INITIAL AND ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
          CLEAR: ls_return.
              documenttype    = ls_document-doctype
              documentnumber  = ls_document-docnumber
              documentpart    = ls_document-docpart
              documentversion = ls_document-docversion
              return          = ls_return
              objectlinks     = lt_objectlink_new.
          APPEND ls_return TO et_return.
          IF ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
                wait = 'X'.
    * Add files to created document
      IF NOT it_files IS INITIAL AND ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
        LOOP AT it_files REFERENCE INTO DATA(lr_file).
          CLEAR: lt_binary, lv_file_size, lt_content, lt_files.
              buffer          = lr_file->rawfile
              append_to_table = abap_false
              output_length   = lv_file_size
              binary_tab      = lt_binary.
          LOOP AT lt_binary REFERENCE INTO DATA(lr_binary).
            APPEND INITIAL LINE TO lt_content ASSIGNING FIELD-SYMBOL(<fs_content>).
            <fs_content>-dokar = ls_document-doctype.
            <fs_content>-doknr = ls_document-docnumber.
            <fs_content>-dokvr = ls_document-docversion.
            <fs_content>-doktl = ls_document-docpart.
            <fs_content>-zaehl = sy-tabix.
            <fs_content>-orln  = lv_file_size.
            <fs_content>-orblk = lr_binary->*.
            DESCRIBE FIELD <fs_content>-orblk LENGTH <fs_content>-orbkl IN BYTE MODE.
          <fs_file>-dttrg          = ls_document-dttrg.
          <fs_file>-storage_cat    = lr_file->storagecategory.
          IF <fs_file>-storage_cat  IS INITIAL.
            <fs_file>-storage_cat  = zif_ca_constants=>gc_dms_default_storage. "'DMS_C1_ST'
          <fs_file>-langu          = sy-langu.
          <fs_file>-pathname       = lr_file->docpath.
    *      <fs_file>-filename       = lr_attachment->docfile.
          <fs_file>-description    = lr_file->description.
          <fs_file>-created_at     = lr_file->created_at.
          <fs_file>-created_by     = lr_file->created_by.
          <fs_file>-changed_at     = lr_file->changed_at.
          <fs_file>-changed_by     = lr_file->changed_by.
          <fs_file>-file_id        = lr_file->file_id.
          <fs_file>-dappl          = lr_file->wsapplication.
          <fs_file>-appnr          = lr_file->originaltype.
          IF <fs_file>-appnr IS INITIAL.
            <fs_file>-appnr = zif_ca_constants=>gc_dms_original_view_only. "'1'
          <fs_file>-active_version = abap_true.
          IF <fs_file>-dappl IS INITIAL.
    *       Get corresponding application type
                pf_file   = lr_file->docfile
                pfx_dappl = <fs_file>-dappl.
              pf_dokar           = ls_document-doctype
              pf_doknr           = ls_document-docnumber
              pf_dokvr           = ls_document-docversion
              pf_doktl           = ls_document-docpart
    *         PS_DOC_STATUS      =
              pf_ftp_dest        = zif_ca_constants=>gc_dms_ftp_rfc  "'SAPFTPA'
              pf_http_dest       = zif_ca_constants=>gc_dms_http_rfc "'SAPHTTPA'
    *         PF_HOSTNAME        = ' '
    *         PS_API_CONTROL     =
              pf_replace         = abap_true
              pf_content_provide = 'TBL'
              psx_message        = ls_message
              pt_files_x         = lt_files
    *         pt_comp_x          = lt_comp_x
              pt_content         = lt_content.
          CLEAR ls_return.
          MOVE-CORRESPONDING ls_message TO ls_return.
          APPEND ls_return TO et_return.
          IF ls_return-type NA /srmsmc/if_supplier_c=>gc_message_types_failure.
                wait = 'X'.

    The function is quite simple as it creates first the DMS document is no document number is passed in structure “IS_DOCUMENT”, the add new linked objects passed in table “IT_LINKS” and finally for each row of table IT_FILES, convert the xstring to a binary table, get required details default values like application type, etc… (which are part of the customizing of DMS).

    Commits after each steps are required to avoid error like “Document XXX does not exist”.

    Hope it might help.

  • Hi Bruno,

    We created a program for uploading documents from application server. But the documents are not opening through transaction CV02N. We are getting the error message as shown below.

    I think the file path is not recorded correctly in CV02N through the program.  Only the file name is coming in the Original field.


    The program code is as shown below.

    REPORT  ztest_sample02.
    TYPES: BEGIN OF ts_document_hdr,
             type    TYPE dokar,
             number  TYPE doknr,
             part    TYPE doktl_d,
             version TYPE dokvr,
           END OF ts_document_hdr.
    DATA: ls_document_hdr  TYPE  ts_document_hdr,
          ls_documentdata  TYPE  bapi_doc_draw2,
          ls_documentdatax TYPE  bapi_doc_drawx2,
          ls_return        TYPE  bapiret2,
          ls_files         TYPE  bapi_doc_files2,
          lt_files         TYPE  STANDARD TABLE OF bapi_doc_files2.
      p_type      TYPE dokar    DEFAULT 'DMR',
      p_number    TYPE doknr    DEFAULT 'DMR100512     114D',
      p_part      TYPE doktl_d  DEFAULT '000',
      p_vers      TYPE dokvr    DEFAULT '01',
      p_path      TYPE dms_path DEFAULT '/tmp/',
      p_filnm     TYPE filep    DEFAULT 'doc.pdf',
      p_filty     TYPE dappl    DEFAULT 'PDF',
      p_datcar    TYPE dttrg    DEFAULT 'DV-1'.
    * Document Header
      ls_document_hdr-type    = p_type.
      ls_document_hdr-number  = p_number.
      ls_document_hdr-part    = p_part.
      ls_document_hdr-version = p_vers.
    * Document Data
      ls_documentdata-wsapplication2  = p_filty.
      ls_documentdatax-wsapplication2 = abap_true.
      ls_documentdata-docfile2        = p_path && p_filnm.
      ls_documentdatax-docfile2       = abap_true.
    * Document Files
      ls_files-documenttype      = ls_document_hdr-type.
      ls_files-documentnumber    = ls_document_hdr-number.
      ls_files-documentpart      = ls_document_hdr-part.
      ls_files-documentversion   = ls_document_hdr-version.
      ls_files-docpath           = p_path.
      ls_files-docfile           = p_filnm.
      ls_files-description       = 'Filename ' && p_path && p_filnm.
      ls_files-wsapplication     = p_filty.
      ls_files-sourcedatacarrier = p_datcar.
      ls_files-originaltype      = '1'.
      APPEND ls_files TO lt_files.
    * Attach file to the Document.
          documenttype    = ls_document_hdr-type
          documentnumber  = ls_document_hdr-number
          documentpart    = ls_document_hdr-part
          documentversion = ls_document_hdr-version
          documentdata    = ls_documentdata
          documentdatax   = ls_documentdatax
          return          = ls_return
          documentfiles   = lt_files.
      IF ls_return-type NE 'E'.
            wait = abap_true.
        MESSAGE s000(zz) WITH 'Success'.
        MESSAGE ID ls_return-id TYPE ls_return-type NUMBER ls_return-number
              WITH ls_return-message_v1 ls_return-message_v2 ls_return-message_v3 ls_return-message_v4.


    Any suggestion on what could be the issue here?


    Thanks in advance,


  • Hi All,

    I have a small question on DMS.

    While creating the document via FM ‘BAPI_DOCUMENT_CREATE2’ its goes into error “document category and documetn discpline required, we have customize the DMS as these two are always to be put as manadtory , how to handle this in progrm.

    Please suggest.


    Thanks & Regards,

    Raj Singh