Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Unable to SPLIT string after Read Dataset from Application Server

Former Member
0 Likes
1,606

HI Experts,

I am unable to SPLIT in a string after reading (read dataset) from a text file in application server.

On the command SPLIT in the code below - the output does not split AT '#' or any characters after it is read from the application server.

Anyone know what is the problem?

The file is uploaded from my Excel file and save it to a text file (tab delimited) and then upload into the application server using CG3Z as ANSI.

But it does not work.

I then test to copy and replace the variable with the same string record back into lv_data_string before SPLIT in DEBUG mode and splits perfectly.

OPEN DATASET P_LGFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

DO.

READ DATASET P_LGFILE INTO lv_data_string.

IF sy-subrc NE 0.

EXIT.

ENDIF.

CLEAR wa_string.

SPLIT lv_data_string AT '#' INTO wa_string-string1 wa_string-string2 wa_string-string3 wa_string-string4 wa_string-string5

wa_string-string6 wa_string-string7 wa_string-string8 wa_string-string9.

APPEND wa_string TO lt_string.

ENDDO.

ENDIF.

Kindly advice.

Thanks in advance

CW

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
705

In runtime ABAP compiler recognizes # as tab delimiter.

You try below code:

DATA: l_sep1 TYPE c.
      l_sep1 = cl_abap_char_utilities=>HORIZONTAL_TAB.

      SPLIT lv_data_string AT l_sep1 INTO wa_string-string1 wa_string-string2 wa_string-string3 wa_string-string4 
                                                                 wa_string-string5  wa_string-string6 wa_string-string7 wa_string-string8 
                                                                  wa_string-string9.

Thanks and Regards,

Chandra

3 REPLIES 3
Read only

rainer_hbenthal
Active Contributor
0 Likes
705

The hash sign has to functions in character and string variables.

1) the hash sign itsself

2) a replacement for all not printable characters like 09x. If you are looking at the file the hash sign may represent another character. Checkl if the fiule really contains a hash sign. In most cases this is a TAB sign instead.

Read only

Former Member
0 Likes
706

In runtime ABAP compiler recognizes # as tab delimiter.

You try below code:

DATA: l_sep1 TYPE c.
      l_sep1 = cl_abap_char_utilities=>HORIZONTAL_TAB.

      SPLIT lv_data_string AT l_sep1 INTO wa_string-string1 wa_string-string2 wa_string-string3 wa_string-string4 
                                                                 wa_string-string5  wa_string-string6 wa_string-string7 wa_string-string8 
                                                                  wa_string-string9.

Thanks and Regards,

Chandra

Read only

Former Member
0 Likes
705

HI ALL,

It works Briliantly !!

Thank You so much !

All the best !

Regards

CW