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


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

Overlaying value at a particular byte using SORT
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
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Tue May 06, 2014 7:14 pm    Post subject: Overlaying value at a particular byte using SORT Reply with quote

Here is the input file :-


Code:
12345 abcd KEY1 
12346 abcd KEY1
12347 abcd KEY1
22345 xyzz KEY2 
22346 xyzz KEY2
22347 xyzz KEY2


Here is the expected file :-

Code:
12345 abcd KEY1 TARGET
12346 abcd KEY1
12347 abcd KEY1
22345 xyzz KEY2 TARGET
22346 xyzz KEY2
22347 xyzz KEY2

_________________
Logically yours,
Smile GRS Smile


Last edited by goldyroshan on Wed May 07, 2014 12:42 am; edited 1 time in total
Back to top
View user's profile Send private message Yahoo Messenger
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: 714

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

PostPosted: Tue May 06, 2014 9:15 pm    Post subject: Reply with quote

The first record already seems to have TARGET on it. If you provide an expected output file, it'll probably be clearer.

Can you not use the bolding, but post instead inside the Code tags so that we can see the spacing.
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.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 12:42 am    Post subject: Reply with quote

William - Done. Edited my original post
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
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: 651
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: Wed May 07, 2014 3:59 am    Post subject: Reply with quote

Are you saying that when column 5 = '5' then you want ' Target' appended to the end of that record (or, at least, at column 17)? Also what is the RECFM and LRECL of the 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.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

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

PostPosted: Wed May 07, 2014 4:44 am    Post subject: Reply with quote

OK, thanks.

For an up-to-date DFSORT, you want INREC with IFTHEN=(WHEN=GROUP and KEYBEGIN for your key field, and PUSH a SEQ to a temporary extension of the record. The SEQ= must be long enough to cater for the maximum number of records in a group. SEQ=2 gives 99, SEQ=3 gives 999, you get the picture.

After that, you have IFHTEN=(WHEN=(logical expression to test the extened field to see if it is one. If it is, you OVERLAY your C'TARGET'.

Use IFOUTLEN= for your original record-length, so that the extended data does not get beyond INREC.

That's about it.
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.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 11:14 am    Post subject: Reply with quote

NicC wrote:
Are you saying that when column 5 = '5' then you want ' Target' appended to the end of that record (or, at least, at column 17)? Also what is the RECFM and LRECL of the dataset?


NicC - Nope. Whenever value at position 12 is KEY1, I would want 'TARGET' populated in position 17. It is also important to note that there are other multiple records for the same value of KEY1 - for those other records, I do not want to overlay TARGET at position 17.

RECFM = FB, LRECL = 1200
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 11:15 am    Post subject: Reply with quote

William Collins wrote:
OK, thanks.

For an up-to-date DFSORT, you want INREC with IFTHEN=(WHEN=GROUP and KEYBEGIN for your key field, and PUSH a SEQ to a temporary extension of the record. The SEQ= must be long enough to cater for the maximum number of records in a group. SEQ=2 gives 99, SEQ=3 gives 999, you get the picture.

After that, you have IFHTEN=(WHEN=(logical expression to test the extened field to see if it is one. If it is, you OVERLAY your C'TARGET'.

Use IFOUTLEN= for your original record-length, so that the extended data does not get beyond INREC.

That's about it.



William - you gave a lot of info here, I was not able to absorb all of it.
Please give me a SORT JCL for the above, I would be in a better position to relate the above description to it.
TIA!
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
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: 714

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

PostPosted: Wed May 07, 2014 2:07 pm    Post subject: Reply with quote

Take it a step at a time.

Code:
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(your key),PUSH=(20:SEQ=2))


If you run that (untested, you'll have to fix any typos) with the sample data you showed and look at what is produced.

You should then notice that the first record in a group has "01" on it. Brilliant. Now it is an easy task. If that value is "01" use OVERLAY to get "TARGET" where you want.

Read up on IFOUTLEN in the manual. It sets the record-length for when all the IFTHEN processing is finished. If you run the above with IFOUTLEN=15 in INREC, you won't see the SEQ that has been added.
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: 651
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: Wed May 07, 2014 2:27 pm    Post subject: Reply with quote

Quote:
Whenever value at position 12 is KEY1, I would want 'TARGET' populated in position 17

Then why does
Code:
22345 xyzz KEY2
become
Code:
22345 xyzz KEY2 TARGET
and the other records with KEY1 not have TARGET appended?
_________________
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.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 2:43 pm    Post subject: Reply with quote

KEY1, KEY2, KEY3..........& so on are just unique identifiers for these records (record set).

so for every KEY1 or KEY2 or KEY3 we have multiple records (having the same Key value = KEY1/2/3). For the 1st occurence of this record, we need to have TARGET at 17th position. All other occurences/records of same KEY need not be overlayed with TARGET. We need to do the same for other KEY2, KEY3..so on
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
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: 651
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: Wed May 07, 2014 3:28 pm    Post subject: Reply with quote

So what you are wanting is: on change of key append 'TARGET' to the first record of the new key. If that understanding is correct then I am beginning to see what William is getting at with his hints.
_________________
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.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 3:47 pm    Post subject: Reply with quote

Yes, you got it right.
So what is the best way to achieve this?
Should I try William's approach?
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
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: 714

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

PostPosted: Wed May 07, 2014 3:54 pm    Post subject: Reply with quote

You mean you haven't already? What was the point of me suggesting anything? You just want to wait for someone to give you the code? Kick back for a long wait. After a few hours waiting, you may as well just try out what I've suggested anyway. Never know, maybe you can do it?
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: 651
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: Wed May 07, 2014 6:06 pm    Post subject: Reply with quote

Put it this way: William knows a whole lot more about DFSort than I do - my eyes glaze over after about page 2 of the manual!
_________________
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.
goldyroshan
Active Member


Joined: 05 Apr 2012
Posts: 67
Location: WI, USA

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

PostPosted: Wed May 07, 2014 9:48 pm    Post subject: Reply with quote

William - Sorry; I didn't mean to offend you, but I was looking for a simpler way (if any).
I did try out what you had suggested, but I could not get the desired results out of that. I basically could not understand (practically) the effect of having a PUSH.
Will get back to you on this, if needed for this issue.

Therefore, as of now I have adopted an altogether different approach :-

I found out that 1st 2 bytes of every record set (having same KEY1) has a definite pattern, so I used this -

OPTION COPY
INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'12'),OVERLAY=(995:C'TARGET)

so whenever, I have a '12' in first 2 positions, I can overlay the 995th position to TARGET. (yes, 995th position was what I had wanted).

Many Many Thanks to William & NicC.
_________________
Logically yours,
Smile GRS Smile
Back to top
View user's profile Send private message Yahoo Messenger
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

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts REMOVE HIGH VALUE FROM THE EXTRACT FILE 2 Guest 6920 Fri May 09, 2008 11:04 am
Krishna View latest post
No new posts Redefine with the larger value. 5 sjadhav 7519 Wed Mar 28, 2007 4:52 am
DavidatK View latest post
No new posts Inserting NULL 5 jaydeeppal 10642 Tue Oct 17, 2006 6:41 pm
dbzTHEdinosauer View latest post
No new posts sink value 0 padmapriya7 3312 Fri Mar 03, 2006 5:42 pm
padmapriya7 View latest post
No new posts query regarding matching field value 3 jasveer 5981 Mon Feb 20, 2006 3:51 pm
jasveer View latest post
 


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-7553.html