05-25-2011 12:23 PM
Hi All,
Am reading the file from application server,, the data is stored with tab delimited '#' format.
am used the following code.
data: gc_tab type char value VALUE cl_abap_char_utilities=>horizontal_tab.
read dataset <filename> into lv_string.
split lv_string at gc_tab into v1 v2 v3 .
but the problem is its not even recognizing '#' character in the string.
Pls. suggest me the possibilities ..
thanks in advance
suresh
05-25-2011 3:54 PM
05-25-2011 4:37 PM
What exactly is a "tab delimited '#' format"?
It's possible that those # signs are not really TAB characters... are you sure about the file content?
05-25-2011 6:51 PM
HI Tamas,
Well the flle content has '#' as a delimiter between each field value..
so when am trying to move the each record into the string ..
read dataset <datasetname> into lstring.
split lstring at '#' into v1 v2 v3. ...... is not able to recognize the '#" character the record ....
rgrds
suresh
05-25-2011 7:04 PM
05-25-2011 7:17 PM
Hi rob,
sorry i dint get ur piont ...
wats the hex value of '#' ? ..means..
for example ...the data in the file in the application server is like
100#20110504#20110412##TESTING#23.0000#
......
....
......
....
normally split shud work ...but its not able to recognizing '#' ...
in the debugger i could only see '#' but not any value for that ..
hope am clear..
thanks
suresh
05-26-2011 4:24 AM
HI Rob,
the hex value for '#' is 7F00 .. am using the delimiter value of 7F00 in split command but still am getting the same error.
pls. advise..
thanks again
suresh
05-26-2011 7:26 PM
A workaround:
data: gc_tab type char value VALUE '@'.
1) Open your input file in notepad.
2) Select and copy the unprintable character to your clipboard.
3) Paste that value into the '@' in the data declaration above.
4) I'm sure there's a better way
Rob
05-25-2011 7:19 PM
The # is just a representation of an unprintable character, so the SPLIT will not recognize it as #. It is something else, and apparently it is not the same like the cl_abap_char_utilities=>horizontal_tab.
As Rob suggested, check the hex value of the character that is represented by the # sign. That will tell you what you have as the delimiter in that file and how you should define it in your program.
05-25-2011 7:21 PM
hi tamas,
how can we check the hex value of that '#' character ? ..plss advise me ..
thanks
suresh
05-25-2011 7:23 PM
Double-click the string containing the record from the file and you'll see the hex representation of it's value. Find out what is the hex code of the # sign.
05-25-2011 7:35 PM
after double clicking the string in debugger ...it has long chain of hexadecimal .. i think 7F00 is hex value for '#' ..
is there anyway to check the correct hex value ...because the record is like
10#20110523#2000149204#05#2011#DZ#4147463000606166##
310030007F00320030003100310030003500320033007F003200300030003000310034003900320030003 - hex value...
thnks
suresh
05-25-2011 7:38 PM
HI tamas,
Yes it is 7F00 hex value for '#' ..now how we can get the delimiter value of 7F00 ..? pls advise.
thnks
suresh
05-25-2011 7:46 PM
Something like this should do the trick:
DATA delimiter(2) TYPE X VALUE '7F00'.
05-25-2011 7:50 PM
hi tamas,
thanks for replies..
but we cant use the type X for split command...as it supports only char.
thnks
suresh
05-25-2011 8:23 PM
am trying the following code but am getting syntax error
constants: delim type x value '7F00'.
split lstring at delim into v1 v2....
pls advise me
thanks
suresh
05-25-2011 8:31 PM
Suresh,
Check this:
DATA: lc_file(4) TYPE c,
data(100) TYPE c,
f_file TYPE string,
lv_num TYPE i,
c_d TYPE c,
x TYPE i,
y TYPE i.
CONSTANTS: c_x TYPE c VALUE '#',
c_v TYPE char4 VALUE '.TXT'.
CLEAR gv_flag.
x = STRLEN( p_file ).
y = x - 4.
lc_file = p_file+y(4).
TRANSLATE lc_file TO UPPER CASE.
IF lc_file <> c_v.
MESSAGE 'No existe el archivo en el servidor' TYPE 'I'.
gv_flag = 'X'.
ENDIF.
IF gv_flag IS INITIAL.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED. DEVK921912
OPEN DATASET p_file for output in legacy text mode code page '1100'. " DEVK921912
IF sy-subrc EQ 0.
DO.
READ DATASET p_file INTO data.
IF sy-subrc <> 0.
EXIT.
ELSE.
lv_num = 0.
DO 18 TIMES.
c_d = data+lv_num(1).
IF c_d = c_x.
EXIT.
ENDIF.
lv_num = lv_num + 1.
ENDDO.
gst_carga-matnr = data(lv_num).
lv_num = lv_num + 1.
gst_carga-maktx = data+lv_num(40).
APPEND gst_carga TO gti_carga.
ENDIF.
ENDDO.
CLOSE DATASET p_file.
ELSE.
MESSAGE 'No existe el archivo en el servidor' TYPE 'I'.
gv_flag = 'X'.
ENDIF.
ENDIF.
The string contain '#' character, so this routine validate if the string contain character "#" in:
IF c_d = c_x.
So, stop the "do" sentence and then get the number of characters for capture the string correct.
Regards,