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

Reading file from Application Server

Former Member
0 Likes
965

Hi All,

I have an old program which is throwing up an issue.

I am succesfully uploading a tab-delimited(DAT) text file from a local server using the 'UPLOAD' Function Module. But when I try to use the same file saved in the application server and upload it using 'OPEN DATASET P_FILE FOR INPUT IN TEXT MODE' statement and next 'READ DATASET P_FILE INTO INT_TABLE', it is not considering the tab-delimiters and reading the adjacent fields into a single field using # as the separator

For example in the text file I have 3 fields

Field1 Field2 Field3

AAAAA BBBBB CCCCC

After the READ DATASET statement the work area is being populated as <wa>-field1 = AAAAA#BB

<wa>-field2 = BBB#CCC

<wa>-field3 = CC

The field length's of the 3 fields are 8, 7 & 7 respectively.

Could you suggest me a solution such that the fields are populated as below

<wa>-field1 = AAAAA

<wa>-field2 = BBBBB

<wa>-field3 = CCCCC

Thanks,

Karthik

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
847

may be you have to split it manually

split <text> at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into filed1 field2 field3 etc.

Regards

Raja

9 REPLIES 9
Read only

athavanraja
Active Contributor
0 Likes
848

may be you have to split it manually

split <text> at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into filed1 field2 field3 etc.

Regards

Raja

Read only

0 Likes
847

Durai,

Thanks for the answer but this OO Concept CL_ABAP_CHAR_UTILITIES is not available in 4.6C.

Regards,

Karthik

Read only

0 Likes
847

Karthik,

Then use:

data: g_delim(1) type x value '09'.

Cheers,

Pat.

Read only

0 Likes
847

data : tab type x .

move: '09' to tab .

now use tab in place of CL_ABAP_CHAR_UTILITIES=>horizontal_tab

Regards

Raja

Read only

0 Likes
847

Hi,

I will try this, but could you please explain what is the significance of '09'. I have not understood that.

Thanks,

Karthik

Read only

0 Likes
847

'09' is the Hexadecimal value for tab.

regds

gv

Read only

0 Likes
847

Hi,

data: hor_tab type x value '09'.

is the hex value of horizontal tab. When you work in binary mode you can read this values and split your fields at it.

Svetlin

P.S. In case you find some answers useful, please assign reward poits.

Read only

former_member221770
Contributor
0 Likes
847

Hi Karthik,

Try something like this:

data: g_data(1000) type c,

g_delim TYPE c value cl_abap_char_utilities=>horizontal_tab. "Tab Delim

open dataset....

read dataset into g_data.

split g_data at g_delim into ....

append ....

Let me know how this goes.

Cheers,

Pat.

Read only

Former Member
0 Likes
847

Hi,

Open the dataset in IN BINARY MODE ( not in text mode ) and use SPLIT stmt at tab.

Svetlin