<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create a Document in DMS server through a BAPI in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654914#M2015263</link>
    <description>&lt;P&gt;How is your question related to RFC please? (your tag)&lt;/P&gt;</description>
    <pubDate>Thu, 20 Apr 2023 21:52:12 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2023-04-20T21:52:12Z</dc:date>
    <item>
      <title>How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654908#M2015257</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt; I want to create a Document number with any file(PDF, JPG, TXT Etc) through BAPI, can anyone have Custom BAPI to create Document in DMS server, please help me on this requirement.&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Satheesh,&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 06:18:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654908#M2015257</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-20T06:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654909#M2015258</link>
      <description>&lt;P&gt;Did you have search a little bit before asking ?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 06:30:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654909#M2015258</guid>
      <dc:creator>FredericGirod</dc:creator>
      <dc:date>2023-04-20T06:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654910#M2015259</link>
      <description>&lt;P&gt;Hello Satheesh,&lt;/P&gt;&lt;P&gt;the following blog describes it in some detail with sample code:&lt;/P&gt;&lt;P&gt;&lt;A href="https://wiki.scn.sap.com/wiki/display/PLM/Calling+DMS+BAPIs+from+external+RFC+clients+without+using+CALLBACK+mechanism"&gt;Calling DMS BAPIs&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Regards, Ulrich&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 07:20:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654910#M2015259</guid>
      <dc:creator>Ulrich_Schmidt1</dc:creator>
      <dc:date>2023-04-20T07:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654911#M2015260</link>
      <description>&lt;P&gt;I guess you mean DMS from the CA-DMS application component in SAP ERP (CV01N, etc.), not the BC-SRV-KPR-DMS (Knowledge PROvider). You don't need to worry about the "server" where it's stored, you just need to use the BAPI for CA-DMS, named BAPI_DOCUMENT_*&lt;/P&gt;&lt;P&gt;Lots of questions and answers in the Web.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 08:42:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654911#M2015260</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-20T08:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654912#M2015261</link>
      <description>&lt;P&gt;Can you please provide the BAPI code for create Document in DMS server (CV01N) if you have any&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 11:55:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654912#M2015261</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-20T11:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654913#M2015262</link>
      <description>&lt;P&gt;With "BAPI code" you mean "ABAP code"?&lt;/P&gt;&lt;P&gt;I only have the C/C++, Java and C# code. I thought the question was about how to call the DMS BAPIs via RFC from an external program, because the question is tagged with "&lt;STRONG&gt;NW ABAP Remote Function Call (RFC)&lt;/STRONG&gt;", which is the sapnwrfc.dll for C/C++.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 20:09:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654913#M2015262</guid>
      <dc:creator>Ulrich_Schmidt1</dc:creator>
      <dc:date>2023-04-20T20:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654914#M2015263</link>
      <description>&lt;P&gt;How is your question related to RFC please? (your tag)&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 21:52:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654914#M2015263</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-20T21:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654915#M2015264</link>
      <description>&lt;P&gt;Hi Sandra,&lt;/P&gt;&lt;P&gt;    I want to Create document in DMS server with RFC/BAPI, can you please share me the BAPI code for create document in DMS server through BAPI_DOCUMENT_CREATE2.&lt;/P&gt;&lt;P&gt;I have develpoped one BAPI for create document in DMS server, but using this code, when we are giving input in XSTRING, then only I am able to create Document, but that created document I am not able to open, please find the below code and give any other inputs.&lt;/P&gt;&lt;P&gt;BAPI Code below:&lt;/P&gt;&lt;P&gt;FUNCTION /PILOG/DMS_CREATE.&lt;/P&gt;&lt;P&gt;*"----------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;*"*"Local Interface:&lt;/P&gt;&lt;P&gt;*"  CHANGING&lt;/P&gt;&lt;P&gt;*"     VALUE(CS_FILE) TYPE  /PILOG/DMS_FILE OPTIONAL&lt;/P&gt;&lt;P&gt;*"----------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;DATA: LS_DOCDATA     TYPE BAPI_DOC_DRAW2.&lt;/P&gt;&lt;P&gt;DATA: LS_OBJECTLINK  TYPE BAPI_DOC_DRAD.&lt;/P&gt;&lt;P&gt;DATA: LT_OBJECTLINKS TYPE TABLE OF BAPI_DOC_DRAD.&lt;/P&gt;&lt;P&gt;DATA: LS_OBJECTDESCR TYPE BAPI_DOC_DRAT.&lt;/P&gt;&lt;P&gt;DATA: LT_OBJECTDESCR TYPE TABLE OF BAPI_DOC_DRAT.&lt;/P&gt;&lt;P&gt;DATA: LS_OBJECTFILE  TYPE BAPI_DOC_FILES2.&lt;/P&gt;&lt;P&gt;DATA: LT_OBJECTFILES TYPE TABLE OF BAPI_DOC_FILES2.&lt;/P&gt;&lt;P&gt;DATA: RETURN TYPE BAPIRET2.&lt;/P&gt;&lt;P&gt;data: gs_tdwat TYPE tdwat,&lt;/P&gt;&lt;P&gt;      access_info like STANDARD TABLE OF scms_acinf WITH HEADER LINE,&lt;/P&gt;&lt;P&gt;      gt_bin type STANDARD TABLE OF raw255,&lt;/P&gt;&lt;P&gt;      gs_bin type raw255.&lt;/P&gt;&lt;P&gt;data: LV_FILENAME type STRING.&lt;/P&gt;&lt;P&gt;DATA: dV_DOCTYPE     TYPE DOKAR.&lt;/P&gt;&lt;P&gt;DATA: dV_objtype   TYPE DOKOB value 'kna1'.&lt;/P&gt;&lt;P&gt;DATA: dV_dktxt     TYPE Dktxt.&lt;/P&gt;&lt;P&gt;DATA: GV_FLAG TYPE FLAG.&lt;/P&gt;&lt;P&gt;if cs_file-DOKAR       is NOT INITIAL and&lt;/P&gt;&lt;P&gt;   cs_file-FILE_NAME   is NOT INITIAL and&lt;/P&gt;&lt;P&gt;   cs_file-FILE_TYPE   is NOT INITIAL and&lt;/P&gt;&lt;P&gt;   cs_file-DESCRIPTION is NOT INITIAL and&lt;/P&gt;&lt;P&gt;   cs_file-XSTRING     is NOT INITIAL.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    buffer                = cs_file-XSTRING&lt;/P&gt;&lt;P&gt;*   APPEND_TO_TABLE       = ' '&lt;/P&gt;&lt;P&gt; IMPORTING&lt;/P&gt;&lt;P&gt;   OUTPUT_LENGTH         = access_info-comp_size&lt;/P&gt;&lt;P&gt;  tables&lt;/P&gt;&lt;P&gt;    binary_tab            = GT_BIN.&lt;/P&gt;&lt;P&gt;*CONCATENATE 'D:\usr\sap\S29\D00\work/' cs_file-file_name into LV_FILENAME.&lt;/P&gt;&lt;P&gt;CONCATENATE '/tmp/' cs_file-file_name into LV_FILENAME.&lt;/P&gt;&lt;P&gt;OPEN dataset LV_FILENAME for OUTPUT in BINARY MODE.&lt;/P&gt;&lt;P&gt;loop at gt_bin into GS_BIN.&lt;/P&gt;&lt;P&gt;  TRANSFER GS_BIN to LV_FILENAME.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;close DATASET LV_FILENAME.&lt;/P&gt;&lt;P&gt;wait UP TO 1 SECONDS.&lt;/P&gt;&lt;P&gt;OPEN DATASET LV_FILENAME for OUTPUT in BINARY MODE.&lt;/P&gt;&lt;P&gt;  if sy-subrc = 0.&lt;/P&gt;&lt;P&gt;    GV_FLAG = 'X'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;  CLOSE DATASET LV_FILENAME.&lt;/P&gt;&lt;P&gt;IF GV_FLAG IS NOT INITIAL.&lt;/P&gt;&lt;P&gt;ls_docdata-documenttype    = cs_file-dokar.&lt;/P&gt;&lt;P&gt;ls_docdata-documentversion = '00'."cs_file-dokar.&lt;/P&gt;&lt;P&gt;ls_docdata-documentpart    = '000'."cs_file-dokar.&lt;/P&gt;&lt;P&gt;ls_docdata-statusextern    = 'AA'."cs_file-dokar.&lt;/P&gt;&lt;P&gt;**ls_docdata-statusintern    = 'AA'."cs_file-dokar.&lt;/P&gt;&lt;P&gt;ls_objectdescr-description  = cs_file-description.&lt;/P&gt;&lt;P&gt;  ls_objectdescr-language     = 'E'.&lt;/P&gt;&lt;P&gt;  ls_objectdescr-language_iso = 'EN'.&lt;/P&gt;&lt;P&gt;  APPEND ls_objectdescr TO lt_objectdescr.&lt;/P&gt;&lt;P&gt;**    ls_objectfile-originaltype      =  originaltype .&lt;/P&gt;&lt;P&gt;**    ls_objectfile-sourcedatacarrier =  sourcedatacarrier.&lt;/P&gt;&lt;P&gt;    ls_objectfile-storagecategory   =  'DMS_C1_ST'."storagecategory .&lt;/P&gt;&lt;P&gt;    ls_objectfile-created_by        =  sy-uname.&lt;/P&gt;&lt;P&gt;    ls_objectfile-docfile           =  LV_FILENAME.&lt;/P&gt;&lt;P&gt;    ls_objectfile-wsapplication     =  cs_file-file_type."wsapplication.&lt;/P&gt;&lt;P&gt;    ls_objectfile-checkedin     =  'X'."cs_file-file_type.&lt;/P&gt;&lt;P&gt;    ls_objectfile-statusextern     =  'AR'."cs_file-file_type.&lt;/P&gt;&lt;P&gt;**    ls_objectfile-statusintern     =  'WR'."cs_file-file_type.&lt;/P&gt;&lt;P&gt;    APPEND ls_objectfile TO lt_objectfiles.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'&lt;/P&gt;&lt;P&gt;  EXPORTING&lt;/P&gt;&lt;P&gt;    documentdata               = ls_docdata&lt;/P&gt;&lt;P&gt;*   HOSTNAME                   =&lt;/P&gt;&lt;P&gt;*   DOCBOMCHANGENUMBER         =&lt;/P&gt;&lt;P&gt;*   DOCBOMVALIDFROM            =&lt;/P&gt;&lt;P&gt;*   DOCBOMREVISIONLEVEL        =&lt;/P&gt;&lt;P&gt;*   CAD_MODE                   = ' '&lt;/P&gt;&lt;P&gt;   PF_FTP_DEST                = 'SAPFTPA'&lt;/P&gt;&lt;P&gt;   PF_HTTP_DEST               = 'SAPHTTP'&lt;/P&gt;&lt;P&gt;**   DEFAULTCLASS               = 'X'&lt;/P&gt;&lt;P&gt; IMPORTING&lt;/P&gt;&lt;P&gt;*   DOCUMENTTYPE               =&lt;/P&gt;&lt;P&gt;   DOCUMENTNUMBER             = cs_file-doknr&lt;/P&gt;&lt;P&gt;*   DOCUMENTPART               =&lt;/P&gt;&lt;P&gt;*   DOCUMENTVERSION            =&lt;/P&gt;&lt;P&gt;   RETURN                     = return&lt;/P&gt;&lt;P&gt; TABLES&lt;/P&gt;&lt;P&gt;*   CHARACTERISTICVALUES       =&lt;/P&gt;&lt;P&gt;*   CLASSALLOCATIONS           =&lt;/P&gt;&lt;P&gt;   DOCUMENTDESCRIPTIONS       = lt_objectdescr&lt;/P&gt;&lt;P&gt;*   OBJECTLINKS                =&lt;/P&gt;&lt;P&gt;*   DOCUMENTSTRUCTURE          =&lt;/P&gt;&lt;P&gt;   DOCUMENTFILES              = lt_objectfiles.&lt;/P&gt;&lt;P&gt;*   LONGTEXTS                  =&lt;/P&gt;&lt;P&gt;*   COMPONENTS                 =&lt;/P&gt;&lt;P&gt; if cs_file-doknr is NOT INITIAL.&lt;/P&gt;&lt;P&gt;       COMMIT WORK.&lt;/P&gt;&lt;P&gt;       CONCATENATE 'DMS Document' cs_file-doknr  'Generated Successfully' into cs_file-message SEPARATED BY space.&lt;/P&gt;&lt;P&gt;       else.&lt;/P&gt;&lt;P&gt;         cs_file-message = 'error while create document'.&lt;/P&gt;&lt;P&gt;       endif.&lt;/P&gt;&lt;P&gt;    ELSE.&lt;/P&gt;&lt;P&gt;      cs_file-message = 'error while creating file in application server' .&lt;/P&gt;&lt;P&gt;    endif.&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;  cs_file-message = 'pass all the required parameters'.&lt;/P&gt;&lt;P&gt; endif.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 06:29:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654915#M2015264</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-21T06:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654916#M2015265</link>
      <description>&lt;P&gt;Structure with fields for /pilog/dms_file as below.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/storage/temp/2161339-image.png" data-attachment="2161339"&gt;image.png&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 06:34:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654916#M2015265</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-21T06:34:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654917#M2015266</link>
      <description>&lt;P&gt;Please use the button [CODE] to format code, which makes the code appear colored/indented, it will be easier for people to look at it. &lt;/P&gt;&lt;P&gt;Please show the images instead of hyperlinks, in order to have both the text and the image in one place.&lt;/P&gt;&lt;P&gt;Just copy/paste the image:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2160390-image.png" /&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 08:21:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654917#M2015266</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-21T08:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654918#M2015267</link>
      <description>&lt;P&gt;I can't read very well your code because not indented and no colors, but I can see that you are writing extra 0 bytes to the file, and you are doing lot of useless stuff. Also file on application server -&amp;gt; SAPFTPA and SAPHTTPA (both with trailing "A").&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 08:28:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654918#M2015267</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-21T08:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654919#M2015268</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;   I am able to create Document with my provided code, but when I am trying to open that file, it is showing erroe as "It is not supported file type or the file has been damaged". can you please help on this&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 11:18:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654919#M2015268</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-21T11:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654920#M2015269</link>
      <description>&lt;P&gt;I'm sorry, I would like to fix your code, but as I said I can't read very well your code because not indented and no colors, hopefully you can use the button [CODE] to format code, which makes the code appear colored/indented,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer = cs_file-XSTRING&lt;BR /&gt;...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Apr 2023 12:18:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654920#M2015269</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-21T12:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654921#M2015270</link>
      <description>&lt;P&gt;Hi Sandra Rossi,&lt;/P&gt;&lt;P&gt;Please find the below code,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FUNCTION /PILOG/DMS_CREATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  CHANGING
