Using Standalone Rowsets to Write a File
The following is an example of using standalone rowsets along with a file layout to write a file:

The following example writes a file using a file layout that contains parent-child records:
Local File &MYFILE;
Local Rowset &rsBusExp, &rsBusExpPer, &rsBusExpDtl;
Local Record &rBusExp, &rBusExpPer, &rBusExpDtl;
Local SQL &SQL1, &SQL2, &SQL3;
&rBusExp = CreateRecord(Record.PERSONAL_DATA);
&rBusExpPer = CreateRecord(Record.BUS_EXPENSE_PER);
&rBusExpDtl = CreateRecord(Record.BUS_EXPENSE_DTL);
&rsBusExp = CreateRowset(Record.PERSONAL_DATA,
CreateRowset(Record.BUS_EXPENSE_PER,
CreateRowset(Record.BUS_EXPENSE_DTL)));
&rsBusExpPer = &rsBusExp.GetRow(1).GetRowset(1);
&MYFILE = GetFile("c:\temp\BUS_EXP.out", "W", "UTF8", %FilePath_Absolute);
&MYFILE.SetFileLayout(FileLayout.BUS_EXP_OUT);
&EMPLID = "8001";
&SQL1 = CreateSQL("%selectall(:1) where EMPLID = :2", &rBusExp, &EMPLID);
&SQL2 = CreateSQL("%selectall(:1) where EMPLID = :2", &rBusExpPer, &EMPLID);
While &SQL1.Fetch(&rBusExp)
&rBusExp.CopyFieldsTo(&rsBusExp.GetRow(1).PERSONAL_DATA);
&I = 1;
While &SQL2.Fetch(&rBusExpPer)
&rBusExpPer.CopyFieldsTo(&rsBusExpPer(&I).BUS_EXPENSE_PER);
&J = 1;
&SQL3 = CreateSQL("%selectall(:1) where EMPLID = :2
and EXPENSE_PERIOD_DT = :3", &rBusExpDtl, &EMPLID,
&rsBusExpPer(&I).BUS_EXPENSE_PER.EXPENSE_PERIOD_DT.Value);
&rsBusExpDtl = &rsBusExpPer.GetRow(&I).GetRowset(1);
While &SQL3.Fetch(&rBusExpDtl)
&rBusExpDtl.CopyFieldsTo(&rsBusExpDtl(&J).BUS_EXPENSE_DTL);
&rsBusExpDtl.InsertRow(&J);
&J = &J + 1;
End-While;
&rsBusExpPer.InsertRow(&I);
&I = &I + 1;
End-While;
&MYFILE.WriteRowset(&rsBusExp);
End-While;
&MYFILE.Close();The previous code generates the following output file.
AA8001 Schumacher,Simon
BB8001 06/11/1989YNA0 Customer Go-Live Celebration
CC8001 06/11/1989
06/01/198908226.83 USDEntertain Clients ⇒
10100
BB8001 08/31/1989YNA0 Customer Focus Group Meeting
CC8001 08/31/198908/11/1989012401.58 USDCustomer Visit ⇒
10100
CC8001 08/31/198908/12/198904250.48 USDCustomer Visit ⇒
10100
CC8001 08/31/198908/12/198902498.34 USDCustomer Visit ⇒
10100
BB8001 03/01/1998YYP0 Attend Asia/Pacific Conference
CC8001 03/01/199802/15/1998011200 USDConference ⇒
00001
CC8001 03/01/199802/16/19980220000 JPYConference ⇒
00001
BB8001 05/29/1998NNP0 Annual Subscription
CC8001 05/29/199805/29/199814125.93 USDSoftware, Inc. ⇒
10100
BB8001 08/22/1998NNP0 Regional Users Group Meeting
CC8001 08/22/199808/22/19981045.69 USDDrive to Meeting ⇒
10100
CC8001 08/22/199808/22/19980912.44 USDCity Parking ⇒
10100
BB8001 12/12/1998NNP0 Customer Visit: Nevco
CC8001 12/12/199812/02/199801945.67 USDCustomer Feedback ⇒
00001
CC8001 12/12/199812/02/19981010.54 USDTo Airport ⇒
00001
CC8001 12/12/199812/03/19980610 USDAirport Tax ⇒
00001
CC8001 12/12/199812/03/199804149.58 USDCustomer Feedback ⇒
00001
CC8001 12/12/199812/04/1998055.65 USDCheck Voicemail ⇒
00001
CC8001 12/12/199812/04/19980988 USDAirport Parking ⇒
00001
CC8001 12/12/199812/04/199802246.95 USDCustomer Feedback ⇒
00001
CC8001 12/12/199812/04/199803135.69 USDCustomer Feedback 00001