Application Development 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: 

Removing New Line Character in Input file

Former Member
0 Kudos

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

23 REPLIES 23

Former Member
0 Kudos

Hi,

It will match CL_ABAP_CHAR_UTILITIES=>NEWLINE (This is a constant)

Check the class

Regards

0 Kudos

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

Former Member
0 Kudos

Hi Sai ,

You can check it with the attribute NEWLINE in the class CL_ABAP_CHAR_UTILITIES.

Regards,

Arun

0 Kudos

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

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

Could you please elaborate this logic. Hope this is helpful for me...

0 Kudos

why dont you just use a remove special character FM to remove the #??

0 Kudos

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..

0 Kudos
Function module              SF_SPECIALCHAR_DELETE

  Import parameters               Value
  WITH_SPECIALCHAR                ASDAISJDILASDLL#

  Export parameters               Value
  WITHOUT_SPECIALCHAR             ASDAISJDILASDLL

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

0 Kudos

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

0 Kudos

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

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

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 .

Former Member
0 Kudos

hi Sai Babu,

you can refer to the below thread inorder to get rid of you problem

regards

Saurabh Goel

Former Member
0 Kudos

Answered my self..

0 Kudos

Hi Sai,

can you share the solution of this problem.

Regards,

Ravi

0 Kudos

is this problem of newline # character solved? If yes how ?

please tell.

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.

0 Kudos

good solution it is working

narendra_patil1
Discoverer
0 Kudos

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 ..