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
 

 

IFTHEN to reformat the matching and non matching condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> SYNCSORT
View previous topic :: :: View next topic  
Author Message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Fri Sep 25, 2015 2:53 pm    Post subject: IFTHEN to reformat the matching and non matching condition
Reply with quote

Hi,

I have a requirement to reformat the input file record and write to output file if at least one condition given in IFTHEN statements is satisfied, else I can ignore the record for output file. I would like to know if it is possible to handle using IFTHEN statement so that I may not need two steps to handle this scenario.

Sample Code below

Code:

//********************************************************
//SORTSTEP EXEC PGM=SORT                                 
//********************************************************
//SYSOUT   DD SYSOUT=*                                   
//SORTOUT  DD SYSOUT=*                                   
//SORTIN   DD *                                           
123455                                                   
ABC123                                                   
PQR456                                                   
/*                                                       
//SYSIN    DD *                                           
 SORT FIELDS=COPY                                         
 INREC IFTHEN=(WHEN=((01,03,CH,EQ,C'ABC')),               
                BUILD=(1:C'TEST1',6:4,6,69X)),           
       IFTHEN=(WHEN=((01,03,CH,EQ,C'PQR')),               
                BUILD=(1:C'TEST2',6:4,6,69X))             
/*                                                       


Output
Code:

123455                     
TEST1123                   
TEST2456                   


since the 1st record in my input did not match any IFTHEN conditions, I do not want the 1st record to be reformatted and copied to output file.

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

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Sep 25, 2015 3:28 pm    Post subject: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

So, use
Code:

 INCLUDE COND=(1,3,CH,EQ,C'ABC',
              OR,
               1,3,CH,EQ,C'PQR')


or

Code:
 INCLUDE COND=(1,3,SS,EQ,C'ABC.PQR')


The "." in the literal can be any character which does not appear in the data.

On large datasets, prefer the first version anyway.
Back to top
View user's profile Send private message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Fri Sep 25, 2015 3:59 pm    Post subject: Re: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

Bill Woodger wrote:
So, use
Code:

 INCLUDE COND=(1,3,CH,EQ,C'ABC',
              OR,
               1,3,CH,EQ,C'PQR')


or

Code:
 INCLUDE COND=(1,3,SS,EQ,C'ABC.PQR')


The "." in the literal can be any character which does not appear in the data.

On large datasets, prefer the first version anyway.


Thanks, Bill.

I did a mistake when I chose the sample data. Here, the reformatting would not be same for each condition e.g. reformatting for ABC will not be same as PQR.

If I go with INCLUDE COND for different format, I think we need to copy the output to separate files (say OUTFIL01, OUTFIL02) for each condition. However, I would like to copy both the reformatted record into same output file.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Sep 25, 2015 4:20 pm    Post subject: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

The INCLUDE COND=/OMIT COND= are just a filter on the input file. You do whatever you want in the rest of the code. There is no connection between the two things.

Don't confuse these with INCLUDE=/OMIT= on OUTFIL. Those would filter that OUTFIL data only.
Back to top
View user's profile Send private message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Fri Sep 25, 2015 6:42 pm    Post subject: Re: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

Bill Woodger wrote:
The INCLUDE COND=/OMIT COND= are just a filter on the input file. You do whatever you want in the rest of the code. There is no connection between the two things.

Don't confuse these with INCLUDE=/OMIT= on OUTFIL. Those would filter that OUTFIL data only.


Thanks, Bill.

Please help me to handle the below scenario using INCLUDE COND.

Input

Code:

123455                                                   
ABC123                                                   
ABC789
PQR456
PQR012


When the 1st three bytes is ABC, I would like to reformat the input rec to output file as below.
Code:

TEST1123BBB
TEST1789BBB


When the 1st three bytes is PQR, I would like to reformat the input rec to output file as below.

Code:

TEST2BBB456
TEST2BBB012


In above output, B represents Blank Space. I would like to reformat and copy the matched recs to one output file and ignore unmatched rec (in my sample - 1st record).
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7228

PostPosted: Fri Sep 25, 2015 7:27 pm    Post subject: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

Code:
  SORT FIELDS=COPY                                         
 
  INCLUDE COND=(1,3,CH,EQ,C'ABC',
              OR,
               1,3,CH,EQ,C'PQR')
 
  INREC IFTHEN=(WHEN=((01,03,CH,EQ,C'ABC')),               
                 BUILD=(1:C'TEST1',6:4,6,69X)),           
        IFTHEN=(WHEN=((01,03,CH,EQ,C'PQR')),               
                 BUILD=(1:C'TEST2',6:4,6,69X))


Find Figure 2. Record Processing Order in the DFSORT Application Programming Guide and see if that helps clarify things.

The order of processing is the same for SyncSORT (may be more options) you can check in your own manual and let us know.
Back to top
View user's profile Send private message
maki_psg

New User


Joined: 28 Jan 2010
Posts: 47
Location: India

PostPosted: Fri Sep 25, 2015 9:47 pm    Post subject: Re: Reply to: IFTHEN to reformat the matching and non matching condition
Reply with quote

Bill Woodger wrote:
Code:
  SORT FIELDS=COPY                                         
 
  INCLUDE COND=(1,3,CH,EQ,C'ABC',
              OR,
               1,3,CH,EQ,C'PQR')
 
  INREC IFTHEN=(WHEN=((01,03,CH,EQ,C'ABC')),               
                 BUILD=(1:C'TEST1',6:4,6,69X)),           
        IFTHEN=(WHEN=((01,03,CH,EQ,C'PQR')),               
                 BUILD=(1:C'TEST2',6:4,6,69X))


Find Figure 2. Record Processing Order in the DFSORT Application Programming Guide and see if that helps clarify things.

The order of processing is the same for SyncSORT (may be more options) you can check in your own manual and let us know.



Thanks a lot, Bill. It really helped me to reduce the number of steps, and get the expected result. :)
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 -> SYNCSORT All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Matching with Key at different postions. rajatbagga DFSORT/ICETOOL 12 Wed Nov 09, 2016 10:58 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts TSO Logon Failing - Acount Not matching SLNewton TSO/ISPF 1 Thu Aug 25, 2016 9:37 pm
No new posts OUTREC FILELDS FAILS WITH ICE126A 2 ... balaji81_k DFSORT/ICETOOL 8 Sat Jul 02, 2016 1:22 am
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am


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