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
 

 

If-Then based implementation using DFSORT

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

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 1:21 pm    Post subject: If-Then based implementation using DFSORT
Reply with quote

Hi,

I have an input file of LRECL=80.
My requirement is as below:
IF (1,4,CH,EQ,C'AAAA')
THEN - CHECK FOR IMMEDIATE NEXT RECORD IF IT'S (1,4,CH,EQ,C'BBBB'). Then, write those two records to output file.

there are chances in the input file that, the immediate next records first 4 bytes have characters other than 'BBBB' in which case we dont want to write to output file.

Eg INPUT FILE :
Code:

QQQQ RECORD1
WWWW RECORD2
AAAA RECORD3
EEEE RECORD4
XXXX RECORD5
BBBB RECORD6
TTTT RECORD7
YYYY RECORD8
AAAA RECORD9
BBBB RECORD10
HHHH RECORD11
LLLL RECORD12
AAAA RECORD13
RRRR RECORD14
BBBB RECORD15
PPPP RECORD16
AAAA RECORD17
BBBB RECORD18
IIII RECORD19
FFFF RECORD20


And the output file must be
Code:

AAAA RECORD9
BBBB RECORD10
AAAA RECORD17
BBBB RECORD18



Thanks in advance.
Back to top
View user's profile Send private message

girishbs13

New User


Joined: 11 Nov 2011
Posts: 24
Location: India

PostPosted: Mon Dec 05, 2011 3:36 pm    Post subject: Reply to: If-Then based implementation using DFSORT
Reply with quote

Hi Aslam,

Here is the DFSORT step which will do what you asked for. I have assumed LRECL=80, RECFM=FB for your output file.

Code:
//STEP0010 EXEC PGM=SORT               
//SYSOUT    DD SYSOUT=*                 
//SORTIN    DD *                       
QQQQ RECORD1                           
WWWW RECORD2                           
AAAA RECORD3                           
EEEE RECORD4                           
XXXX RECORD5                           
BBBB RECORD6                           
TTTT RECORD7                           
YYYY RECORD8                           
AAAA RECORD9                           
BBBB RECORD10                           
HHHH RECORD11                           
LLLL RECORD12                           
AAAA RECORD13
RRRR RECORD14                                                 
BBBB RECORD15                                                 
PPPP RECORD16                                                 
AAAA RECORD17                                                 
BBBB RECORD18                                                 
IIII RECORD19                                                 
FFFF RECORD20                                                 
/*                                                           
//SORTOUT  DD DSN=O/p file
//SYSIN DD *                                                 
  OPTION COPY                                                 
  INREC  IFTHEN(WHEN=GROUP,BEGIN(1,4,CH,EQ,C'AAAA'),         
            END(1,4,CH,EQ,C'BBBB'),                           
            PUSH(15:SEQ=1,16:1,15))                           
  OUTFIL INCLUDE=(1,4,CH,EQ,C'BBBB',AND,15,1,CH,EQ,C'2'),     
            BUILD=(16,13,/,1,13,67X)                         
/*
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Dec 05, 2011 3:48 pm    Post subject: Reply to: If-Then based implementation using DFSORT
Reply with quote

And if the input is like this?

Code:

AAAA RECORD9                           
AAAB RECORD11                           
BBBB RECORD10                           
AAAA RECORD17                                                 
BBBB RECORD18     


I'm assuming the keys are representative, rather than actual.

Code:
AAAA
XXXX
AAAA
MMMM
XXXX


Can this type of combination logically exist, and what do you want to do when it does. Here XXXX is the "important" thing.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 4:04 pm    Post subject:
Reply with quote

I tried the above code, and it wrked fine. Awesome.
But at the same time when I give the input through a file, then the output file comes empty. Why is it doing so... May be i am missing something out of my ignorance.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 4:09 pm    Post subject:
Reply with quote

Hello Bill Woodger,

The input file will be the same way as I have given.
Back to top
View user's profile Send private message
girishbs13

New User


Joined: 11 Nov 2011
Posts: 24
Location: India

PostPosted: Mon Dec 05, 2011 4:12 pm    Post subject:
Reply with quote

Hi Aslam,

It should work fine with a file input.

Can you post your step here?
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 4:22 pm    Post subject:
Reply with quote

Hello Girish, My code is below

Code:

//S1 EXEC PGM=SORT                                         
//SYSOUT DD SYSOUT=*                                       
//SORTIN DD DSN=TEST.INPUT.FILE,DISP=SHR
//SORTOUT DD DSN=TEST.OUTPUT.FILE,         
//           DISP=(NEW,CATLG,DELETE)                       
//SYSIN DD *                                               
  OPTION COPY                                               
    INREC  IFTHEN(WHEN=GROUP,BEGIN(1,4,CH,EQ,C'AAAA'),     
              END(1,4,CH,EQ,C'BBBB'),                       
              PUSH(15:SEQ=1,16:1,15))                       
    OUTFIL INCLUDE=(1,4,CH,EQ,C'BBBB',AND,15,1,CH,EQ,C'2'),
              BUILD=(16,13,/,1,13,67X)                     
/*                                                                                                       


The TEST.INPUT.FILE has the same records as I have mentioned in my first post.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Dec 05, 2011 4:25 pm    Post subject: Reply to: If-Then based implementation using DFSORT
Reply with quote

Aslam,

When you give it a dataset, is the dataset fixed-length or variable-length records? If variable, (in the RECFM) then you'd need to adjust for the RDW by adding four bytes to all the start positions.

If BBBB represents the lowest logical key possibe after the AAAA key, then you should be OK with the above code.
Back to top
View user's profile Send private message
girishbs13

New User


Joined: 11 Nov 2011
Posts: 24
Location: India

PostPosted: Mon Dec 05, 2011 4:33 pm    Post subject:
Reply with quote

Hi Aslam,

Please create your output file with LRECL,
If you want a file with record length lower than 80, accordingly change the 67X in the build statement.
Back to top
View user's profile Send private message
techslam

New User


Joined: 03 Dec 2010
Posts: 87
Location: India

PostPosted: Mon Dec 05, 2011 5:08 pm    Post subject:
Reply with quote

Hello girish,

I have included DCB=(LRECL=80,RECFM=FB) for the sortout file, but still, the output files comes empty....
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Dec 05, 2011 5:23 pm    Post subject: Reply to: If-Then based implementation using DFSORT
Reply with quote

Again then, what is the RECFM of your input dataset?

If it contains the same data, and you have the same sort cards, then, assuming you are not getting NOT CATLG's messages for the output, the RECFM must not include F. If it does, then you don't have the same data or you don't have the same sort cards. Or magic has happened. Magic isn't real. Check your input RECFM, contents of dataset and sort cards.

If still mystificed, post the lot, in the Code tags.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1712
Location: UK

PostPosted: Mon Dec 05, 2011 9:23 pm    Post subject:
Reply with quote

You also need to give the output file some space and a place to stay.
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 How to get the remainder and quotient... vnktrrd DFSORT/ICETOOL 2 Mon Oct 31, 2016 10:59 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm
This topic is locked: you cannot edit posts or make replies. Job to wait and continue based on reply yugendran COBOL Programming 5 Wed Oct 05, 2016 1:46 pm
No new posts how to split records based on specifi... Venkata Ramayya DFSORT/ICETOOL 6 Wed Sep 28, 2016 3:20 am


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