*"     VALUE(CS_FILE) TYPE  /PILOG/DMS_FILE OPTIONAL
*"----------------------------------------------------------------------
DATA: LS_DOCDATA     TYPE BAPI_DOC_DRAW2.
DATA: LS_OBJECTLINK  TYPE BAPI_DOC_DRAD.
DATA: LT_OBJECTLINKS TYPE TABLE OF BAPI_DOC_DRAD.
DATA: LS_OBJECTDESCR TYPE BAPI_DOC_DRAT.
DATA: LT_OBJECTDESCR TYPE TABLE OF BAPI_DOC_DRAT.
DATA: LS_OBJECTFILE  TYPE BAPI_DOC_FILES2.
DATA: LT_OBJECTFILES TYPE TABLE OF BAPI_DOC_FILES2.
DATA: RETURN TYPE BAPIRET2.

data: gs_tdwat TYPE tdwat,
      access_info like STANDARD TABLE OF scms_acinf WITH HEADER LINE,
      gt_bin type STANDARD TABLE OF raw255,
      gs_bin type raw255.

data: LV_FILENAME type STRING.
DATA: dV_DOCTYPE     TYPE DOKAR.
DATA: dV_objtype   TYPE DOKOB value 'kna1'.
DATA: dV_dktxt     TYPE Dktxt.
DATA: GV_FLAG TYPE FLAG.


