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

How to break Column to Multiple Rows based on certain cond


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Thu Apr 02, 2009 10:54 am
Reply with quote

Hi,

I have an input file in the below format,

01 Input-Rec.
05 ID pic x(04).
05 FILLER pic X(01).
05 Code1-A pic X(01).
05 Code1-B pic X(01).
05 FILLER pic X(01).
05 Code2-A pic X(01).
05 Code2-B pic X(01).
05 FILLER pic X(01).
05 Code3-A pic X(01).
05 Code3-B pic X(01).

Input file contents are shown below:

I/P:-

0001 YY YN NY
0002 NY YY YY
0003 YN NY YY
0004 YY YY YN

In the above input for ID 0001, we have code1, code2 and code3 where Code1-A ===> After Image (Y) and
Code1-B ===> Before Image (Y) are same.

But Code2-A ===> After Image (Y) and
Code2-B ===> Beofre Image (N) is different

in the same way Code3 Before and After Image are different.

Now I want to break into Rows as specified below:-

O/P:-

0001
Code2 Y N Code1 is removed since Before and After image is same
Code3 N Y

0002
Code1 N Y Code2 and Code3 are removed since the image is same

0003
Code1 Y N
Code2 N Y

0004
Code3 Y N
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Thu Apr 02, 2009 5:58 pm
Reply with quote

