Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to extract certain records, then SORT the rest(same file)in COBOL

Status
Not open for further replies.

chitownjoe

Programmer
Mar 27, 2001
5
US
How would I code(PROCEDURE DIVISION), to first extract
certain records(ie. ACCT-NO = '0001400100'), write them
to a file, then SORT the rest of the records, and include
the sorted records, in the same file? I've pretty much
got the rest of the program coded, just need to add this
logic, the best way possible. Thanks-CHITOWN JOE
 
Hi Joe,

Is this a mainframe application? If so, I may be able to help.

Jack
 
OK. I'll try to get the ball rolling for you. I assume the compiler you're using supports the internal SORT verb. You can use INPUT & OUTPUT PROCEDURES.

Create a sort rec layout that looks identical to your input rec, except that the acct# is preceeded by one extra byte. This bye becomes the 1st byte of the key you sort by (key = 1byte + acct#).

On the input side, test for acct# 00014etc. If = move 1 to
xtra byte else move 0.

On the output side, strip off the byte you added to each record and return it to the sort. If you can live w/the xtra byte, you don't need an O/P PROCEDURE.

You'll have to decide where the rest of your code belongs.

The resulting file will be in the order you want. That is if I understood your problem correctly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top