Hi,
we are trying to read a file from <b>Application server</b> in to an internal table using datasets.
The structure of internal table is
DATA : BEGIN OF IT_FILE_DATA OCCURS 10,
OBDNO(10), "OBD NO
BUDAT(10), "DATE
QTY(17), "QTY
UNIT(3), "UNIT
STOCKTYP(1), "STOCK TYPE
END OF IT_FILE_DATA.
And the data in flat file in Application server looks like
8010915223.02.20052MT1 , ie separated by ~ .
Is there any way by which by a single "read dataset" command , we can get the fields from file in to corresponding fields of the work area?
Thanx in advance ,
Regards,
Sriram.
Hi Sriram!
Use read dataset with a text variable (e.g. char50).
Then use split text at '~' into it_file_data-obdno it_file_data-budat...
This should do the job.
Regards,
Christian
Hi,
Here's an example:
READ DATASET DSIN INTO WA.
SPLIT WA AT '~' INTO TABLE SPTAB.
LOOP AT SPTAB.
IDX = IDX + 1.
ASSIGN COMPONENT IDX OF STRUCTURE IT_FILE_DATA TO <FS1>.
If sy-subrc = 0.
<FS1> = SPTAB-field.
Endif.
Endloop.
Regards Andreas
Add a comment