07-15-2009 9:21 AM
Hi Experts,
I Have a question about "New Line Character". I searched in SDN before posting this thread, But I didn't get answer.
Question:
Let me say my Client requirement first. After loading the data(Millions of Records) into SAP through LSMW, they asked write a program for validation of those loaded records based on I/P file. I wrote a program and It is success full.
But, the problem is when file is in Application server in 'BIN' format, a new line character(#) is created. While comparing the last record of each line, it doesn't match. How to remove this new line character(#) in I/P file for each line of record? Please see the below records for example
PROVINCIA DE BUENOS AIRE| |1870|AR| #
PROVINCIA DE BUENOS AIRE| |1876|AR| #
BOX 7407 PRINCETON| |085437407|US|NJ#
5756 2 A CAPITAL FEDERAL| |1431|AR|00#
Note: This New line character is not matching the string "#".
Please help me guys, so many objects are related with this concept. I appreciate quick response. Please.
Thanks
Sai
07-15-2009 9:25 AM
Hi,
It will match CL_ABAP_CHAR_UTILITIES=>NEWLINE (This is a constant)
Check the class
Regards
07-15-2009 9:28 AM
Hi Ravi,
Thanks for quick reply. I tried with this class, But it doesn't recognize as character. If you have any code, please post it to me. I will try again..
Thanks
Sai
07-15-2009 9:27 AM
Hi Sai ,
You can check it with the attribute NEWLINE in the class CL_ABAP_CHAR_UTILITIES.
Regards,
Arun
07-15-2009 9:45 AM
Hi Arun, Ravi,
I wrote the code like this, here 'fil_curre' is currency key.
IF <l_wa_file_data>-fil_curre CS cl_abap_char_utilities=>newline.
REPLACE ALL OCCURRENCES OF REGEX cl_abap_char_utilities=>newline
IN <l_wa_file_data>-fil_curre WITH ''.
ENDIF.
While executing the code, the cursor here, simply jumps to next step.
Any enhancements to this code or any new ideas?
Thanks
Sai
07-15-2009 9:52 AM
hi Sai,
Try this,
read the data present in the application server to a string say str1.
REPLACE ALL OCCURRENCES OF '#' IN str1 WITH space.
07-15-2009 10:01 AM
Hi Sai ,
Check what is the code for the last character in the string you get as input.
This can be done by selecting the the character using offset in debugging and clicking in the magnify button in case of classical debugger , please check if the value is same as that we get in the class.
Regards,
Arun
07-15-2009 10:31 AM
Hi arun,
As you said, it is different. In the file the code is '000D', but in class, the code is '000A'. that is why it is not matching. what can I do in this situation. Please help me.
Thanks
Sai
07-15-2009 10:53 AM
Hi Sai ,
We had done some thing similar some time back , i dont remember it correctly , please try the below code
data : text(2) type x .
text = '000D'.
Use the variable text to search for the existance of the symbol in the text .
Do reply in case this does not work.
Please verify again the code is 000D or 0D , as 0D is the HEX code for carriage return command .
Regards,
Arun
Edited by: Arun R on Jul 15, 2009 3:38 PM
07-22-2009 9:50 AM
Could you please elaborate this logic. Hope this is helpful for me...
07-22-2009 9:57 AM
why dont you just use a remove special character FM to remove the #??
07-22-2009 10:08 AM
Hi Soumya,
I don't know is it working or not bcoz new line character '#' is not recognized as character in the field. any, way please give me that FM name, I will try and let you know is it working or not.
Thanks for reply..
07-22-2009 10:19 AM
Function module SF_SPECIALCHAR_DELETE
Import parameters Value
WITH_SPECIALCHAR ASDAISJDILASDLL#
Export parameters Value
WITHOUT_SPECIALCHAR ASDAISJDILASDLL
07-15-2009 9:43 AM
Hi,
As a workaroudn you may try this:
Find string length and then delete the last character from string using offset.
Once this is done , you will be able to compare the last record.
Rgds,
Sandeep
07-15-2009 9:53 AM
Hi Sandeep,
I tried this logic also, but I need to remove this newline character dynamically. the last line in I/P file there is no new line character, see this example...
0.0000|20090217|99.00|99.00|99.00|99.00|USD#
0.0000|189843.00|5973.50|97500.00|0.00|USD#
0.0000|0.00|84382.00|4375.00|0.00|0.00|USD -------> No New line character
At last line in the file, the record doesn't match..
thanks
Sai
07-15-2009 9:54 AM
Hi Sandeep,
I tried this logic also, but I need to remove this newline character dynamically. the last line in I/P file there is no new line character, see this example...
0.0000|20090217|99.00|99.00|99.00|99.00|USD#
0.0000|189843.00|5973.50|97500.00|0.00|USD#
0.0000|0.00|84382.00|4375.00|0.00|0.00|USD -------> No New line character
At last line in the file, the record doesn't match..
thanks
Sai
07-15-2009 9:59 AM
For this you need to check one more condition like:
lv_len = strlen(str).
Search "#" with offset (lv_len) , if this is true then process .
07-15-2009 10:27 AM
09-10-2009 4:40 PM
07-31-2010 11:23 AM
07-09-2011 7:59 AM
is this problem of newline # character solved? If yes how ?
please tell.
09-04-2014 9:06 AM
Hi All,
I was also facing similar problem and it got solved by using the following statement:
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>CR_LF(1)
IN v_string
WITH space.
This is because CL_ABAP_CHAR_UTILITIES=>CR_LF(1) is '#' in character and has a hexadecimal value '000D'.
Regards,
Rachit.
06-16-2022 10:44 AM
11-22-2023 6:25 AM
I tried all combinations like REPLACE / Translate / Code to check last character with '#' or TAB or NEWLINE and remove it using string operation but none of it worked ....
Finally
REPLACE ALL OCCURRENCES OF CL_ABAP_CHAR_UTILITIES=>CR_LF(1)
IN v_string
WITH space.
This is because CL_ABAP_CHAR_UTILITIES=>CR_LF(1) is '#' in character and has a hexadecimal value '000D'
worked for me ..