2011 May 16 6:29 AM
HI,
I have a text which needs to be created in header/item texts of sales order.
text ='THIS IS!HEADERTEXT!WELCOME' ..
now it needs to be saved in the header/item text as shown below:-
THIS IS
HEADER TEXT
WELCOME.
i.e., '!' needs to be replaced by the line feed
REPLACE all OCCURRENCES OF '!' in text WITH cl_abap_char_utilities=>cr_lf. .but still am unable to save the text with line feed..
pls suggest me the alternatives.
thanks
sures
2011 May 16 8:58 AM
hi,
You can check this
data:lv_string type string.
data:it type table of string.
lv_string = 'THIS IS!HEADERTEXT!WELCOME' .
split lv_string at '!' into table it.
loop at it into lv_string.
if sy-tabix = 1.
lines-tdformat = '*'.
else.
lines-tdformat = '/'.
endif.
lines-tdline = lv_string.
append lines.
endloop.
hi,
You can check this
data:lv_string type string.
data:it type table of string.
lv_string = 'THIS IS!HEADERTEXT!WELCOME' .
split lv_string at '!' into table it.
loop at it into lv_string.
if sy-tabix = 1.
lines-tdformat = '*'.
else.
lines-tdformat = '/'.
endif.
lines-tdline = lv_string.
append lines.
endloop.
2011 May 16 6:38 AM
REPLACE all OCCURRENCES OF '!' in text WITH cl_abap_char_utilities=>cr_lf.Where have you written this code? How are you "saving" this text? Please elaborate.
2011 May 16 7:26 AM
HI Suhas,
this is the following code
text = 'THIS IS!HEADER TEXT!WELCOME'.
now i want to save the text as
THIS IS
HEADER TEXT
WELCOME
that means "!" should be replace by the line feed so that the next character will be printed on the next line.
pls. suggest the possibilities to achieve this.
thanks
2011 May 16 7:05 AM
Hi,
The replace statement will work fine.. It will result in "THIS IS##HEADERTEXT##WELCOME." But then how you are saving your text in Sales header/text. Explain briefly about your requirement. Where you are trying to see the output.
Regards,
Vimala P
2011 May 16 7:38 AM
HI Vimala,
Yes, in debuggind mode its appearing as 'THIS IS##HEADER TEXT##WELCOME' ..but when i execute it , in the output its showing as 'THIS IS##HEADER TEXT##WELCOME' rather than in different lines.
i need to save the text in differentl lines in the header text of the sales order.
thanks
2011 May 16 8:24 AM
Hi Suresh,
Do you use the function 'SAVE_TEXT' for saving the header text?
In this case, you have split the text in three different lines of internal table which you are filling.
Regards,
Filippo
2011 May 16 7:25 AM
Try using below one in the replace statement.
CL_ABAP_CHAR_UTILITIES=>NEWLINE
2011 May 16 8:58 AM
hi,
You can check this
data:lv_string type string.
data:it type table of string.
lv_string = 'THIS IS!HEADERTEXT!WELCOME' .
split lv_string at '!' into table it.
loop at it into lv_string.
if sy-tabix = 1.
lines-tdformat = '*'.
else.
lines-tdformat = '/'.
endif.
lines-tdline = lv_string.
append lines.
endloop.
2011 May 16 9:19 AM
2011 May 16 9:20 AM
2011 May 16 12:42 PM
Hi Sures,
maybe following approach works:
If not, you can further try ASCII-code 10 instead of 13.
DATA:
lv_hex_cr TYPE x VALUE 13 LENGTH 4,
lv_char_cr TYPE c
.
FIELD-SYMBOLS:
<lv_char_cr> TYPE c
.
ASSIGN lv_hex_cr TO <lv_char_cr> CASTING TYPE c.
MOVE <lv_char_cr> TO lv_char_cr.
REPLACE all OCCURRENCES OF '!' in text WITH lv_char_cr
Regards, Hubert
2011 May 16 1:16 PM
Hello Suresh,
try the following code for your requirement:
DATA: lt_message_body TYPE bcsy_text VALUE IS INITIAL,
ls_message TYPE string,
ls_text TYPE string VALUE 'THIS IS!HEADERTEXT!WELCOME',
lv_char TYPE c VALUE '!',
ls_rest TYPE string.
SPLIT ls_text AT lv_char INTO ls_message ls_rest.
APPEND ls_message TO lt_message_body.
WHILE ls_rest IS NOT INITIAL.
MOVE ls_rest TO ls_text.
CLEAR ls_message.
SPLIT ls_text AT lv_char INTO ls_message ls_rest.
APPEND ls_message TO lt_message_body.
ENDWHILE.
APPEND ls_rest TO lt_message_body.
"lt_message_body" will contain the text in desired format.
thanks,
Koushik
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |