<?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 BAPI_DOCUMENT_CREATE2 Longtext N lines problem in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175210#M1979381</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;
  &lt;P&gt;I'm using this BAPI_DOCUMENT_CREATE2 to create a CV01N document, when the user choose a PDF file to upload and put a text to justify its necessity.&lt;/P&gt;
  &lt;P&gt;The user can fill two or more lines.&lt;/P&gt;
  &lt;P&gt;But when I execute it filling 2 or 3 lines, the longtext has just one line in the created document when I enter CV03N to see it.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Follow &lt;/STRONG&gt;an attached CV03N document showing only one line on description tab. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;FORM upload_anexo CHANGING p_documentnumber TYPE bapi_doc_aux-docnumber.


 DATA:
  "BAPI_DOCUMENT_CREATE2
 ls_documentdata LIKE bapi_doc_draw2,
 lt_documentfiles TYPE STANDARD TABLE OF bapi_doc_files2,
 ls_documentfiles LIKE LINE OF lt_documentfiles,
 lt_longtexts TYPE STANDARD TABLE OF bapi_doc_text,
 ls_longtexts LIKE LINE OF lt_longtexts,
 lv_documentnumber TYPE bapi_doc_aux-docnumber, 
 ls_return TYPE bapiret2.


 CLEAR p_documentnumber.


*--------------------------------------------------------------------*
 " obligate user to fill text to justify the bill.
*--------------------------------------------------------------------*
 CALL SCREEN 200.


 " Read user text writen on 0200 screen (editor box)
 " back from screen 0200
 IF g_mytable[] IS NOT INITIAL.
 FREE lt_longtexts.


 LOOP AT g_mytable INTO DATA(ls_mytable).
   CLEAR ls_longtexts.
*  ls_longtexts-deletevalue
   ls_longtexts-language = 'P'."sy-langu.
   ls_longtexts-language_iso = 'PT'."sy-langu.
   ls_longtexts-textline = ls_mytable-line.
   INSERT ls_longtexts INTO TABLE lt_longtexts.
 ENDLOOP.

 ELSE.
   MESSAGE s000(zsd) WITH 'Error, user did not fill text'
                     DISPLAY LIKE 'E'.
   RETURN.
 ENDIF.


*--------------------------------------------------------------------*
 " GET FILENAME
*--------------------------------------------------------------------*
 PERFORM ler_arquivo_comprovante.


 " READ filename
 READ TABLE ti_file INTO DATA(ls_file) INDEX 1.
 IF sy-subrc = 0.
   ls_documentfiles-documenttype = 'ZAV'."Generate unic name on the system 16 characteres

  TRY.
   ls_documentfiles-documentnumber = cl_system_uuid=&amp;gt;create_uuid_x16_static( ).

  CATCH cx_uuid_error. "
    MESSAGE s000(zsd) WITH 'Error'
    DISPLAY LIKE 'E'.
    RETURN.
  ENDTRY.


   ls_documentfiles-documentpart = '000'.
   ls_documentfiles-documentversion = '00'.
   ls_documentfiles-storagecategory = 'DMS_C1_ST'.
   ls_documentfiles-wsapplication = 'PDF'.
   ls_documentfiles-docfile = ls_file-filename.
   ls_documentfiles-description = 'Bill example'.
   ls_documentfiles-language = 'PT'.
   INSERT ls_documentfiles INTO TABLE lt_documentfiles.
 ENDIF.


 BREAK-POINT.
*--------------------------------------------------------------------*
 " CREATE DOCUMENT CV01N
*--------------------------------------------------------------------*
 ls_documentdata-documenttype = 'ZAV'.
 ls_documentdata-documentnumber = ls_documentfiles-documentnumber. " CHAR16 unic code
 ls_documentdata-documentversion = '00'.
 ls_documentdata-documentpart = '000'.
 ls_documentdata-description = 'Bill example'.
 ls_documentdata-username = sy-uname.
 ls_documentdata-statusintern = 'LB'. "released
 

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
 EXPORTING
    documentdata = ls_documentdata
