SORT card needed to exclude record set

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

Moderators: Frank Yaeger, Moderator Group

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

SORT card needed to exclude record set

Post by goldyroshan » Mon Nov 09, 2015 8:09 pm

Here is how my input records look like -

A1 00 ABC XYZ -> header
A2 10 XXX PQR -> detail record 1
A3 20 GHI STU -> detail record 2
A4 99 KKK RRR -> trailer

I want to check whenever we have XXX at this position, then I would want to exclude the entire record set (i.e. all rows from 00 (header) to 99 (trailer).
Please suggest SORT card for the same
Logically yours,
:-) GRS :-)

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

Post by William Collins » Mon Nov 09, 2015 11:23 pm

JOINKEYS with the same dataset for both inputs. Specofy the key as the first byte (ie will be A) and use a JOIN UNPAIRED,F1,ONLY

In JNF2CNTL, INCLUDE for that value at that position and also a data-record.

If there are no records to include, your entire main file will be "unmatched", meaning you want it. If matched, meaning you don't want it, you won't get any output from the JOINKEYS.

chaat
Member
Posts: 19
Joined: Sun Apr 18, 2010 11:51 pm
Location: St. Cloud, Minnesota, USA

Post by chaat » Tue Nov 10, 2015 10:52 am

William Collins wrote:JOINKEYS with the same dataset for both inputs. Specofy the key as the first byte (ie will be A) and use a JOIN UNPAIRED,F1,ONLY

In JNF2CNTL, INCLUDE for that value at that position and also a data-record.

If there are no records to include, your entire main file will be "unmatched", meaning you want it. If matched, meaning you don't want it, you won't get any output from the JOINKEYS.
this would be very easy with File-Aid MVS.

reply here if your interested.
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate
characters)

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

Post by William Collins » Tue Nov 10, 2015 12:32 pm

Always interested :-)

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Thu Nov 12, 2015 12:59 am

Bill,

I tried the one suggested by you, it didn't work.

Here is my requirement -
input file -

Code: Select all

B2 00 GGG   MISC_ORDER                  
B2 10 001  C    
B2 20 001  C    
B2 99 GLO   20151027 163020 0000002     
B2 00 HHH   MISC_ORDER                  
B2 10 200  200  
B2 20 200  200  
B2 10 200  200  
B2 20 200  200  
B2 99 GLO   20151027 163020 0000008


output file should look like this -

Code: Select all

B2 00 HHH   MISC_ORDER                  
B2 10 200  200  
B2 20 200  200  
B2 10 200  200  
B2 20 200  200  
B2 99 GLO   20151027 163020 0000008



So, whenever 200 is at 7th byte in input file, I want those records (along with header = 00 at 4th byte & trailer = 99 at 4th byte) in the o/p file.

Please assist
Logically yours,
:-) GRS :-)

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

Post by William Collins » Thu Nov 12, 2015 2:01 am

Well, of course it doesn't work. You've changed the spec.

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Thu Nov 12, 2015 8:10 pm

So anything that you can suggest?
Logically yours,
:-) GRS :-)

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Mon Nov 16, 2015 7:04 pm

So does this mean we can't do this thru a SORT? :(
Logically yours,
:-) GRS :-)

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

Post by William Collins » Mon Nov 16, 2015 9:03 pm

It can be done with SORT.

Can you post the code you tried, please?

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Mon Nov 16, 2015 10:02 pm

I only know of how to extract detail records (which even every Mainframe newcomer can do).
But I have no clue of how to extract corresponding header & trailer record for those detail records all together.
Tried checking in SORT manuals but could not get anything.
Hence seeking experts' guidance here!
Logically yours,
:-) GRS :-)

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Tue Nov 17, 2015 11:40 pm

Bill,

I tried to check sort manuals.
I felt that we can achieve this by any of this -

DATASORT operator of ICETOOL,
SUBSET operator of ICETOOL
IFTHEN WHEN=GROUP

However, I don't know what/how to do it precisely. :(
Logically yours,
:-) GRS :-)

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

Post by William Collins » Wed Nov 18, 2015 4:41 am

You use JOINKEYS, with the same dataset for both inputs.

In JNF1CNTL, you use INREC with WHEN=GROUP to PUSH an ID to a temporary extension to the record. This ID field will be your key for the first JOINKEYS statement, where you also specify SORTED,NOSEQCK.

In JNF2CNTL you using INCLUDE to identify the data that you want, and also to include all headers. Use WHEN=GROUP to do the same thing as in JNF1CNTL. Use IFTHEN=(WHEN=(logicalexpression) to identify the headers, and to set the extended ID to, for instance, binary zero. Use SUM FIELDS=NONE to avoid duplicate keys. Specify the extended ID as the second JOINKEYS key.

Don't use a JOIN statement, so you only get the matched records.

Specify your entire F1 only on the REFORMAT statement.

You should be around about there, then.

You can deal with duplicate keys in a different way. If you have many, many groups of records you may want to do it differently.

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Wed Nov 18, 2015 7:59 am

I appreciate your effort/help Bill.
But would be lot better if you could also give the actual sort card (even if its not the final polished sort card that's ok).
Logically yours,
:-) GRS :-)

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

Post by William Collins » Wed Nov 18, 2015 12:16 pm

Well, I was hoping you'd show the one that you declared as "not working" so we could polish that one.

goldyroshan
Active Member
Posts: 67
Joined: Thu Apr 05, 2012 1:29 am
Location: WI, USA

Post by goldyroshan » Fri Nov 20, 2015 9:22 pm

Okay.
I'll try this one out & get back with the results.
Thanks a lot
Logically yours,
:-) GRS :-)

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