if cs_file-DOKAR       is NOT INITIAL and
   cs_file-FILE_NAME   is NOT INITIAL and
   cs_file-FILE_TYPE   is NOT INITIAL and
   cs_file-DESCRIPTION is NOT INITIAL and
   cs_file-XSTRING     is NOT INITIAL.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer                = cs_file-XSTRING
*   APPEND_TO_TABLE       = ' '
 IMPORTING
   OUTPUT_LENGTH         = access_info-comp_size
  tables
    binary_tab            = GT_BIN.

*CONCATENATE 'D:\usr\sap\S29\D00\work/' cs_file-file_name into LV_FILENAME.
CONCATENATE '/tmp/' cs_file-file_name into LV_FILENAME.

OPEN dataset LV_FILENAME for OUTPUT in BINARY MODE.

loop at gt_bin into GS_BIN.
  TRANSFER GS_BIN to LV_FILENAME.
ENDLOOP.

close DATASET LV_FILENAME.
wait UP TO 1 SECONDS.

OPEN DATASET LV_FILENAME for OUTPUT in BINARY MODE.
  if sy-subrc = 0.
    GV_FLAG = 'X'.
  ENDIF.
  CLOSE DATASET LV_FILENAME.

IF GV_FLAG IS NOT INITIAL.

ls_docdata-documenttype    = cs_file-dokar.
ls_docdata-documentversion = '00'."cs_file-dokar.
ls_docdata-documentpart    = '000'."cs_file-dokar.
ls_docdata-statusextern    = 'AA'."cs_file-dokar.
**ls_docdata-statusintern    = 'AA'."cs_file-dokar.

