2006 Nov 21 12:44 AM
I am working SAP ECC 6.0
I want to upload a file from application server using open data set ..The file is CSV or tab delimited; I could read perfectly into a string, but when I use the Split command its not working because its not considering the tab delimiter. I am trying at least to find out this character (TAB) and get all the offset into the string using FIND command.
I created a small program to represent my problem and I used REGEX expression to find out the TAB values. Could somebody check this REGEX expression and tell me what I am missing?. What is wrong?. (I know is the Regex expression) How can I find out specifically the tab character?
= TAB CHARACTER.
Wa_string value
DH#10022006#Z2#9210#10022006#SUBSCRIBR REFUND# # # #
2 11 14 17 27 37 44
Line LINE Offset Length
1 0 1 1
2 0 10 1
3 0 13 1
4 0 18 1
5 0 27 1
6 0 37 1
7 0 44 1
READ DATASET P_BFILE INTO wa_string.
FIND ALL OCCURRENCES OF
REGEX [\S\b]
in wa_string
RESULTS tabresult_tab.
This function is returning the line 6 in the table, which means SPACE. I just need that return only the TAB offset.
I will thank your help.
Example code:
REPORT ZTEST5.
data P_BFILE LIKE RLGRAP-FILENAME value '/usr/filewithtabdelim.txt'.
data: begin of t_input OCCURS 0,
field type string,
end of t_input,
text TYPE string,
tabresult_tab TYPE match_result_tab,
WA_STRING TYPE STRING.
Start-OF-SELECTION.
open dataset P_BFILE for input
in text mode ENCODING DEFAULT.
break-point.
do 1 times.
READ DATASET P_BFILE INTO wa_string.
FIND ALL OCCURRENCES OF
REGEX '\S\b'
REGEX \[^:space:]]+\
in wa_string
RESULTS tabresult_tab.
write: / wa_string.
enddo.
2006 Nov 21 1:27 AM
Dear Jose
For tab delimeted file:
Declare a variable as below:
data: l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab.
Now use this for split command...
spli <string> at l_tab into <wa>-fld1 <wa>-fld2....
Hope this might help you.
Kind Regards
Eswar
Dear Jose
For tab delimeted file:
Declare a variable as below:
data: l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab.
Now use this for split command...
spli <string> at l_tab into <wa>-fld1 <wa>-fld2....
Hope this might help you.
Kind Regards
Eswar
2006 Nov 21 1:27 AM
Dear Jose
For tab delimeted file:
Declare a variable as below:
data: l_tab(1) type c value cl_abap_char_utilities=>horizontal_tab.
Now use this for split command...
spli <string> at l_tab into <wa>-fld1 <wa>-fld2....
Hope this might help you.
Kind Regards
Eswar
2006 Nov 21 3:23 AM
Very Simple Dude....
The TAB that u see in windows is not what u see in the Unix.. In unix it appears as a # .
This # is diffrent from windows #. It is a unicode character.
So u need to do this -- Declare a variable as follows --
data : c_tab type x value '09'.
split string at c_tab into fld_1 fld_2 ...
Remeber.. U might get an error saying unicode check active or inactive something...
Then Go to Attributes and in the botttom there willl be chek box sayin Unicode checks active... Just un-check or may be check (I am not sure.. try both) it... It will work perfectly...
Plz reward points if it was useful.
2006 Nov 21 3:34 AM
Dear Varun
The info you have provided is suitable only for NON-UNICODE systems. While we are in UNICODE enabled system:
<b>1. We can not remove/uncheck "UNICODE Checks Active" from program attributes.
2. We can declare a variable of type "X".</b>
Above info is just for your knowledge.
Kind Regards
Eswar
2006 Nov 21 3:42 AM
Oh great... that is something I was not aware of....
Then its fine.. .we can directly go with type x declaration.
2006 Nov 21 3:47 AM
Sorry, it was my typo error:
We <b>CAN NOT declare</b> a variable of type "X".
Hence we have to use class CL_ABAP_CHAR_UTILITIES, for characters that we normally use like tab, carriage return, line feed...
Regards
Eswar
2006 Nov 21 4:04 AM
But my freind... I hvae tried it many times... and It works...
2006 Nov 21 4:59 AM
Have you checked when the attribute for "Unicode Checks active" is set to "X". This is incase of UNICODE enabled system???
Regards
Eswar
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |