Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

function SAVE_TEXT

Former Member
0 Likes
1,501

Hello!

I am using this function in order to save text in sales order.

When i pass the table lines to the function it has for example 4 lines.

After saving i can see that the 4 lines where concatenated to each other.

I want to create a situation where the 4 lines will be one after the other.

Is it possible?

Regards

Yifat Bar

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
703

Hi,

Check this code. It is to save header note text on sales document. It insert text line by line instead of concatenating them.

----------------------------------------------------------------------*
----------------------------------------------------------------------*
DATA: l_objname LIKE thead-tdname,
      l_vbeln   LIKE vbak-vbeln.

DATA: lst_header LIKE thead.    "Target Text Header

*" internal table for text to be inserted
DATA: lit_textline  LIKE tline OCCURS 10 WITH HEADER LINE.

*" move sales document number
l_vbeln = 'Pass Sales document number here'.
l_objname = l_vbeln. "(or you can directly assing VBELN value here)

*" Create text header
lst_header-tdobject = 'VBBK'.
lst_header-tdname   = l_objname.
lst_header-tdid     = '0001'.
lst_header-tdspras  = sy-langu.

lit_textline-tdformat = '*'.  "User tdformat = '*', this means 'DEFAULT PARAGRATH'
lit_textline-tdline   = 'This is 1st line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 2nd line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 3rd line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 4th line'.
APPEND lit_textline.

* Save text
CALL FUNCTION 'SAVE_TEXT'
     EXPORTING
          client          = sy-mandt
          header          = lst_header
          insert          = 'X'
          savemode_direct = 'X'
     TABLES
          lines           = lit_textline.
IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
----------------------------------------------------------------------*
----------------------------------------------------------------------*

Regards,

RS

2 REPLIES 2
Read only

athavanraja
Active Contributor
0 Likes
703

you concatenate cl_abap_char_utilities=>cr_lf at the end of each line to insert line breaks.

i guess this can also be achived by passing proper tdformat.

Raja

Read only

Former Member
0 Likes
704

Hi,

Check this code. It is to save header note text on sales document. It insert text line by line instead of concatenating them.

----------------------------------------------------------------------*
----------------------------------------------------------------------*
DATA: l_objname LIKE thead-tdname,
      l_vbeln   LIKE vbak-vbeln.

DATA: lst_header LIKE thead.    "Target Text Header

*" internal table for text to be inserted
DATA: lit_textline  LIKE tline OCCURS 10 WITH HEADER LINE.

*" move sales document number
l_vbeln = 'Pass Sales document number here'.
l_objname = l_vbeln. "(or you can directly assing VBELN value here)

*" Create text header
lst_header-tdobject = 'VBBK'.
lst_header-tdname   = l_objname.
lst_header-tdid     = '0001'.
lst_header-tdspras  = sy-langu.

lit_textline-tdformat = '*'.  "User tdformat = '*', this means 'DEFAULT PARAGRATH'
lit_textline-tdline   = 'This is 1st line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 2nd line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 3rd line'.
APPEND lit_textline.

lit_textline-tdformat = '*'.
lit_textline-tdline   = 'This is 4th line'.
APPEND lit_textline.

* Save text
CALL FUNCTION 'SAVE_TEXT'
     EXPORTING
          client          = sy-mandt
          header          = lst_header
          insert          = 'X'
          savemode_direct = 'X'
     TABLES
          lines           = lit_textline.
IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
----------------------------------------------------------------------*
----------------------------------------------------------------------*

Regards,

RS