Split Input Based Upon Last Digit of Integer Field

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

Moderators: Frank Yaeger, Moderator Group

Post Reply
Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

Split Input Based Upon Last Digit of Integer Field

Post by Dunbar » Tue Jun 17, 2014 9:02 pm

Looking for some assistance. Im attempting to split an input file into 5 outputs based upon the last digit of an integer field (5,4). The only way I have been able to accomplish this is convert the integer/binary field to ZD and then split based upon ZD as shown below. The conversion to ZD seems to add some overhead in cpu/time and Im trying to find another way to avoid using it.

Any suggestions would be greatly appreciated.

Code: Select all

INCLUDE COND=((80,18,CH,EQ,C'NNNNNNNNNNNNNNNNNN',AND,
             39,1,CH,EQ,C'Y',AND,
             38,1,CH,EQ,C'M'),OR,
             (80,18,CH,NE,C'NNNNNNNNNNNNNNNNNN'))
INREC FIELDS=(1:1,24,25:27,06,31:34,24,55:59,46,
              101:5,4,BI,TO=ZD,LENGTH=5)
SORT FIELDS=(5,4,BI,A,1,4,BI,A)
OUTFIL FNAMES=DD01O,INCLUDE=(105,1,ZD,EQ,0,OR,105,1,ZD,EQ,1)
OUTFIL FNAMES=DD02O,INCLUDE=(105,1,ZD,EQ,2,OR,105,1,ZD,EQ,3)
OUTFIL FNAMES=DD03O,INCLUDE=(105,1,ZD,EQ,4,OR,105,1,ZD,EQ,5)
OUTFIL FNAMES=DD04O,INCLUDE=(105,1,ZD,EQ,6,OR,105,1,ZD,EQ,7)
OUTFIL FNAMES=DD05O,INCLUDE=(105,1,ZD,EQ,8,OR,105,1,ZD,EQ,9)

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

Post by William Collins » Wed Jun 18, 2014 2:25 am

You're doing somewhat more than just converting.

What you want to do is forget the INREC, and look at how to do "bit logic tests" for your INCLUDE=.

By the way, unless unavoidable (like SORT FIELDS=, SUM FIELDS=, REFORMAT FIELDS=) don't use FIELDS=, use BUILD.

Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

Post by Dunbar » Wed Jun 18, 2014 2:53 am

Correct, the INCLUDE and INREC statements were existing. My change was to change from a single output and split to 5 records based upon the last digit in the 5,4 field which is leading field in sort card.

Dunbar
Member
Posts: 7
Joined: Tue Jun 17, 2014 8:50 pm
Location: Arkansas

Post by Dunbar » Wed Jun 18, 2014 3:39 am

So here is the original I started with. It still seems very inefficient to me. Can you please elaborate what you mean by not using FIELDS? What alternative is there for the SORT statement or you mean I should use multiple sort steps to accomplish this? I changed the INREC FIELDS to INREC BUILD statement and didnt see much change in my test job.

Code: Select all

 INREC FIELDS=(1:1,24,25:27,06,31:34,24,55:59,46)
 SORT FIELDS=(5,4,BI,A,1,4,BI,A)
 OUTFIL FNAMES=DD01O,
    INCLUDE=((76,18,CH,EQ,C'NNNNNNNNNNNNNNNNNN',AND,
             36,1,CH,EQ,C'Y',AND,
             35,1,CH,EQ,C'M'),OR,
             (76,18,CH,NE,C'NNNNNNNNNNNNNNNNNN'))

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

Post by William Collins » Wed Jun 18, 2014 4:34 am

As I tried to indicate, FIELDS means many things, depending on where it is used. This is for historical reasons.

INREC FIELDS, OUTREC FIELDS and OUTFIL OUTREC all exist, and will be supported forever. But INREC BUILD, OUTREC BUILD and OUTFIL BUILD are better to use than FIELDS/OUTREC, because BUILD only means BUILD, and does the same thing at each point of the processing.

Using BUILD instead of FIELDS/OUTREC will change nothing at all, except make it easier to understand.

Whoever wrote the INREC origianlly did not know what they were doing, because they made it harder to maintain through the inclusion of unnecessary column numbers.

Having INCLUDE COND rather than the INCLUDE= on OUTFIL is more efficient, because not all records on the file will be SORTed before they are ignored. If worried about performance, rearrange the conditions in the COND= so that the most likely to be true is first.

Then you need to look at your documentation to see how to test bits in INCLUDE/OMIT COND and INCLUDE/OMIT=. This will save you from having the conversion to ZD. I don't think it'll make a stunning difference, but it'll save some.

The time is taken up by the SORT. If you need to SORT, not much you can do about that (if the order of duplicate keys is not important, ensure you have NOEQUALS).

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