Conditional Count using IFTRAIL
Moderators: Frank Yaeger, Moderator Group
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
Conditional Count using IFTRAIL
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.
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.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 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.
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.
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
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.
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.
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 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)?
When you combine these 2 files, what should the output be (recfm, lrecl, anthing else we should know to help)?
Have a good one
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
Nic
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
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
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.
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
Have a good one
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
-
- Member
- Posts: 11
- Joined: Mon Feb 27, 2012 7:35 pm
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page