2008 Mar 11 5:31 AM
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.
2008 Mar 11 5:34 AM
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.
2008 Mar 11 5:34 AM
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
2008 Mar 11 5:36 AM
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
2008 Mar 11 5:37 AM
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
2008 Mar 11 5:41 AM
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
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |