Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : When you specified V for RECFM parameter, LRECL value is largest record in the file plus 4 bytes. These four bytes contain the actual length of each variable length record in the file

Google
 
Web mainframegurukul.com

Conditional Count using IFTRAIL
Goto page 1, 2  Next
 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities
  View previous topic :: View next topic  
Author Message
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jul 04, 2012 6:05 pm    Post subject: Conditional Count using IFTRAIL Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

William Collins
Active Member


Joined: 24 May 2012
Posts: 732

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 5:12 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 8:05 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
NicC
Active Member


Joined: 24 Jul 2011
Posts: 650
Location: Down on the pig farm

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 1:18 pm    Post subject: Reply with quote

That is not a merge - that is a concatenation.
_________________
Regards
Nic
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 1:23 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 1:30 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Anuj Dhawan
Moderator


Joined: 09 Aug 2008
Posts: 1625
Location: Mumbai, India

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 4:57 pm    Post subject: Reply with quote

I still agree with Nic.
_________________
Regards,
Anuj
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 5:20 pm    Post subject: Reply with quote

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

Apologies for misleading.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 7:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
NicC
Active Member


Joined: 24 Jul 2011
Posts: 650
Location: Down on the pig farm

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Jul 05, 2012 10:00 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jul 06, 2012 7:42 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jul 06, 2012 8:05 am    Post subject: Reply with quote

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:

//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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jul 06, 2012 8:09 am    Post subject: Reply with quote

Thanks for this. This was simple, the tricky part comes where I need the count of record sets in the trailer.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
DikDude
Moderator


Joined: 22 Jul 2011
Posts: 1001
Location: usa

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jul 06, 2012 8:11 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
rajat_kharbanda
Member


Joined: 27 Feb 2012
Posts: 11

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Jul 06, 2012 8:12 am    Post subject: Reply with quote

I agree DikDude. That is why I keep coming back. Smile
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities All times are GMT + 5 Hours
Goto page 1, 2  Next
Page 1 of 2



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-6662.html