ls_objectdescr-description  = cs_file-description.
  ls_objectdescr-language     = 'E'.
  ls_objectdescr-language_iso = 'EN'.
  APPEND ls_objectdescr TO lt_objectdescr.

**    ls_objectfile-originaltype      =  originaltype .
**    ls_objectfile-sourcedatacarrier =  sourcedatacarrier.
    ls_objectfile-storagecategory   =  'DMS_C1_ST'."storagecategory .
    ls_objectfile-created_by        =  sy-uname.
    ls_objectfile-docfile           =  LV_FILENAME.
    ls_objectfile-wsapplication     =  cs_file-file_type."wsapplication.
    ls_objectfile-checkedin     =  'X'."cs_file-file_type.
    ls_objectfile-statusextern     =  'AR'."cs_file-file_type.
**    ls_objectfile-statusintern     =  'WR'."cs_file-file_type.
    APPEND ls_objectfile TO lt_objectfiles.


CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
  EXPORTING
    documentdata               = ls_docdata
*   HOSTNAME                   =
*   DOCBOMCHANGENUMBER         =
*   DOCBOMVALIDFROM            =
*   DOCBOMREVISIONLEVEL        =
*   CAD_MODE                   = ' '
   PF_FTP_DEST                = 'SAPFTPA'
   PF_HTTP_DEST               = 'SAPHTTP'
