Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Getting previous record using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Thu Jul 12, 2012 7:43 am    Post subject: Getting previous record using SORT
Reply with quote

Hi,

My input file looks like as below

AAA,TOT=100
LEVEL1,DDD
FINAL,CT
CYT=CHK
AAA,TOT=30
LEVEL1,EEE
FINAL,CT
CYT=LEV
AAA,TOT=40
LEVEL1,DDD
FINAL,CT
CYT=CHK

Here every four records is a set, i want my output file should extract its 1st record if the fourth record is having CHK in position 5. Sample o/p file as below

AAA,TOT=100
AAA,TOT=40

It should not extract AAA,TOT=30 as its 4th record is having LEV in 5th position.

Can it be done in SORT? I did in eztrieve.. but we want in SORT now...
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1537
Location: Andromeda Galaxy

PostPosted: Thu Jul 12, 2012 11:02 am    Post subject:
Reply with quote

Yes it can be done

What is your sort product ?

I understand your group header has TOT=

In DFSORT

Do a when group + push of header have it as file 1
Using File1 Remove those records which has CHK have it as file2
Join both for paired data

For samples check forum similar requirement have been discussed
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Thu Jul 12, 2012 8:04 pm    Post subject: Reply to: Getting previous record using SORT
Reply with quote

Without JOINKEYS, INCLUDE/OMIT records you don't want.
OPTION COPY
GROUP for TOT, PUSHing entire record.

IFTHEN=(WHEN=INIT to initialise marker
IFTHEN=(WHEN=(logexp for CHK and needed record, OVERLAY marker to say include/omit

OUTFIL INCLUDE/OMIT for marker, BUILD for pushed entire TOT record.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1537
Location: Andromeda Galaxy

PostPosted: Thu Jul 12, 2012 8:31 pm    Post subject:
Reply with quote

Bill,

I dont think you need WHEN=INIT or when=logical expression

This should suffice

Code:
  OPTION COPY
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,3,CH,EQ,C'TOT'),
        PUSH=(21:1,20))
  OUTFIL INCLUDE=(5,3,CH,EQ,C'CHK'),BUILD=(1:21,20)
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Fri Jul 13, 2012 7:14 am    Post subject: Reply to: Getting previous record using SORT
Reply with quote

I tried on my own and got the required o/p.... of course i used WHEN group and PUSH cards...

Thanks...
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Fri Jul 13, 2012 12:18 pm    Post subject: Reply to: Getting previous record using SORT
Reply with quote

What do you mean "on your own"?

With WHEN=GROUP the "requirement" is very easy. Too easy to post on here. Your misleading subject lead Pandora-Box to the JOINKEYS, which goes for updating the "previous record".

If you can do it yourself, we are of course very happy. Next time take the extra day before posting, and only post when you can't get it. We don't like wasting time.

And use the Code tags. You got away wiith it as your data is so trivial. Next time, even if your record looks like thus:

Code:
A


Use the Ciode tags.

Having wasted Pandora-Box's time, you could at least say "thank you".
Back to top
View user's profile Send private message
sasikumar1984

Active User


Joined: 02 Jul 2007
Posts: 109
Location: Chennai - India

PostPosted: Fri Jul 13, 2012 9:50 pm    Post subject:
Reply with quote

Bill,

Sorry, i posted the reply as soon as i got the o/p, so that others don't waste time giving reply for my post.... but missed to say thanks to Pandora-Box...

without Pandora-Box suggestion, i couldn't have achieved what i wanted....thanks a lot to Pandora-Box....also hereafter i use code tags when needed....

thanks all others too who helped me here....

i used group when and push'ed the 1st rec information next records until i get 1st record of next set and it last i separated 4th records alone with include condition.. i ddin't use JOINKEY's as it is required for my o/p...

Happy weekend...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us