Upcoming eventsCOBOL
Do you use COBOL?
|
FileUtilityFile Search, Sort and Join UtilityThis is a proposal to create a file utility that can sort, search, join files and have subtotals at sort breaks. Look at the example bellow. The output would be filec containing the fields in both filea and fileb and only records whre the joined fields reside in both files. open input filea fd filea 01 filearec. 05 field1 pic x(10). 05 field2 pic x(20). 05 field3 pic x(10). sort filea on field2, field3. open input fileb. fd fileb. 01 copy filebdef. sort fileb on keyfield. join filea.field2 to fileb.keyfield. *>works like innerjoin
output filec from filea, fileb.
go
Search and Subtotal example open input filea fd filea 01 filearec. 05 field1 pic x(10). 05 field2 pic x(20). 05 field3 pic x(10). 05 field4 pic 9(4)v99. if field1(1:1) = "a" sort filea on field2, field3. 01 totalfld1 pic 9(4)v99 = field4. 01 totalfld2 pic 9(4)v99 = field4. 01 countfld pic 9(4) = 1. outout filed from filea, totalfld1 subtotal reset at field3, totalfld2 subtotal noreset, countfld subtotal noreset. go
|
Login |