Application Development 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: 

Reading tab delimited file from application server

Former Member
0 Kudos
828

Hi All,

I do know that we need to use Open data set to read a file from application server, but my question is when you use read DATASET v_file into wa_final - this wa_final is an work area and also i have mentione an internal table. so do we need to Split the record at tab into the corresponding fields. Append the records into an internal table i_input.????

Please let me know on this....

thanks in advance....

Poonam....

10 REPLIES 10

Former Member
0 Kudos
313

Hi Poonam,

You need to find the Tab representation in Hexadecimal ( i think its C9 or C13)

Whenever you find the tab representation while reading the dataset you can identify which is the next field of your workarea..

Hope this helps

Regards,

Kanchan

0 Kudos
313

what if i use a constant like this:

c_tab type abap_char1 value cl_abap_char_utilities=>horizontal_tab.

then i can use split at c_tab into internal table - this ll be an internal table right which is of type table and string???

0 Kudos
313

Yes Poonam.. That will also help..

Take all the data and identify what is your delimiter mostly it is # and then split it into table form from String table type..

Former Member
0 Kudos
313

Hi,

first see the file contents in application server, how the contents whether the contents seperated by any symbol or not, if the contents seperated by any symbol then you have to split the data before appending to internal table.

check this code.

DATA: l_data_string TYPE string.

filename = p_file.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

DO.

READ DATASET filename INTO l_data_string.

IF sy-subrc NE 0.

EXIT.

ENDIF.

CLEAR k_input.

SPLIT l_data_string AT '#' INTO k_input-agreement k_input-suffix k_input-status

k_input-first_name k_input-last_name k_input-job_title k_input-tel k_input-fax k_input-email_address k_input-mob_number.

APPEND k_input TO i_input.

ENDDO.

ENDIF.

Regards,

Venu

0 Kudos
313

hi,

you have mentioned

SPLIT l_data_string AT '#' INTO k_input-agreement k_input-suffix k_input-status

k_input-first_name k_input-last_name k_input-job_title k_input-tel k_input-fax k_input-email_address k_input-mob_number.

cant i write it split i_data into workarea or internal table.

0 Kudos
313

No Split command works only for fields not for internal tables.. you can refer to F1 help of Split Statement...

0 Kudos
313

how about using an workarea???

former_member212005
Active Contributor
0 Kudos
313

The hexadecimal for the tab delimited file is '09'...

CONSTANTS: c_sep TYPE x VALUE '09'.

I think the above should help....

Former Member
0 Kudos
313

Copied from post above

Hi,

DATA: l_data_string TYPE string.

filename = p_file.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc EQ 0.

DO.

READ DATASET filename INTO l_data_string.

IF sy-subrc NE 0.

EXIT.

ENDIF.

CLEAR k_input.

SPLIT l_data_string AT '#' INTO k_input-agreement k_input-suffix k_input-status

k_input-first_name k_input-last_name k_input-job_title k_input-tel k_input-fax k_input-email_address k_input-mob_number.

APPEND k_input TO i_input.

ENDDO.

ENDIF.

Regards,

Munibabu.K

Edited by: Matt on May 26, 2009 1:23 PM

former_member212005
Active Contributor
0 Kudos
313

I am sure that the hexadecimal separator in case of Tab Delimited File is '09'.