This is Tikiwiki v2.2 -Arcturus- © 2002–2008 by the Tiki community 2010/09/07 21:25 PDT

Menu [toggle]

Upcoming events

COBOL

Do you use COBOL?
OpenCOBOL 1.0
OpenCOBOL 1.1
OpenCOBOL Other
Other COBOL
Not Yet

View Results
(Votes: 112)
Print

FileUtility

File Search, Sort and Join Utility
This 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

  • >for outer join use left join (see bellow) don't think right join in needed
  • >left join fileea.field2 to fileb.keyfield

output filec from filea, fileb.
  • >for specific fields only use
  • >output filec from filea.field2, filea.field3, fileb.Deptname
  • >
  • >output will erase filec before writing to append to filec use the following
  • >append filec from fila, fileb

go


  1. Once this code is parsed a COBOL source file will be produced and the command could also compile and run the program as well.
  2. Another option would be that our running cobol program be written to understand parsed code and execute the above commands.

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




Created by: jrls. Last Modification: Tuesday January 27, 2009 12:21:06 PST by jrls.