To better assist, I need an example of the data. There are two ways to handle reading the file.
SAMPLE DATA:
test.dat
1abc9999999999
20000aaaaaaaaaaaa
1cdf8888888888
29393llllllllllll
1dkd8383838383
1iej8383838281
29342oweselcoekco
As you can see there are two different records within this table. The 1st column distinguishes them.
1st method.
Create a master file description for the file.
The mfd can contain one field that has a format of Axx where xx is the max length of the field. Then you filedef the file and then you can read each record in and parse the record into fields. Example
tofile.mas
FILENAME=TOFILE, SUFFIX=FIX
SEGNAME=TOFILE, SEGTYPE=S
FIELD=TODATA, ALIAS=TDATA, USAGE=A80, ACTUAL=A80,$
FILEDEF TOFILE DISK test.dat
DEFINE FILE TOFILE
FIELE1/A1 = EDIT(TODATA, '9');
FIELD2/A3 = EDIT(TODATA, '$999');
FIELD3/A10 = EDIT(TODATA, '$$$$9999999999');
END
TABLE FILE TOFILE
PRINT FIELD2 FIELD3
IF FIELD1 EQ '1'
ON TABLE HOLD AS MYFILE
END
Change your define for field1 eq '2' and pull out those records into another file.
2nd method.
This method uses dialog manager to create two fixed format files from one, just created an appropriate mfd to read them once they're created:
FILEDEF TOFILE DISK test.dat
FILEDEF MYFILE1 DISK test1.dat
FILEDEF MYFILE2 DISK test2.dat
-SET &SPC = ' ';
-LOOP1
-READ TOFILE &CHK.A1. &XRECORD.A16.
-IF &IORETURN GT 0 THEN GOTO IMDONE;
-*
-IF &CHK EQ '2' THEN GOTO F2TYP;
-*-----------------
-* PROCESS FILETYPE '1' RECORDS
-*-----------------
-SET &F1FIELD = EDIT(&XRECORD, '999');
-SET &F2FIELD = EDIT(&XRECORD, '$$$9999999999');
-SET &WLINE = &F1FIELD | &SPC | &F2FIELD;
-WRITE MYFILE1 &WLINE
-GOTO LOOP1
-*
-F2TYP
-*-----------------
-* PROCESS FILETYPE '2' RECORDS
-*-----------------
-SET &F1FIELD = EDIT(&XRECORD, '9999');
-SET &F2FIELD = EDIT(&XRECORD, '$$$$999999999999');
-SET &WLINE = &F1FIELD | &SPC | &F2FIELD;
-WRITE MYFILE2 &WLINE
-GOTO LOOP1
-*
-----------------
-* ALL FINISHED
-*---------------
-IMDONE
Hope this helps.....................