Skip to Content
author's profile photo Former Member
Former Member

problem in recognizing '#" in while reading from appl.server

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 25, 2011 at 02:54 PM

    Any replies for my issue?

    thnks

    suresh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 25, 2011 at 03: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?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • Posted on May 25, 2011 at 06: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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 25, 2011 at 07: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,

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.