SORT query?

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
Varun Dhawan
Member
Posts: 3
Joined: Wed Sep 14, 2011 7:31 pm

SORT query?

Post by Varun Dhawan » Fri Oct 04, 2013 11:09 pm

Hi All,

I am trying to report something out via DFSORT/ICETOOL. The input file is as below:

A B C D E
1 2 3 4 5
6 7 3 9 1
5 6 6 8 2
Date: <today's date>
....
....

So A, B, C, D, E are actually headers to which the information 1, 2, 3, 4 5 correspond. Now, we will assume here that they are aligned here so that information is at the bottom of header. I can modify the code later as per the row/column position specifics.
There may be multiple rows between column header and till the time 'Date' literal is encountered.

The objective is to extract all the lines before the 'Date' literal whose value in column C is '3'.

The output should be:

A C E
1 3 5
6 3 1

Is it achievable via SORT/ICETOOL or should i just proceed with writing a COBOL program for it?

Regards
Varun

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Sat Oct 05, 2013 3:55 am

Yes.

Do you have more data after "Date"?

If not, it is an INCLUDE COND=( with an AND, to include your heading for the third column and the value you want for the third column.

The use INREC BUILD=( to format the output you want.

If there is data after "Date", you can use IFTHEN=(WHEN=GROUP with a BEGIN for the "Date" and PUSH the date field onto all the subsequent records (you don't need the records, so you can do it at position 1 without causing a problem). Then use OUTFIL OMIT= to get rid of all the records marked with "Date".

Varun Dhawan
Member
Posts: 3
Joined: Wed Sep 14, 2011 7:31 pm

Post by Varun Dhawan » Wed Oct 09, 2013 5:10 pm

Thank you for the quick response William.

Your suggestion would've worked (we had more date after DATE) but in light of the further requirements that have popped in, I have decided to move ahead a write a COBOL program.

Regards
Varun

Varun Dhawan
Member
Posts: 3
Joined: Wed Sep 14, 2011 7:31 pm

Post by Varun Dhawan » Thu Oct 10, 2013 12:24 am

Okay, seems like I'd need sort after all, different task though -

Input 80 byte FB file:

Hello Varun
AA BB CC DD EE
FF GG HH II JJ
Hello William
11 22 33 44 55

Desired Output:
AA Varun BB CC DD EE
FF Varun GG HH II JJ
11 William 22 33 44 55

NOTE: Values like AA, BB, 11, 22 etc may be different. Keywords 'Varun' and 'William' will remain fixed, its just that i dont know how many lines will i have under the 'Hello Varun' or 'Hello William' record.

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others