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

Help me ..!

Former Member
0 Likes
430

Plse help me in this.this is not giving me proper output.

i am having flat file with tab delimiter...i want to use split command to get the data.check my code

data : begin of itab occurs 0,

matnr type c,

mbrsh type c,

meins type c,

end of itab.

data : begin of jtab occurs 0,

data(1024) type c,

end of jtab.

data : sep type xstring. ****byte string****

call function 'GUI_UPLOAD'

exporting

filename = 'C:\flat_files\sam.txt'

FILETYPE = 'ASC'

READ_BY_LINE = 'X'

tables

data_tab = jtab.

loop at jtab.

sep = 09. *****ASCII code for tab

split jtab-data at sep into itab-matnr itab-mbrsh itab-meins.

endloop.

loop at itab.

write : / itab-matnr ,itab-mbrsh , itab-meins.

endloop.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
411

Hi,

Instead of using ASCII code....do this,

declare this stmt,

constants: con_tab value cl_abap_char_utilities=>horizontal_tab.

and write the below stmt..instead of urs..

split jtab-data at con_tab into itab-matnr itab-mbrsh itab-meins.

Hopr this helps u,

Regrds,

Arunsri

Edited by: Arunsri on Mar 5, 2008 5:23 AM

3 REPLIES 3
Read only

Former Member
0 Likes
412

Hi,

Instead of using ASCII code....do this,

declare this stmt,

constants: con_tab value cl_abap_char_utilities=>horizontal_tab.

and write the below stmt..instead of urs..

split jtab-data at con_tab into itab-matnr itab-mbrsh itab-meins.

Hopr this helps u,

Regrds,

Arunsri

Edited by: Arunsri on Mar 5, 2008 5:23 AM

Read only

Former Member
0 Likes
411

Hi,

IF you want to upload a tab separated file then just pass this parameter in GUI_UPLOAD

has_field_separator = 'X'

No need to have separate coding.

Regards,

Atish

Read only

Former Member
0 Likes
411

Hi Ravi,

You didn't specify the length of fields in the itab structure. The length of the fields will be considered as 1 char. Here is the efficient way of reading data from a file which is tab delimited.

For the function module GUI_UPLOAD there is a parameter "has_field_separator" for which you can

specify whether your file is tab delimited or comma delimited,etc. If it is tab delimited you assign 'X' . If you use this parameter you dont have to use "split" command. The data in the file will be uploaded into the fields of the internal table directly. I commented the unnecessary code.

data : begin of itab occurs 0,
matnr(18) type c,
mbrsh type c,
meins(3) type c,
end of itab.

*** data : begin of jtab occurs 0,
*** data(1024) type c,
*** end of jtab.

**** data : sep type string.

call function 'GUI_UPLOAD'
exporting
filename = 'C:\flat_files\sam.txt'
FILETYPE = 'ASC'
READ_BY_LINE = 'X'
has_field_separator = 'X'
tables
data_tab = itab.

**loop at jtab.
**
**sep = 09.
**
**split jtab-data at sep into itab-matnr itab-mbrsh itab-meins.
*endloop.

loop at itab.
write : / itab-matnr ,itab-mbrsh , itab-meins.
endloop.

Reward all helpful answers..

Sunny