2004 Nov 04 8:22 PM
Hi ,
I have an issue with removing the carriage return / Tab from the extracted (Flat File) data from SAP EKPO table.
1) While uploading(Long Back) the Legacy data to SAP tables the carriage returns and Tabs in Product description were uploaded to SAP tables.
2) Now I am extracting data from bkpf,..EKPO.. tables to a flat file .
3) When I extract the data i. PO number, Product description,......
The Product description is going to 3 to 5 lines depending on the carriage returns and Tabs in the Product description. Ekpo-txz01
Ex : Mfg # DS104NA / NET######GEAR DS104 Hub######model
I want this product description in one continuous line. It is possible only by removing the Carriage returns and tabs from product description before concatenating and TRANSFERING the file to Server.
4) What is getting: The line is breaking @gear @ Hub due to Carriage return/Tab
Mfg D NET
GEAR DS104 Hub
model .
5) What is required is: in one line
Mfg D NETGEAR DS104 model
In the process I am extracting product description from Ekpo-txz01 . So it is internal table. Now I want to remove the carriage return / Tab .
How these can be removed.
Thanks,
Vasu
2004 Nov 07 2:25 PM
Dear Vasu,
Sometimes there is a problem that cannot be solved normally. This is one of them.
The reason why the mentioned methods do not work is because you need to remove actually two characters CR and LF in one stroke. You can identify one but then not the other. So approach it from the other side.
Simply define what your correct characters might be AND only use them to export.
Below you will find a FORM routine that does just that (only passes defined valid characters and NOT others).
FORM validate_field USING VALUE(field_in)
CHANGING field_out.
CONSTANTS:
All low caps characters
validlow(26) TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz',
All upper caps characters and all figures
validhigh(36) TYPE c VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
All other characters (starting with space)
validrest(32) TYPE c VALUE ' <,>.?/:;"{[}]|\~`!@#$%^&*()_-+=',
Single quote
validquote VALUE ''''.
DATA:
pos(1) TYPE c, " Container to hold 1 character
l TYPE i, " Length
i TYPE i. " Indexer
Determine length
l = STRLEN( field_in ).
Stripping loop
WHILE i LT l.
Get one character
pos = field_in+i(1).
Check its validity
IF pos CO validlow
OR pos CO validhigh
OR pos CO validrest
OR pos EQ validquote.
When valid, use it
concatenate field_out
pos
into field_out.
ENDIF.
ENDWHILE.
ENDFORM.
Hopes this helps solving your problem.
Regards,
Rob.
Hi ,
I have an issue with removing the carriage return / Tab from the extracted (Flat File) data from SAP EKPO table.
1) While uploading(Long Back) the Legacy data to SAP tables the carriage returns and Tabs in Product description were uploaded to SAP tables.
2) Now I am extracting data from bkpf,..EKPO.. tables to a flat file .
3) When I extract the data i. PO number, Product description,......
The Product description is going to 3 to 5 lines depending on the carriage returns and Tabs in the Product description. Ekpo-txz01
Ex : Mfg # DS104NA / NET######GEAR DS104 Hub######model
I want this product description in one continuous line. It is possible only by removing the Carriage returns and tabs from product description before concatenating and TRANSFERING the file to Server.
4) What is getting: The line is breaking @gear @ Hub due to Carriage return/Tab
Mfg D NET
GEAR DS104 Hub
model .
5) What is required is: in one line
Mfg D NETGEAR DS104 model
In the process I am extracting product description from Ekpo-txz01 . So it is internal table. Now I want to remove the carriage return / Tab .
How these can be removed.
Thanks,
Vasu
2004 Nov 04 9:05 PM
Vasu,
You can replace tab and carriage return of your text using REPLACE command.
REPLACE cl_abap_char_utilities=>horizontal_tab in
Ekpo-txz01 with ' '.
REPLACE cl_abap_char_utilities=>CR_LF in
Ekpo-txz01 with ' '.
2004 Nov 04 11:01 PM
Hi Umar,
First thanks for giving some solution.
When I use the code as suggested,
1. It is removing 'Tab' only. It is not removing carriage return.
2. It is removing one TAB at a time.
3. Still I am <u>seeing a BOX [] after the text</u> in flat file. <b>i.e carriage return is not removed from Ekpo-txz01</b> .
I Used this and passing Ekpo-txz01 in a loop.
REPLACE cl_abap_char_utilities=>horizontal_tab in
Ekpo-txz01 with ' '.
REPLACE cl_abap_char_utilities=>CR_LF in
Ekpo-txz01 with ' '.
Can you suggest some solution/idea for this.
Thanks,
Vasu
Message was edited by: vasu bandi
2004 Nov 05 3:48 PM
Double-click on cl_abap_char_utilities=>CR_LF. You will see other attributes that equal to that BOX. Maybe it is NEWLINE.
2004 Nov 05 6:57 PM
Hi,
I have used all:
REPLACE cl_abap_char_utilities=>horizontal_tab in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>CR_LF in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>VERTICAL_TAB in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>NEWLINE in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>FORM_FEED in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>BACKSPACE in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>SPACE_STR in
ZTEST001_ITAB-DESCTXZ01 with ' '.
REPLACE cl_abap_char_utilities=>FORM_FEED in
ZTEST001_ITAB-DESCTXZ01 with ' '.
Still I was getting symbol [] .
In test data I created this error by pressing ENTER key.
I created a flat file with TAB key and Enter key. Then I uploaded to custom table in SAP. I could see the #### symbols in table.
Then I extracted data to a flat file on server. The TAB keys were removed. But the "Enter key" is shown as [].
Any info on this issue please. How to remove these [] from flat file.
Thanks,
Vasu
Note: On double clicking I am not seeing any thing like []. I could see ## # .
2004 Nov 05 9:58 AM
Try using the TRANSLATE statement instead (as this replaces all instances of the constant found in the string being evaluated).
Hope this helps.
Rosie Brent
Message was edited by: Rosie Brent
2004 Nov 05 7:05 PM
Hi,
I tried to use:
data x type x value '0A'.
TRANSLATE ZTEST001_ITAB-DESCTXZ01 using x.
I am getting eror : X must be a character-type data object(data type C,N,D,T OR string).
Any info in solving this.
Thanks,
Vasu
2004 Nov 05 7:27 PM
Hi
It seems TRANSLATE statement doen't like x-type arguments.
Our system is 4.6D and I have never used it but give a try to:
<b>REPLACE ALL OCCURRENCES OF x IN y WITH z.</b>
Hope it helps...
*--Serdar
2004 Nov 05 8:16 PM
Hi,
I tried:
data : CR type x value '0D',
NL type x value '0A'.
REPLACE ALL OCCURRENCES OF CR IN ZTEST001_ITAB-DESCTXZ01 WITH ''.
I am getting eror : X must be a character-type data object(data type C,N,D,T OR string).
ZTEST001_ITAB-DESCTXZ01 is like ekpo-txz01.
Thanks,
Vasu
2004 Nov 05 8:21 PM
Hi Vasu
Can't you do this removal of special characters before sending data to SAP?
*--Serdar
2004 Nov 05 9:08 PM
Vasu,
Replace need the fields to be character type. Since the problem is that you are not able to find the correct code for that [] (newline), why don't you see the hex representation of that weird character. You can do that by doing this.
1. Put a break point in your program.
2. While in debugging, display that string. Click on binacular plus icon at the right of field contents.
3. Find out the hex representation of that weird character.
4. Then in your program, declare a variable of type ABAP_CHAR1. Set it to the character you found in 3)
5. Then do a replace on this field.
Hope this will work.
2004 Nov 05 9:34 PM
Hi,
I tried:
data : CR type x value '0D',
NL type x value '0A'.
REPLACE ALL OCCURRENCES OF CR IN ZTEST001_ITAB-DESCTXZ01 WITH ''.
I am getting eror : X must be a character-type data object(data type C,N,D,T OR string).
ZTEST001_ITAB-DESCTXZ01 is like ekpo-txz01.
Thanks,
Vasu
2004 Nov 05 9:51 PM
Field CR has to be type character if you want to use replace. Try finding out the character representation of that newline in your string as per in my previous reply.
2004 Nov 05 9:51 PM
Hi ,
What i see is like this:
k####AC##3
6B232323234143232333202020202020202020202020202020202020202020202020202020202020
So it is 23 . How can we remove this.
Thanks,
VAsu
2004 Nov 05 10:18 PM
HI,
I am giving the values:
cl_abap_char_utilities=>horizontal_tab -- 09
cl_abap_char_utilities=>CR_LF -
0D0A
cl_abap_char_utilities=>VERTICAL_TAB --- 0B
cl_abap_char_utilities=>NEWLINE -
0A
cl_abap_char_utilities=>FORM_FEED -
0C
cl_abap_char_utilities=>BACKSPACE --- 08
so I am not seeing 23 .
Thanks,
Vasu
2004 Nov 07 2:25 PM
Dear Vasu,
Sometimes there is a problem that cannot be solved normally. This is one of them.
The reason why the mentioned methods do not work is because you need to remove actually two characters CR and LF in one stroke. You can identify one but then not the other. So approach it from the other side.
Simply define what your correct characters might be AND only use them to export.
Below you will find a FORM routine that does just that (only passes defined valid characters and NOT others).
FORM validate_field USING VALUE(field_in)
CHANGING field_out.
CONSTANTS:
All low caps characters
validlow(26) TYPE c VALUE 'abcdefghijklmnopqrstuvwxyz',
All upper caps characters and all figures
validhigh(36) TYPE c VALUE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
All other characters (starting with space)
validrest(32) TYPE c VALUE ' <,>.?/:;"{[}]|\~`!@#$%^&*()_-+=',
Single quote
validquote VALUE ''''.
DATA:
pos(1) TYPE c, " Container to hold 1 character
l TYPE i, " Length
i TYPE i. " Indexer
Determine length
l = STRLEN( field_in ).
Stripping loop
WHILE i LT l.
Get one character
pos = field_in+i(1).
Check its validity
IF pos CO validlow
OR pos CO validhigh
OR pos CO validrest
OR pos EQ validquote.
When valid, use it
concatenate field_out
pos
into field_out.
ENDIF.
ENDWHILE.
ENDFORM.
Hopes this helps solving your problem.
Regards,
Rob.
2004 Dec 16 1:07 AM
Greetings All,
I tried many ways to avoid this carriage return in text file.But at the end I went with the logic --reading character by character, which I was trying to avoid from the beginning. It is working now.
Thanks to Rob Veenstra.
Why this issue: The end users were using SHIFT+ENTER to
go to next line in Legacy system. On which we donot have any control. So this data was uploaded into SAP.
Because of this SHIFT+ENTER I was
getting carriage return in SAP data
extraction.
Any way issue was resolved.
I thank you all for the help.
Regards,
Vasu Bandi
Message was edited by: vasu bandi
Message was edited by: vasu bandi
Message was edited by: vasu bandi
Message was edited by: vasu bandi
2009 Mar 24 7:33 PM
2009 Apr 14 5:28 PM
As I understand, the problem here was to replace a carriage return character (hex value 0D) with a space.
The difficulty is that there doesn't seem to be an attribute in cl_abap_char_utilities that represents carriage return.
The hex value of cl_abap_char_utilities=>CR_LF is 0D0A (carriage return + line feed), so we want to use just the first character, the carriage return.
This worked for me:
REPLACE cl_abap_char_utilities=>CR_LF(1) in w_charfield with ' '.
2014 Aug 31 12:14 AM
2004 Nov 08 5:15 AM
Hi Vasu,
Try the following code.
FIELD-SYMBOLS: <tb> TYPE x,
<tc> TYPE c.
DATA:
tab(6) TYPE x VALUE '09200D200A20',
char60(60) TYPE c.
CONCATENATE 'abCD' cl_abap_char_utilities=>horizontal_tab
cl_abap_char_utilities=>CR_LF '1234' INTO char60.
ASSIGN tab TO <tb> CASTING.
ASSIGN <tb> TO <tc> CASTING.
TRANSLATE char60 USING <tc>.
In the char60 we have horizontal_tab and CR_LF.
All of them are replaced by space (char(20)).
Best regards,
Eugene
2004 Nov 09 8:31 AM
Hello,
one warning the code of Eugene will fail on UNICODE systems.
Kind Regards
Klaus