**   DEFAULTCLASS               = 'X'
 IMPORTING
*   DOCUMENTTYPE               =
   DOCUMENTNUMBER             = cs_file-doknr
*   DOCUMENTPART               =
*   DOCUMENTVERSION            =
   RETURN                     = return
 TABLES
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
   DOCUMENTDESCRIPTIONS       = lt_objectdescr
*   OBJECTLINKS                =
*   DOCUMENTSTRUCTURE          =
   DOCUMENTFILES              = lt_objectfiles.
*   LONGTEXTS                  =
*   COMPONENTS                 =
          .

     if cs_file-doknr is NOT INITIAL.

       COMMIT WORK.

       CONCATENATE 'DMS Document' cs_file-doknr  'Generated Successfully' into cs_file-message SEPARATED BY space.

       else.
         cs_file-message = 'error while create document'.
       endif.



    ELSE.
      cs_file-message = 'error while creating file in application server' .
    endif.




else.
  cs_file-message = 'pass all the required parameters'.
 endif.
&lt;/CODE&gt;&lt;/PRE&gt;Thanks,Satheesh kumar</description>
      <pubDate>Fri, 21 Apr 2023 13:02:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654921#M2015270</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-21T13:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654922#M2015271</link>
      <description>&lt;P&gt;&lt;B&gt;You write an empty file, because you do twice &lt;/B&gt;OPEN DATASET ... FOR OUTPUT ... (create or replace) consecutively &lt;B&gt;on the same file path&lt;/B&gt;, and second time you just clear the file.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;OPEN dataset LV_FILENAME for OUTPUT in BINARY MODE.

