cancel
Showing results for 
Search instead for 
Did you mean: 

How to avoid Carriage return in external Data source fields

Former Member
0 Kudos

Dear BW Experts,

We have an external data source and loading it from a .CSV file.

Some of the fields like address field and description field have carriage return in the field.

This causes error while loading the datasource from the .CSV file. The external system is unable to correct the same.

Could you advise as to how to fix the issue.

Thanks,

Sai

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member

Hi Matt,

I unable to write any logic in the start routene, since loading of data source from an external file does not have any place to write such routene.

The carriage return and line feed (HEX 0D OA) is within a field that is enclosed by double quotes and thus is a valid value for a field in a CSV type file. The entire content of the field, including carriage return and line feed needs to be loaded into the PSA.

However, this is giving errors at load time.

Kindly help us in providing a solution.

Thanks,

Sai

Former Member
0 Kudos

Is there a table or setting in SAP to prevent this from happening?

Without having to programmatically alter the output file?

Thanks.

Former Member
0 Kudos

I have always opened the CSV file in editpad and saved it in a different encoding which removed the carriage returns

Sai - This is Ramamurthy. Can you please call me at <<phone number removed>>

I have been trying to reach you for the last several years

Thanks and I am already excited

Edited by: Matt on Mar 1, 2011 6:08 AM

matt
Active Contributor
0 Kudos

>

> I have been trying to reach you for the last several years

Posting of personal information is not permitted.

matt
Active Contributor
0 Kudos

In a start routine, use the solution proposed by Harald Boeing here: . I've just used in a virtual provider in the following form:

replace all occurrences of regex '[\n\r\t]+' in STRING with ''.

Which gets rid of newline, carriage return and tab. Search for a REGEX tutorial if there are other non-printable characters you need to remove. Unfortunately, there is no way of generically getting rid of all non-printable characters.

matt

Former Member
0 Kudos

If the .CSV file is accessible then the carriage return can be removed by writing the formula : SUBSTITUTE(cells name (e.g A1),CHAR(13),"") for all the columns containing carriage return and then loaded to the PSA.

Former Member
0 Kudos

you can write the abap code in the transformation..i have been using it in my program to remove special character

cl_abap_char_utilities=>cr_lf is used to identify the carriage return

if source_field ca cl_abap_char_utilities=>cr_lf.

clear: zlgtxt0, zlgtxt1, zwrngch.

zwrngch = cl_abap_char_utilities=>cr_lf.

zlgtxt0 = source_field.

call function 'SSM_REPLACE_CHAR_BY_SPACE'

exporting

input_string = zlgtxt0

char = zwrngch

importing

output_string = zlgtxt1.

clear source_field.

source_field = zlgtxt1.

endif.

arun_kumar52
Active Participant
0 Kudos

Hi,

Try to follow any one of these,

1) Ask your source contact to create flat file with Delimiter with "(double quotes) and use this in your Data Source File assigning place.

2) Try to create a Routine for that particular info object and replace the carriage return to null.

Hope this could help to fix your issue.

-Arun.M.D

om_ambulker2
Discoverer
0 Kudos

Hi Sai,

you can do pre processing of file in unix server before loading data in BW or you can write a routine on that field to remove carriage return character from the field.

for Unix use below command:

sed -e 's/^M//g' filename

For Routine: Write a logic to remove CR

om_ambulker2
Discoverer
0 Kudos

This message was moderated.