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

Split tab delimited file coming from application server.

Former Member
0 Likes
860

Hi,

i have received a tab delimited file from the application server.it contains # instead of tab at the application server.

i want to know how to split it.

i tried decalring constant as:

c_tab type x value'09'.

but it gives an error saying only c,n,d and t types are allowed.

please gelp.

Thanks,

Anand.

1 ACCEPTED SOLUTION
Read only

former_member386202
Active Contributor
0 Likes
730

Hi,

Do like this

*--Local Variables

DATA : l_file TYPE string,

l_line TYPE string.

*--Clear

CLEAR : l_file.

l_file = p_ipfile.

*--Read the data from application server file.

OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

*--Error in opening file

MESSAGE i368(00) WITH text-005.

ENDIF.

*--Get all the records from the specified location.

DO.

READ DATASET l_file INTO l_line.

IF sy-subrc NE 0.

EXIT.

ELSE.

SPLIT l_line AT cl_abap_char_utilities=>horizontal_tab

INTO st_ipfile-vbeln

st_ipfile-posnr

st_ipfile-edatu

st_ipfile-wmeng.

APPEND st_ipfile TO it_ipfile.

ENDIF.

ENDDO.

*--Close dataset

CLOSE DATASET l_file.

Regards,

Prashant

Hi,

i have received a tab delimited file from the application server.it contains # instead of tab at the application server.

i want to know how to split it.

i tried decalring constant as:

c_tab type x value'09'.

but it gives an error saying only c,n,d and t types are allowed.

please gelp.

Thanks,

Anand.

4 REPLIES 4
Read only

former_member386202
Active Contributor
0 Likes
731

Hi,

Do like this

*--Local Variables

DATA : l_file TYPE string,

l_line TYPE string.

*--Clear

CLEAR : l_file.

l_file = p_ipfile.

*--Read the data from application server file.

OPEN DATASET l_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

*--Error in opening file

MESSAGE i368(00) WITH text-005.

ENDIF.

*--Get all the records from the specified location.

DO.

READ DATASET l_file INTO l_line.

IF sy-subrc NE 0.

EXIT.

ELSE.

SPLIT l_line AT cl_abap_char_utilities=>horizontal_tab

INTO st_ipfile-vbeln

st_ipfile-posnr

st_ipfile-edatu

st_ipfile-wmeng.

APPEND st_ipfile TO it_ipfile.

ENDIF.

ENDDO.

*--Close dataset

CLOSE DATASET l_file.

Regards,

Prashant

Read only

Former Member
0 Likes
730

Hi ,

Try declaring as follows:

data: c_tab(1) TYPE c.

CLASS cl_abap_char_utilities DEFINITION LOAD.

c_tab = cl_abap_char_utilities=>horizontal_tab.

Reward points if usefull

Read only

Former Member
0 Likes
730

Hi,

You can try the same pattern code to do that.K_sep can be a constant of value #.

loop at i_file_tab into wa_file_tab.

split wa_file_tab-inp_string

at k_sep

into wa_lngtxt-objid wa_lngtxt-txtid

wa_lngtxt-lang wa_lngtxt-matnr

wa_lngtxt-werks wa_lngtxt-plnnr

wa_lngtxt-plnal wa_lngtxt-op_num

wa_lngtxt-text.

endloop.

Hope this will Help

Regards

Shibin

Read only

Former Member
0 Likes
730

Hi

In that case use this way..

SPLIT p_data AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO

INTO wa_data-field1

wa_data-field2.

The other one you have mentioned does not work for newer versions as ECC 6.0

Thanks