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

If-Then based implementation using DFSORT


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

Moderator Emeritus


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

PostPosted: Mon Dec 05, 2011 3:48 pm
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Mon Dec 05, 2011 4:25 pm
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
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
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

Moderator Emeritus


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

PostPosted: Mon Dec 05, 2011 5:23 pm
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: 2455
Location: Hampshire, UK

PostPosted: Mon Dec 05, 2011 9:23 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts DFSORT GUID DFSORT/ICETOOL 1
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top