loop at gt_bin into GS_BIN.
  TRANSFER GS_BIN to LV_FILENAME.
ENDLOOP.

close DATASET LV_FILENAME.
wait UP TO 1 SECONDS.

OPEN DATASET LV_FILENAME for OUTPUT in BINARY MODE.
  if sy-subrc = 0.
    GV_FLAG = 'X'.
  ENDIF.
  CLOSE DATASET LV_FILENAME.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Delete the second block [OPEN DATASET ... FOR OUTPUT ... ] ... [CLOSE DATASET ... ].&lt;/P&gt;&lt;P&gt;Remove even the logic about GV_FLAG (unclear name for "file has been created successfully", see Clean ABAP guide of the importance to use meaningful names), because you know that dataset is correctly written if SY-SUBRC = 0 after each dataset instruction (see ABAP documentation). An error may possibly trigger a class-based exception too.&lt;/P&gt;&lt;P&gt;NB: you are incorrectly mixing application server/frontend RFC destinations:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;   PF_FTP_DEST                = 'SAPFTPA'
   PF_HTTP_DEST               = 'SAPHTTP'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;For &lt;STRONG&gt;application server &lt;/STRONG&gt;(which is your case), it must be all &lt;STRONG&gt;with &lt;/STRONG&gt;trailing "A":&lt;PRE&gt;&lt;CODE&gt;   PF_FTP_DEST                = 'SAPFTPA'
   PF_HTTP_DEST               = 'SAPHTTPA'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;For &lt;STRONG&gt;frontend &lt;/STRONG&gt;(which is not your case), it must be &lt;STRONG&gt;without &lt;/STRONG&gt;trailing "A":&lt;PRE&gt;&lt;CODE&gt;   PF_FTP_DEST                = 'SAPFTP'
   PF_HTTP_DEST               = 'SAPHTTP'&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;NB: calling SCMS_XSTRING_TO_BINARY is useless because you can directly write cs_file-XSTRING to the file:&lt;PRE&gt;&lt;CODE&gt;TRY.&lt;BR /&gt;    OPEN dataset LV_FILENAME for OUTPUT in BINARY MODE.&lt;BR /&gt;    IF sy-subrc = 0.&lt;BR /&gt;      TRANSFER cs_file-XSTRING to LV_FILENAME. " &amp;lt;=================== write whole file&lt;BR /&gt;      close DATASET LV_FILENAME.
      IF sy-subrc &amp;lt;&amp;gt; 0.
        " handle error although technically speaking in the current situation sy-subrc is always 0
      ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;NB: cleanup your code before posting because many unused lines hurt like lowercase 'kna1':&lt;BR /&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: dV_objtype   TYPE DOKOB value 'kna1'.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After calling a create/update/delete BAPI, you must call BAPI_TRANSACTION_COMMIT instead of COMMIT WORK as rule of thumb, because usually people don't know for which BAPI it is mandatory to call it. Same for BAPI_TRANSACTION_ROLLBACK/ROLLBACK WORK.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 19:12:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654922#M2015271</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-21T19:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654923#M2015272</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 19:13:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654923#M2015272</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-21T19:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654924#M2015273</link>
      <description>&lt;P&gt;Hi Sandra Rossi,&lt;/P&gt;&lt;P&gt;I