*   HOSTNAME =
*   DOCBOMCHANGENUMBER =
*   DOCBOMVALIDFROM =
*   DOCBOMREVISIONLEVEL =
*   CAD_MODE = ' '
*   PF_FTP_DEST = ' '
*   PF_HTTP_DEST = ' '
*   DEFAULTCLASS = 'X'
 IMPORTING
*   DOCUMENTTYPE =
    documentnumber = lv_documentnumber
*   DOCUMENTPART =
*   DOCUMENTVERSION =
    return = ls_return
 TABLES
*   CHARACTERISTICVALUES =
*   CLASSALLOCATIONS =
*   DOCUMENTDESCRIPTIONS =
*   OBJECTLINKS =
*   DOCUMENTSTRUCTURE =
    documentfiles = lt_documentfiles
    longtexts = lt_longtexts
*   COMPONENTS =cv01n-text-just-1-line-error.png
 .


 IF lv_documentnumber IS NOT INITIAL.
   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
   EXPORTING
      wait = 'X'.
     p_documentnumber = lv_documentnumber.
 ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    MESSAGE s000(zsd) WITH 'Error while creating doc'
                      DISPLAY LIKE 'E'.
    RETURN.
 ENDIF.


ENDFORM. " UPLOAD_ANEXO&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 18 Jan 2020 00:01:24 GMT</pubDate>
    <dc:creator>glauco</dc:creator>
    <dc:date>2020-01-18T00:01:24Z</dc:date>
    <item>
      <title>BAPI_DOCUMENT_CREATE2 Longtext N lines problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175210#M1979381</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;
  &lt;P&gt;I'm using this BAPI_DOCUMENT_CREATE2 to create a CV01N document, when the user choose a PDF file to upload and put a text to justify its necessity.&lt;/P&gt;
  &lt;P&gt;The user can fill two or more lines.&lt;/P&gt;
  &lt;P&gt;But when I execute it filling 2 or 3 lines, the longtext has just one line in the created document when I enter CV03N to see it.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Follow &lt;/STRONG&gt;an attached CV03N document showing only one line on description tab. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;FORM upload_anexo CHANGING p_documentnumber TYPE bapi_doc_aux-docnumber.


 DATA:
  "BAPI_DOCUMENT_CREATE2
 ls_documentdata LIKE bapi_doc_draw2,
 lt_documentfiles TYPE STANDARD TABLE OF bapi_doc_files2,
 ls_documentfiles LIKE LINE OF lt_documentfiles,
 lt_longtexts TYPE STANDARD TABLE OF bapi_doc_text,
 ls_longtexts LIKE LINE OF lt_longtexts,
 lv_documentnumber TYPE bapi_doc_aux-docnumber, 
 ls_return TYPE bapiret2.


 CLEAR p_documentnumber.


*--------------------------------------------------------------------*
 " obligate user to fill text to justify the bill.
*--------------------------------------------------------------------*
 CALL SCREEN 200.


 " Read user text writen on 0200 screen (editor box)
 " back from screen 0200
 IF g_mytable[] IS NOT INITIAL.
 FREE lt_longtexts.


 LOOP AT g_mytable INTO DATA(ls_mytable).
   CLEAR ls_longtexts.
*  ls_longtexts-deletevalue
   ls_longtexts-language = 'P'."sy-langu.
   ls_longtexts-language_iso = 'PT'."sy-langu.
   ls_longtexts-textline = ls_mytable-line.
   INSERT ls_longtexts INTO TABLE lt_longtexts.
 ENDLOOP.

 ELSE.
   MESSAGE s000(zsd) WITH 'Error, user did not fill text'
                     DISPLAY LIKE 'E'.
   RETURN.
 ENDIF.


*--------------------------------------------------------------------*
 " GET FILENAME
