ā2011 Apr 05 9:04 PM
Hello,
I have a program which uploads the text from excel.
In excel, if one cell have multiple lines (separated by Alt + enter) , the program separates them with '#' .
I know the '#' is a hexadecimal value, but how could i replace this value with space ?
when i checked the hex value of '#' in debugger, it has the length of more than 2000.
Please suggest how i can replace '#' with space.
Thanks for your help.
ā2011 Apr 05 9:35 PM
Hi Ramesh,
Try the following code.
data: IN_TEXT type string.
data: lv_lf type c value CL_ABAP_CHAR_UTILITIES=>CR_LF.
replace all occurrences of lv_lf in IN_TEXT with space.Regards,
Kinshuk
ā2011 Apr 05 10:20 PM
Kinshuk,
Thanks for your response.
I tried your solution before, but it didnt work.
Here , the value of CL_ABAP_CHAR_UTILITIES=>CR_LF will be '0D00', but the value of '#' which iam getting from excel is not ''0D00'.
ā2011 Apr 06 6:37 AM
Hi,
Try this.
data: IN_TEXT type string.
data: lv_lf type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
replace all occurrences of lv_lf in IN_TEXT with space.If that doesnt work try with
data: lv_lf type c value cl_abap_char_utilities=>VERTICAL_TAB
or
data: lv_lf type c value cl_abap_char_utilities=>NEWLINE
ā2016 Apr 08 1:36 PM
btw. CL_ABAP_CHAR_UTILITIES=>CR_LF corresponds to 0D00 0A00 (Carriage Return + Line Feed) .
If you only want the Carriage Return you can use CL_ABAP_CHAR_UTILITIES=>CR_LF+0(1) which yields 0D00
ā2011 Apr 06 6:46 AM
Hi Ramesh,
If you are using GUI_UPLOAD to load the excel file, use the "REPLACEMENT" parameter in the IMPORT parameter, update this parameter to use space, by defalut it is '#'.
Note: If you are using any other method to upload the file let me know.
Regards,
Chen
ā2011 Apr 06 7:01 AM
Hi Ramesh,
"REPLACEMENT" in GUI_UPLOAD won't work, for "#" is a placeholder for several not printable characters in SAP. The attributes in CL_ABAP_CHAR_UTILITIES should be the better way, if you can find one!
Regards,
Klaus
ā2011 Apr 06 10:06 AM
Hi Klaus,
Hope you can help me understand this better, the reason why Ramesh has '#' in place of 'ALT+ENTER' in the ITAB is because (i guess) 'GUI_UPLOAD' was not able find a printable character for the same. Now if he tries to "FIND" the same using CR_LF, how would it find the same?
Ramesh - I see that CL_ABAP_CHAR_UTILITIES=>CR_LF is a two character field, may you can try CR and LF separately as given below, as i am not sure on if 'ALT+ENTER' is translated/converted to CR or LF.
CR
replace all occurrences of CL_ABAP_CHAR_UTILITIES=>CR_LF(1) in 'your string' with space.
LF
replace all occurrences of CL_ABAP_CHAR_UTILITIES=>CR_LF+1(1) in 'your string' with space.
Regards,
Chen
ā2025 Mar 19 1:05 PM
Thanks
replace all occurrences of CL_ABAP_CHAR_UTILITIES=>CR_LF(1) in 'your string' with space.
This worked for me š
ā2011 Apr 06 11:17 AM
Hello Ramesh,
I am using MS Office 2007 excel & have a cell has multiple lines (created by Alt+Enter). When i check the HEX contents of the cell it shows a line feed(LF) ('0A').
I use the following statement which replaces the '#' with space:
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline
IN wa_data WITH ` `Hope this helps.
BR,
Suhas
ā2011 Apr 06 1:54 PM
Thanks guys..cl_abap_char_utilities=>NEWLINE did the trick. Appriciate your help.
ā2011 Apr 11 2:57 PM
Guys,
I had to re-open this thread as i have similar problem again.
Now Iam working on a program which downloads material texts to excel.
And Iam using CL_ABAP_CHAR_UTILITIES=>NEWLINE, in order to split the text lines into multiple lines within the same excel Cell.
To do this, using only CL_ABAP_CHAR_UTILITIES=>NEWLINE is not enough, I had to put the whole text between double quotes.
For example ... to download 'line1' 'line2' into same excel cell..
Concatenate 'line1' 'line2' into v_text separated by CL_ABAP_CHAR_UTILITIES=>NEWLINE .
concatenate ' " ' v_text ' " ' into v_text.
This works fine. But when the text itself has the double quotes in it, then the text jumping to the next cell.
And i have lot of material texts which have double quotes in their text itself..
Any ideas to solve this ?
Edited by: Ramesh Putta on Apr 11, 2011 3:57 PM
ā2011 Apr 11 3:06 PM
ā2012 Jun 27 2:04 PM
Try this 2 lines for the material text field
REPLACE ALL OCCURRENCES OF `'` in material_text with '`'.
REPLACE ALL OCCURRENCES OF '"' in material_text with `""`.
Please refer the sample report below
*&---------------------------------------------------------------------*
*& Report ZCB_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZCB_TEST.
data: it TYPE TABLE OF string,
wa TYPE string,
seperator TYPE string VALUE cl_abap_char_utilities=>newline.
DO 5 TIMES.
CONCATENATE 'line1' seperator 'l"ine2' seperator 'line3' INTO wa.
REPLACE ALL OCCURRENCES OF `'` in wa with '`'.
REPLACE ALL OCCURRENCES OF '"' in wa with `""`.
CONCATENATE '"' wa '"' INTO wa.
APPEND wa to it.
ENDDO.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\test.csv'
FILETYPE = 'DAT'
TABLES
DATA_TAB = it
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ā2015 Oct 09 1:33 PM
Hi
check in debugging
if hex value for # is 000D
then use:
REPLACE ALL OCCURANCE OF cl_abap_char_utilities=>cr_lf(1) IN string WITH space.
if hex value is 000A
then use:
REPLACE ALL OCCURANCE OF cl_abap_char_utilities=>cr_lf+1(1) IN string WITH space.
similary you can check for HORIZONTAL_TAB, VERTICAL_TAB etc.
hope this help
Regards