have changed the code as per your inputs, when I test it We are able to create
Document in DMS server and able to see in CV03N as well.&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2160410-image.png" /&gt;&lt;/P&gt;&lt;P&gt;But When I am trying to open
that file in CV03N, it is showing below error, kindly help me on this.&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2160409-image.png" /&gt;&lt;/P&gt;&lt;P&gt;please find below code .&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FUNCTION /PILOG/DMS_CREATE.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  CHANGING
*"     VALUE(CS_FILE) TYPE  /PILOG/DMS_FILE OPTIONAL
*"----------------------------------------------------------------------
DATA: LS_DOCDATA     TYPE BAPI_DOC_DRAW2.
DATA: LS_OBJECTLINK  TYPE BAPI_DOC_DRAD.
DATA: LT_OBJECTLINKS TYPE TABLE OF BAPI_DOC_DRAD.
DATA: LS_OBJECTDESCR TYPE BAPI_DOC_DRAT.
DATA: LT_OBJECTDESCR TYPE TABLE OF BAPI_DOC_DRAT.
DATA: LS_OBJECTFILE  TYPE BAPI_DOC_FILES2.
DATA: LT_OBJECTFILES TYPE TABLE OF BAPI_DOC_FILES2.
DATA: RETURN TYPE BAPIRET2.

data: gs_tdwat TYPE tdwat,
      access_info like STANDARD TABLE OF scms_acinf WITH HEADER LINE,
      gt_bin type STANDARD TABLE OF raw255,
      gs_bin type raw255.

data: LV_FILENAME type STRING.
DATA: dV_DOCTYPE     TYPE DOKAR.
**DATA: dV_objtype   TYPE DOKOB value 'kna1'.
DATA: dV_dktxt     TYPE Dktxt.
DATA: GV_FLAG TYPE FLAG.


if cs_file-DOKAR       is NOT INITIAL and
   cs_file-FILE_NAME   is NOT INITIAL and
   cs_file-FILE_TYPE   is NOT INITIAL and
   cs_file-DESCRIPTION is NOT INITIAL and
   cs_file-XSTRING     is NOT INITIAL.

***CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
***  EXPORTING
***    buffer                = cs_file-XSTRING
****   APPEND_TO_TABLE       = ' '
*** IMPORTING
***   OUTPUT_LENGTH         = access_info-comp_size
***  tables
***    binary_tab            = GT_BIN.

*CONCATENATE 'D:\usr\sap\S29\D00\work/' cs_file-file_name into LV_FILENAME.
CONCATENATE '/tmp/' cs_file-file_name into LV_FILENAME.

OPEN dataset LV_FILENAME for OUTPUT in BINARY MODE.
If sy-subrc = 0.
       TRANSFER cs_file-XSTRING to LV_FILENAME.

close DATASET LV_FILENAME.

if sy-subrc &amp;lt;&amp;gt; 0.
     "handle error although technically
  endif.

  ENDIF.
wait UP TO 1 SECONDS.

**OPEN DATASET LV_FILENAME for OUTPUT in BINARY MODE.
  if sy-subrc = 0.
    GV_FLAG = 'X'.
  ENDIF.
**  CLOSE DATASET LV_FILENAME.

IF GV_FLAG IS NOT INITIAL.

