2009 May 26 7:20 AM
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....
2009 May 26 7:39 AM
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
2009 May 26 7:41 AM
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???
2009 May 26 7:48 AM
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..
2009 May 26 7:45 AM
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
2009 May 26 8:39 AM
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.
2009 May 26 9:26 AM
No Split command works only for fields not for internal tables.. you can refer to F1 help of Split Statement...
2009 May 26 9:53 AM
2009 May 26 9:59 AM
The hexadecimal for the tab delimited file is '09'...
CONSTANTS: c_sep TYPE x VALUE '09'.
I think the above should help....
2009 May 26 10:43 AM
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
2009 May 26 10:46 AM
I am sure that the hexadecimal separator in case of Tab Delimited File is '09'.