IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Getting previous record using SORT


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Thu Jul 12, 2012 11:02 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 12, 2012 8:04 pm
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

Global Moderator


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

PostPosted: Thu Jul 12, 2012 8:31 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 13, 2012 12:18 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top