ls_docdata-documenttype    = cs_file-dokar.
ls_docdata-documentversion = '00'."cs_file-dokar.
ls_docdata-documentpart    = '000'."cs_file-dokar.
ls_docdata-statusextern    = 'AA'."cs_file-dokar.
**ls_docdata-statusintern    = 'AA'."cs_file-dokar.

ls_objectdescr-description  = cs_file-description.
  ls_objectdescr-language     = 'E'.
  ls_objectdescr-language_iso = 'EN'.
  APPEND ls_objectdescr TO lt_objectdescr.

**    ls_objectfile-originaltype      =  originaltype .
**    ls_objectfile-sourcedatacarrier =  sourcedatacarrier.
    ls_objectfile-storagecategory   =  'DMS_C1_ST'."storagecategory .
    ls_objectfile-created_by        =  sy-uname.
**    ls_objectfile-docpath        =  '/tmp/'.
    ls_objectfile-docfile           =  LV_FILENAME.
    ls_objectfile-wsapplication     =  cs_file-file_type."wsapplication.
    ls_objectfile-checkedin     =  'X'."cs_file-file_type.
    ls_objectfile-statusextern     =  'AA'."cs_file-file_type.
**    ls_objectfile-statusintern     =  'WR'."cs_file-file_type.
    APPEND ls_objectfile TO lt_objectfiles.


CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
  EXPORTING
    documentdata               = ls_docdata
*   HOSTNAME                   =
*   DOCBOMCHANGENUMBER         =
*   DOCBOMVALIDFROM            =
*   DOCBOMREVISIONLEVEL        =
*   CAD_MODE                   = ' '
   PF_FTP_DEST                = 'SAPFTPA'
   PF_HTTP_DEST               = 'SAPHTTPA'
**   DEFAULTCLASS               = 'X'
 IMPORTING
*   DOCUMENTTYPE               =
   DOCUMENTNUMBER             = cs_file-doknr
*   DOCUMENTPART               =
*   DOCUMENTVERSION            =
   RETURN                     = return
 TABLES
*   CHARACTERISTICVALUES       =
*   CLASSALLOCATIONS           =
   DOCUMENTDESCRIPTIONS       = lt_objectdescr
*   OBJECTLINKS                =
*   DOCUMENTSTRUCTURE          =
   DOCUMENTFILES              = lt_objectfiles.
*   LONGTEXTS                  =
*   COMPONENTS                 =
          .

     if cs_file-doknr is NOT INITIAL.

**       COMMIT WORK.

       CONCATENATE 'DMS Document' cs_file-doknr  'Generated Successfully' into cs_file-message SEPARATED BY space.
            CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
          .
       else.
         cs_file-message = 'error while create document'.
       endif.



    ELSE.
      cs_file-message = 'error while creating file in application server' .
    endif.




else.
  cs_file-message = 'pass all the required parameters'.
 endif.






ENDFUNCTION.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2023 15:47:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654924#M2015273</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-22T15:47:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654925#M2015274</link>
      <description>&lt;P&gt;Do I correctly see that your XSTRING is starting with EF BB BF? It's UTF-8 BOM, not PDF format at all...&lt;/P&gt;&lt;P&gt;The issue is not about the code, the issue is about the value of input XSTRING.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2023 08:37:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654925#M2015274</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-23T08:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654926#M2015275</link>
      <description>&lt;P&gt;Hi Sandra,&lt;/P&gt;&lt;P&gt;     Can you please help me on this value of input XTRING, how we can resolve this.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Satheesh.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 05:07:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654926#M2015275</guid>
      <dc:creator>SATHEESHKUMAR_1</dc:creator>
      <dc:date>2023-04-24T05:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a Document in DMS server through a BAPI</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654927#M2015276</link>
      <description>&lt;P&gt;It's wrong input value. How can you imagine that I can do anything about it? Only you can pass correct input value.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Apr 2023 06:00:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/how-to-create-a-document-in-dms-server-through-a-bapi/m-p/12654927#M2015276</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-04-24T06:00:41Z</dc:date>
    </item>
  </channel>
</rss>