*--------------------------------------------------------------------*
 PERFORM ler_arquivo_comprovante.


 " READ filename
 READ TABLE ti_file INTO DATA(ls_file) INDEX 1.
 IF sy-subrc = 0.
   ls_documentfiles-documenttype = 'ZAV'."Generate unic name on the system 16 characteres

  TRY.
   ls_documentfiles-documentnumber = cl_system_uuid=&amp;gt;create_uuid_x16_static( ).

  CATCH cx_uuid_error. "
    MESSAGE s000(zsd) WITH 'Error'
    DISPLAY LIKE 'E'.
    RETURN.
  ENDTRY.


   ls_documentfiles-documentpart = '000'.
   ls_documentfiles-documentversion = '00'.
   ls_documentfiles-storagecategory = 'DMS_C1_ST'.
   ls_documentfiles-wsapplication = 'PDF'.
   ls_documentfiles-docfile = ls_file-filename.
   ls_documentfiles-description = 'Bill example'.
   ls_documentfiles-language = 'PT'.
   INSERT ls_documentfiles INTO TABLE lt_documentfiles.
 ENDIF.


 BREAK-POINT.
*--------------------------------------------------------------------*
 " CREATE DOCUMENT CV01N
*--------------------------------------------------------------------*
 ls_documentdata-documenttype = 'ZAV'.
 ls_documentdata-documentnumber = ls_documentfiles-documentnumber. " CHAR16 unic code
 ls_documentdata-documentversion = '00'.
 ls_documentdata-documentpart = '000'.
 ls_documentdata-description = 'Bill example'.
 ls_documentdata-username = sy-uname.
 ls_documentdata-statusintern = 'LB'. "released
 

CALL FUNCTION 'BAPI_DOCUMENT_CREATE2'
 EXPORTING
    documentdata = ls_documentdata
*   HOSTNAME =
*   DOCBOMCHANGENUMBER =
*   DOCBOMVALIDFROM =
*   DOCBOMREVISIONLEVEL =
*   CAD_MODE = ' '
*   PF_FTP_DEST = ' '
*   PF_HTTP_DEST = ' '
*   DEFAULTCLASS = 'X'
 IMPORTING
*   DOCUMENTTYPE =
    documentnumber = lv_documentnumber
*   DOCUMENTPART =
*   DOCUMENTVERSION =
    return = ls_return
 TABLES
*   CHARACTERISTICVALUES =
*   CLASSALLOCATIONS =
*   DOCUMENTDESCRIPTIONS =
*   OBJECTLINKS =
*   DOCUMENTSTRUCTURE =
    documentfiles = lt_documentfiles
    longtexts = lt_longtexts
*   COMPONENTS =cv01n-text-just-1-line-error.png
 .


 IF lv_documentnumber IS NOT INITIAL.
   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
   EXPORTING
      wait = 'X'.
     p_documentnumber = lv_documentnumber.
 ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    MESSAGE s000(zsd) WITH 'Error while creating doc'
                      DISPLAY LIKE 'E'.
    RETURN.
 ENDIF.


ENDFORM. " UPLOAD_ANEXO&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Jan 2020 00:01:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175210#M1979381</guid>
      <dc:creator>glauco</dc:creator>
      <dc:date>2020-01-18T00:01:24Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_DOCUMENT_CREATE2 Longtext N lines problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175211#M1979382</link>
      <description>&lt;P&gt;Ola Glauco,&lt;/P&gt;&lt;P&gt;1. "use empty brackets after lt_longtexts &lt;/P&gt;&lt;P&gt;longtexts = lt_longtexts[]&lt;/P&gt;&lt;P&gt;2. "can use APPEND instead of INSERT&lt;/P&gt;&lt;P&gt;APPEND lt_longtexts TO lt_bapi_longtexts.&lt;/P&gt;&lt;P&gt;* &lt;/P&gt;&lt;P&gt;*example: standard include program LCDESKF13 uses BAPI to populate longtext &lt;/P&gt;&lt;P&gt;data: lt_longtexts like bapi_doc_text_keys occurs 0 with header line, &lt;/P&gt;&lt;P&gt;         lt_bapi_longtexts like bapi_doc_text occurs 0 with header line. &lt;/P&gt;&lt;P&gt;* build internal table for Long text using structure BAPI_DOC_TEXT &lt;/P&gt;&lt;P&gt;* where-used list for BAPI to check usage &lt;/P&gt;&lt;P&gt;* fill table lt_bapi_longtexts