Code:
//STEP1 EXEC PGM=ICETOOL                                               
//TOOLMSG  DD  SYSOUT=*                                                 
//DFSMSG   DD  SYSOUT=*                                                 
//SYSOUT   DD  SYSOUT=*                                                 
//TEMP1   DD DISP=(,DELETE,DELETE),SPACE=(CYL,(10,10),RLSE),DSN=&&TEMP1
//OUTFILE DD SYSOUT=*   **your outfile
//INFILE DD *                                                           
0001 YY YN NY                                                           
0002 NY YY YY                                                           
0003 YN NY YY                                                           
0004 YY YY YN                                                           
/*                                                                     
//TOOLIN DD *                                                           
 COPY FROM(INFILE) TO(TEMP1) USING(CTL1)                               
 COPY FROM(TEMP1) TO(OUTFILE) USING(CTL2)                               
//CTL1CNTL DD *                                                         
 OUTFIL FNAMES=TEMP1,IFTHEN=(WHEN=(5,1,CH,EQ,C' '),                             
       BUILD=(1:1,4,/,                                             
       1:C'CODE1 ',7:6,2,/,                                             
       1:C'CODE2 ',7:9,2,/,                                             
       1:C'CODE3 ',7:12,2,80:X))   
/*                                   
//CTL2CNTL DD *                                                         
 INCLUDE COND=((7,1,CH,NE,8,1,CH),OR,7,1,CH,EQ,C' ')   
/*   
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 02, 2009 11:09 pm
Reply with quote

Hariprasad_Pargunan,

The following DFSORT JCL will give you the desired results. Since there are 3 different codes to check , the unique combinations will be 3 factorial which is 6. so we check for the 6 possible values and write out the records

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                 
0001 YY YN NY                                                   
0002 NY YY YY                                                   
0003 YN NY YY                                                   
0004 YY YY YN                                                   
0005 YN YN YN                                                   
0006 YY YY YY                                                   
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  SORT FIELDS=COPY                                               
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,13,C'111')),                 
  IFTHEN=(WHEN=(06,2,CH,EQ,C'YY'),OVERLAY=(14:C'0'),HIT=NEXT),   
  IFTHEN=(WHEN=(09,2,CH,EQ,C'YY'),OVERLAY=(15:C'0'),HIT=NEXT),   
  IFTHEN=(WHEN=(12,2,CH,EQ,C'YY'),OVERLAY=(16:C'0'))             

  OUTFIL IFOUTLEN=8,OMIT=(14,3,ZD,EQ,0),                         
  IFTHEN=(WHEN=(14,3,ZD,EQ,1),                                   
  BUILD=(1,4,/,C'CODE3 ',12,2)),                                 

  IFTHEN=(WHEN=(14,3,ZD,EQ,10),                                 
  BUILD=(1,4,/,C'CODE2 ',06,2,/,C'CODE3 ',09,2)),               

  IFTHEN=(WHEN=(14,3,ZD,EQ,11),                                 
  BUILD=(1,4,/,C'CODE2 ',09,2,/,C'CODE3 ',12,2)),               

  IFTHEN=(WHEN=(14,3,ZD,EQ,100),                                 
  BUILD=(1,4,/,C'CODE1 ',06,2)),                                 

  IFTHEN=(WHEN=(14,3,ZD,EQ,101),                                 
  BUILD=(1,4,/,C'CODE1 ',06,2,/,C'CODE3 ',12,2)),               

  IFTHEN=(WHEN=(14,3,ZD,EQ,110),                                 
  BUILD=(1,4,/,C'CODE1 ',06,2,/,C'CODE2 ',09,2)),               

  IFTHEN=(WHEN=(14,3,ZD,EQ,111),                                 
  BUILD=(1,4,/,C'CODE1 ',06,2,/,C'CODE2 ',09,2,/,C'CODE3 ',12,2))
/*
Back to top
View user's profile Send private message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Fri Apr 03, 2009 1:52 pm
Reply with quote

Hi,

Both the SORT cards are woking perfectly. Thank you so much.

Actually I tried the second option given by Skolusu in slightly different way but I got error in my SORT card.

I have used the HIT=NEXT function in "IFTHEN BUILD" control statement which results in error. But using HIT=NEXT along with OVERLAY didnt throw any error. Could you please explain me about this constraint?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Apr 03, 2009 8:47 pm
Reply with quote

Quote:
Actually I tried the second option given by Skolusu in slightly different way but I got error in my SORT card.

I have used the HIT=NEXT function in "IFTHEN BUILD" control statement which results in error.


HIT=NEXT is allowed with BUILD.

There are several IFTHEN BUILD clauses, so it's not clear what you changed or what error you received. Please show the specific IFTHEN clause you changed and the //SYSOUT messages you received including the error message.
Back to top
View user's profile Send private message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Mon Apr 06, 2009 9:55 am
Reply with quote

Hi Frank Yaeger,

Please find below my SORT card and SYSOUT error message,

Code:
//SYSIN    DD    *                           
 SORT FIELDS=COPY                             
 OUTFIL IFTHEN=(WHEN=INIT,                   
                BUILD=(1,4)),                 
        IFTHEN=(WHEN=(06,1,CH,NE,07,1,CH),   
                BUILD=(/,06,1,07,1),HIT=NEXT),
        IFTHEN=(WHEN=(09,1,CH,NE,10,1,CH),   
                BUILD=(/,09,1,10,1),HIT=NEXT),
        IFTHEN=(WHEN=(12,1,CH,NE,13,1,CH),   
                BUILD=(/,12,1,13,1)),         
        IFTHEN=(WHEN=NONE,     
                BUILD=(4X))                   
/*


Code:

SYSIN :                                                     
 SORT FIELDS=COPY                                           
 OUTFIL IFTHEN=(WHEN=INIT,                                   
                BUILD=(1,4)),                               
        IFTHEN=(WHEN=(06,1,CH,NE,07,1,CH),                   
                BUILD=(/,06,1,07,1),HIT=NEXT),               
                                    *                       
        IFTHEN=(WHEN=(09,1,CH,NE,10,1,CH),                   
                BUILD=(/,09,1,10,1),HIT=NEXT),               
        IFTHEN=(WHEN=(12,1,CH,NE,13,1,CH),                   
                BUILD=(/,12,1,13,1)),                       
        IFTHEN=(WHEN=NONE,                                   
                BUILD=(4X))                                 
WER901I  **WARNING** SYNCSORT 1.3.1.0 WILL EXPIRE IN 48 DAYS
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                   
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000               
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE               
Back to top
View user's profile Send private message
vinothsubramanian

New User


Joined: 01 Sep 2006
Posts: 39
Location: Chennai, India

PostPosted: Mon Apr 06, 2009 11:57 am
Reply with quote

Did you try the one which I posted?
Back to top
View user's profile Send private message
himanshu7

Active User


Joined: 28 Aug 2007
Posts: 131
Location: At Desk

PostPosted: Mon Apr 06, 2009 12:13 pm
Reply with quote

Code:
WER901I  **WARNING** SYNCSORT 1.3.1.0 WILL EXPIRE IN 48 DAYS
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                   
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000               
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE   



Your Shop is using Syncsort and not DFSORT.

Please get the mannual from your syncsort support guys and check for the commands,Almost all the DFSORT cmnds works with syncsort but still you need to check with the syncsort support.
Back to top
View user's profile Send private message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Mon Apr 06, 2009 4:48 pm
Reply with quote

Vinoth,

I have tried your SORT Card and its working fine.

Himan,

I am getting error only when I use ",/," in IFTHEN BUILD function along with HIT=NEXT option.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Apr 07, 2009 1:23 am
Reply with quote

Hariprasad_Pargunan,

There are multiple problems with your code. It is nothing like what Skolusu provided. Did you try his code as written?
Back to top
View user's profile Send private message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Wed Apr 08, 2009 9:12 am
Reply with quote

Hi Alissa Margulies,

I have tried SKolusu's Sort Card its working perfectly.

You are right there are lot of mistakes in my Sort card. Now i have changed it please see below,

Code:

//SORTIN   DD    *                                           
0001 YY YN NY                                               
0002 NY YY YY                                               
0003 YN NY YY                                               
0004 YY YY YN                                               
/*                                                           
//SORTOUT  DD    SYSOUT=*                                   
//*                                                         
//SYSOUT   DD    SYSOUT=*                                   
//SYSIN    DD    *                                           
 SORT FIELDS=COPY                                           
 OUTFIL IFOUTLEN=80,                                         
        IFTHEN=(WHEN=INIT,                                   
                BUILD=(1,04,76X,6,2,9,2,12,2)),             
        IFTHEN=(WHEN=(81,1,CH,NE,82,1,CH),                   
                BUILD=(/,1:C'CODE1',X,81,1,X,82,1),HIT=NEXT),
        IFTHEN=(WHEN=(83,1,CH,NE,84,1,CH),                   
                BUILD=(/,1:C'CODE2',X,83,1,X,84,1),HIT=NEXT),
        IFTHEN=(WHEN=(85,1,CH,NE,86,1,CH),                   
                BUILD=(/,1:C'CODE3',X,85,1,X,86,1)),         
        IFTHEN=(WHEN=NONE,                                   
                BUILD=(80X))                                 
/*                                                           



Sysout Error message
Code:

SYSIN :                                                       
 SORT FIELDS=COPY                                             
 OUTFIL IFOUTLEN=80,                                         
        IFTHEN=(WHEN=INIT,                                   
                BUILD=(1,04,76X,6,2,9,2,12,2)),               
        IFTHEN=(WHEN=(81,1,CH,NE,82,1,CH),                   
                BUILD=(/,1:C'CODE1',X,81,1,X,82,1),HIT=NEXT),
                                                   *         
        IFTHEN=(WHEN=(83,1,CH,NE,84,1,CH),                   
                BUILD=(/,1:C'CODE2',X,83,1,X,84,1),HIT=NEXT),
        IFTHEN=(WHEN=(85,1,CH,NE,86,1,CH),                   
                BUILD=(/,1:C'CODE3',X,85,1,X,86,1)),         
        IFTHEN=(WHEN=NONE,                                   
                BUILD=(80X))                                 
WER901I  **WARNING** SYNCSORT 1.3.1.0 WILL EXPIRE IN 47 DAYS 
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                     
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                 
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE                 



I am getting this error only when using "/" option in IFTHEN BUILD function along with HIT=NEXT option.
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Apr 08, 2009 9:17 pm
Reply with quote

Multi-line BUILD statements cannot be used with HIT=NEXT.
Back to top
View user's profile Send private message
Hariprasad_Pargunan

New User


Joined: 08 Jan 2009
Posts: 20
Location: Chennai

PostPosted: Thu Apr 09, 2009 9:11 pm
Reply with quote

Hi Alissa Margulies,

Thanks for your clarification!
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Sort based on the record type DFSORT/ICETOOL 1
No new posts Reflection 3270 screen shows only 23 ... Compuware & Other Tools 6
No new posts SORT JCL to merge multiple tow into s... DFSORT/ICETOOL 6
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
Search our Forums:

Back to Top