View previous topic :: View next topic
|
Author |
Message |
vaibhavkolhe
New User
Joined: 24 Feb 2005 Posts: 11
|
|
|
|
Hello,
I need to perform an internal sort in a cobol program and I will be using Input Procedure & Output Procedure to do it. The following is the description of the Input file
FD INFILE
01 INREC.
05 IN-REC-TYPE PIC X(3)
05 IN-PA-CODE PIC x(2)
05 IN-PROD-TYPE PIC X(1)
05 IN-AGT-NAME PIC X(20).
......
FD OUTFILE
01 OUTREC.
05 OUT-REC-TYPE PIC X(3)
05 OUT-PA-CODE PIC x(2).
05 OUT-PROD-TYPE PIC X(1).
05 OUT-AGT-NAME PIC X(20).
I need to sort the INFILE on IN-PA-CODE, IN-PROD-TYPE and IN-AGT-NAME in that order. However, I need to have a different value in the SORT-PROD-TYPE field which will be hard coded in the Input procedure. After sorting, and releasing the record, I need to write a report based on OUT-PROD-TYPE.
Question:
1. What would be the definition of the SORT-REC?
2. If the SORT field is a part of the data record, does it affect the output records?
3. Can anybody list the algorithm of how this can be done?
Thanks,
Vaibhav |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
I will be using Input Procedure & Output Procedure to do it. |
conflicts with
Quote: |
I need to sort the INFILE |
Either you are using INPUT PROCEDURE and OUTPUT PROCEDURE, or you are using a file sort -- you can't have it both ways unless you're doing two sorts.
Define your SORT RECORD with the fields you want to sort -- and the SORT RECORD does not have to match your input file layout, your output file layout, or anything else. Code up your INPUT PROCEDURE and OUTPUT PROCEDURE statements to do the processing you want. Compile, bind, and run. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
If you post your SD and your SORT statement, someone will be able to confirm if you are moving in the right direction. . . |
|
Back to top |
|
|
arunmozhicholan
New User
Joined: 07 Feb 2007 Posts: 27 Location: chennai
|
|
|
|
Hi ,
1)What would be the definition of the SORT-REC?
you need to define on wat condition going to sort that needs to be in
SD entry
2. If the SORT field is a part of the data record, does it affect the output records?
YES
3. Can anybody list the algorithm of how this can be done?
Release sort-rec asc/dec keys
using input procedure file 1 file 2
output procedure file 3
while reading the file u need to move the values to sort record which u have in sd entry and relaese
and open the input file
Return in the ouput procedure
from sort record |
|
Back to top |
|
|
|