clear: lt_bapi_longtexts. &lt;/P&gt;&lt;P&gt;loop at lt_longtexts where tab_index = wa_plm_document-index. &lt;/P&gt;&lt;P&gt;    APPEND lt_longtexts TO lt_bapi_longtexts. "can use APPEND instead of INSERT &lt;/P&gt;&lt;P&gt;endloop. &lt;/P&gt;&lt;P&gt;* etc. &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 = l_doc_data &lt;/P&gt;&lt;P&gt;  IMPORTING &lt;/P&gt;&lt;P&gt;    documenttype = l_dokar &lt;/P&gt;&lt;P&gt;    documentnumber = l_doknr &lt;/P&gt;&lt;P&gt;    documentpart = l_doktl &lt;/P&gt;&lt;P&gt;    documentversion = l_dokvr &lt;/P&gt;&lt;P&gt;    return = l_return &lt;/P&gt;&lt;P&gt;  TABLES &lt;/P&gt;&lt;P&gt;    characteristicvalues = lt_char_val &lt;/P&gt;&lt;P&gt;    classallocations = lt_class_alo &lt;/P&gt;&lt;P&gt;    documentfiles = lt_files[] &lt;/P&gt;&lt;P&gt;    longtexts = lt_longtexts[] "use empty brackets after lt_longtexts &lt;/P&gt;&lt;P&gt;    documentdescriptions = lt_doc_desc[]. &lt;/P&gt;&lt;P&gt;* etc. &lt;/P&gt;&lt;P&gt;* Boas Festas &lt;/P&gt;&lt;P&gt;References &lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.sap.com/questions/3053259/help-on-bapidocumentcreate2.html" target="test_blank"&gt;https://answers.sap.com/questions/3053259/help-on-bapidocumentcreate2.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;
&lt;A href="https://www.abapforum.com/forum/viewtopic.php?t=1414" target="test_blank"&gt;https://www.abapforum.com/forum/viewtopic.php?t=1414&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 04:46:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175211#M1979382</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-01-18T04:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_DOCUMENT_CREATE2 Longtext N lines problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175212#M1979383</link>
      <description>&lt;P&gt;Oi Joanna.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'll try the brackets. But I've debugged and the 3 lines are already recognized inside the BAPI and the BAPI itself "lost" my two other lines during its own execution.&lt;BR /&gt;I'm guessing if is there a bug or another parameter I need to fill up together the lt_longtext. I think I need to dig more around it or debug it more.&lt;/P&gt;&lt;P&gt;The standard program example fills it up from another internal table format, but in the end the fields are the same like I'm alread filling it up.&lt;/P&gt;&lt;P&gt;The other link shows another function which creates files to folders, but in my case the customer uses just CV01N to upload the files.&lt;/P&gt;&lt;P&gt;Thank you for you quick anwser.&lt;/P&gt;&lt;P&gt;Boas festas pra você também &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2020 17:39:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175212#M1979383</guid>
      <dc:creator>glauco</dc:creator>
      <dc:date>2020-01-19T17:39:56Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_DOCUMENT_CREATE2 Longtext N lines problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175213#M1979384</link>
      <description>&lt;P&gt;Are you sure CV01N let you enter more than 1 line for a given language?&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2020 18:33:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175213#M1979384</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2020-01-19T18:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: BAPI_DOCUMENT_CREATE2 Longtext N lines problem</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175214#M1979385</link>
      <description>&lt;P&gt;good question. &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;BR /&gt;I will talk to the functional consultant and will give this answer here.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 00:05:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/bapi-document-create2-longtext-n-lines-problem/m-p/12175214#M1979385</guid>
      <dc:creator>glauco</dc:creator>
      <dc:date>2020-01-20T00:05:40Z</dc:date>
    </item>
  </channel>
</rss>

