‎2007 Aug 28 6:20 PM
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
‎2007 Aug 28 8:54 PM
hi lalit,
use the split key owrd to split the data in a single thread.
‎2007 Aug 29 4:39 AM
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>