Conditional Count using IFTRAIL

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

Moderators: Frank Yaeger, Moderator Group

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Conditional Count using IFTRAIL

Post by rajat_kharbanda » Wed Jul 04, 2012 6:05 pm

Hi,

I am not sure if anything such as this already exist in one of the posts, but if it does can you direct me to it.

I have 2 VB files, 1000 each bytes with similar format. Below is some sample data

000000XXXXXXXXXXXXXXXXX
100000XXXXXXXXXXXXYYYYYY
200000ZZZZZZZZZZZZZZZZZ
300000AAAAAAAAAAAAAAAAA
.
.
.
999999CCCCCCCCzzzzzzzzzzz

the first 6 characters give the record type where 000000 is the header (only one in each file) and 999999 is the trailer (only one in each file). The data in both these files exist in sets such as record types 100000, 200000 and 300000 form 1 set. Every set in the files will contain 1 record each for 100000 and 200000. There may be none or many records in each set corresponding to 300000.

What needs to be achieved here is a merge of these 2 files with the output containing one header and one trailer. The trailer (999999) should have the count of SETS and not records, 8 bytes starting position 7.

Each set could be identified by the record 100000, so basically the trailer should have a count of 100000 type records.

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

Post by William Collins » Thu Jul 05, 2012 5:12 am

When you say "merge" do you mean that as MERGE in its meaning in SORT utilities? If so, what would you use as the key? If not, can you please clarify?

Which SORT product are you using? WHEN=GROUP and PUSH an ID would "count" the 100000 records. KEYBEGIN in DFSORT, RESTART a sequence number and BEGIN=sequenceno1 for Syncsort.

PUSH to the beginning of the record as you have variable-length records.

The ID (effectively a sequence number for the group) will magically appear on your trailer.

You need to BUILD to obliterate the ID from the data records and to include it on the trailer. A GROUP with a sequence number with BEGIN for the trailer should allow you to INCLUDE/OMIT the trailer you don't want. Similar for the header.

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Thu Jul 05, 2012 8:05 am

Hi William,

Thanks for getting back. No, I mean a direct merge here. Say file 1 has records 1,2,5,3 and File 2 has 6,2,4,8. I would want the output to have records in the order 1,2,5,3,6,2,4,8.

I did have this solution on my mind, but was looking for a simpler solution where I do not have to amend anything to the record.

Thanks.

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Jul 05, 2012 1:18 pm

That is not a merge - that is a concatenation.
Regards
Nic

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Thu Jul 05, 2012 1:23 pm

Well Nic, it's upto a person's perception. From my perceptive, if I have 2 files with 1 containing records of 80 bytes and the other containing records of 120 bytes, I would say on concatenation, I would get a file of 200 bytes.

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Thu Jul 05, 2012 1:30 pm

I think I was wrong on how I depicted the merge in my first reply. To make it more clear, if i have the records in 1st file as:
1
2
5
3

and my second file has records as

6
2
4
8
I would need the final o/p as

1
2
5
3
6
2
4
8

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Jul 05, 2012 4:57 pm

I still agree with Nic.
Regards,
Anuj

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Thu Jul 05, 2012 5:20 pm

Well if that is the case. Refer to the above problem as a concatenation instead of merge.

Apologies for misleading.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Thu Jul 05, 2012 7:26 pm

One person's perception does not really matter. . . What does matter is that we all use the same terminology (otherwise everything quickly gets out of control). It is a good thing to train one's perception to use the standard/acceptable terminology and not somthing that one or a few have decided to use because they prefer it.

When you combine these 2 files, what should the output be (recfm, lrecl, anthing else we should know to help)?
Have a good one

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Thu Jul 05, 2012 10:00 pm

MERGE in sort terms is getting all the records from 2 or more datasets into a key sequence. Sticking the contents of one or more datasets to the end of another dataset so that the whole lot looks like one big dataset is concatenation. You actually are doing neither as your datasets are of different record lengths. You now have to say which dataset is to be forced to the record length of the other dataset - presumably by padding the first dataset with blanks to the full 120 bytes required. Of course, you may be willing to have the last 40 bytes chopped off the second dataset.
Regards
Nic

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Fri Jul 06, 2012 7:42 am

Well, I have already apologized for my thinking/perception being wrong.
The point where I talked about different file lengths was just to explain what I thought was concatenation.
I have given all the file details in my original problem. RECFM=VB, LRECL=1000.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Jul 06, 2012 8:05 am

If you want to create a single file frm the 2 existing files copy from the inputs to a new output.

Depending on whether a combined file is even necessary, you could simply use te following to read the data

Code: Select all

//INPUT    DD DSN=the.first.dsn,DISP=OLD
//         DD DSN=the.second.dsn,DISP=OLD 
If you only need to read them as one file, the above will work. It you really need the combined file, use the above as the SORTIN DD of a Sort copy step.
Have a good one

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Fri Jul 06, 2012 8:09 am

Thanks for this. This was simple, the tricky part comes where I need the count of record sets in the trailer.

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Jul 06, 2012 8:11 am

Follow on:

Don't beat yourself up too much :wink:

We may appear a bit harsh, but if we help, it is usually worth it.
Have a good one

rajat_kharbanda
Member
Posts: 11
Joined: Mon Feb 27, 2012 7:35 pm

Post by rajat_kharbanda » Fri Jul 06, 2012 8:12 am

I agree DikDude. That is why I keep coming back. :)

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