Application Development 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: 

Re: Read Dataset

Former Member
0 Kudos

Hi All,

i am reading flat file from application server.

my file contains records in the following order

First line : indicator

second line: header

third line: item details

-


-


-


i am using read dataset and moving the data into a string

how do i split header and item details in single record in an internal table?

Please reply with some sample code

2 REPLIES 2

Former Member
0 Kudos

hi lalit,

use the split key owrd to split the data in a single thread.

varma_narayana
Active Contributor
0 Kudos

Hi Lalit..

Let us assume the Header record contains the indicator in First position as H

and the Item record contains the indicator in First position as I

This is a sample code: you have to change it as per ur req:

DATA : V_REC(1000).

PARAMETERS : P_DSN(40).

OPEN DATASET P_DSN FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

exit.

ENDIF.

DO.

READ DATASET P_DSN INTO V_REC.

if sy-subrc ne 0.

exit.

endif.

IF v_rec(1) = 'H'.

SPLIT V_REC AT '/' INTO ITAB-FIELD1 ITAB-FIELD2. "Header fields

elseif v_rec(1) = 'I'.

SPLIT V_REC AT '/' INTO ITAB-FIELD3 ITAB-FIELD4. "Item fields

APPEND ITAB.

endif.

ENDDO.

close dataset p_dsn.

<b>Reward if Helpful.</b>