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

Issues on Read Dataset

Former Member
0 Likes
750

Hi All,

I required to read the data from application server, which the data is in below layout. Each fields are separated by tab. How I can read each of the fields and append to internal table.

Field1#Field2#Field3

Below are my current coding which unable to read out the fields. Please kindly help me to correct it...if i'm wrongly. Thanks.

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.

DO.

READ DATASET p_inpfl INTO i_input.

IF sy-subrc EQ 0.

APPEND i_input.

CLEAR i_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_inpfl.

ENDIF.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
726

Hi..,

U need to mention the ENCODING mode here...

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.

DO.

READ DATASET p_inpfl INTO i_input.

IF sy-subrc EQ 0.

APPEND i_input.

CLEAR i_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_inpfl.

ENDIF.

Hope this solves..

u can use <b>SPLIT INTO ITAB</b> to populate the internal table with Each and every field value separately !!

regards,

sai ramesh

Hi All,

I required to read the data from application server, which the data is in below layout. Each fields are separated by tab. How I can read each of the fields and append to internal table.

Field1#Field2#Field3

Below are my current coding which unable to read out the fields. Please kindly help me to correct it...if i'm wrongly. Thanks.

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.

DO.

READ DATASET p_inpfl INTO i_input.

IF sy-subrc EQ 0.

APPEND i_input.

CLEAR i_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_inpfl.

ENDIF.

5 REPLIES 5
Read only

Former Member
0 Likes
727

Hi..,

U need to mention the ENCODING mode here...

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.

DO.

READ DATASET p_inpfl INTO i_input.

IF sy-subrc EQ 0.

APPEND i_input.

CLEAR i_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_inpfl.

ENDIF.

Hope this solves..

u can use <b>SPLIT INTO ITAB</b> to populate the internal table with Each and every field value separately !!

regards,

sai ramesh

Read only

0 Likes
726

Hi,

I get error message in - Type...filter...message....or at position...expected after mode.

How I should make changed to current code if I using

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE <b>ENCODING DEFAULT</b>.

Thank you.

Read only

0 Likes
726

HI..

is that i_input your final table.. ?? which contains the individual fields along with their values.. Or onli it saves the entire line read from the file ??

Read only

0 Likes
726

Hi Sai ramesh,

i_input is not my final table..

I just want to read the data from application server ..then append all these values into i_input. Later I required to select the first field from i_input to extract data from others tables.

Hope this's clarify.

Thanks.

Read only

0 Likes
726

Ok fine ..

keep your original source code as it is ..

OPEN DATASET p_inpfl FOR INPUT IN TEXT MODE.

DO.

READ DATASET p_inpfl INTO i_input.

IF sy-subrc EQ 0.

APPEND i_input.

CLEAR i_input.

ELSE.

EXIT.

ENDIF.

ENDDO.

CLOSE DATASET p_inpfl.

ENDIF.

The character '#' is a Horizontal tab ..

Those '#' are special characters to indicates new line or tab. You need to use the abap objects CL_ABAP_CHAR_UTILITIES to fix this issue.

define a constant..

constants :

C_HTAB value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.<b> **<--Horizontal tab</b>

loop at i_input.

split i_input at C_HTAB into i_finaltab-field1 i_input.

split i_input at C_HTAB into i_finaltab-field2 i_input.

split i_input at C_HTAB into i_finaltab-field3 i_input.

split i_input at C_HTAB into i_finaltab-field4 i_input.

append i_tab.

endloop.

regards,

sai ramesh