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

Appending Flag for record for duplicates in a file


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

New User


Joined: 21 May 2009
Posts: 5
Location: India

PostPosted: Thu May 21, 2009 3:48 pm
Reply with quote

I have a File in Below FORMAT


A1 X
A1 X
A2 X
A2 Y

I want the out put as

A1 X Y
A1 X Y
A2 X N
A2 Y N

Here in the input file is sorted A1 and X feilds. On match of the feilds I want the Y at End and On no duplicate record should have N at end.

Please advice.

Regards,
Chaitanya KVK
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu May 21, 2009 4:48 pm
Reply with quote

Hi,

try this
Code:
//STEP0001 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD *                                                     
A1 X                                                                 
A1 X                                                                 
A2 X                                                                 
A2 Y                                                                 
//T1       DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)     
//OUT      DD SYSOUT=*                                               
//TOOLIN   DD *                                                     
SORT FROM(IN) TO(T1) USING(CTL1)                                     
SPLICE FROM(T1) TO(OUT) ON(1,4,CH) KEEPBASE KEEPNODUPS -             
  WITHALL WITH(1,4) USING(CTL2)                                     
/*                                                                   
//CTL1CNTL DD *                                                     
  SORT FIELDS=(1,4,CH,A)                                             
  OUTREC OVERLAY=(6:SEQNUM,8,ZD,RESTART=(1,4))                       
/*                                                                   
//CTL2CNTL DD *                                           
  SORT FIELDS=(1,4,CH,A,6,8,ZD,D)                         
  OUTFIL FNAMES=OUT,                                       
    IFTHEN=(WHEN=(6,8,ZD,GT,+1),BUILD=(1,4,06:C'Y')),     
    IFTHEN=(WHEN=NONE,BUILD=(1,4,06:C'N'))                 
/*                                                         




Gerry
Back to top
View user's profile Send private message
kvkchaitanya

New User


Joined: 21 May 2009
Posts: 5
Location: India

PostPosted: Thu May 21, 2009 5:38 pm
Reply with quote

Thanks a Lot!! Its working
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 21, 2009 10:42 pm
Reply with quote

kvkchaitanya,

As your data is already sorted on the key, the following 1 pass DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
A1 X                                                             
A1 X                                                             
A2 X                                                             
A2 Y                                                             
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,5,X,SEQNUM,8,ZD,RESTART=(1,4)))
  SORT FIELDS=(1,4,CH,A,7,8,CH,D)                                 
                                                                 
  OUTREC IFOUTLEN=6,IFTHEN=(WHEN=INIT,                           
  OVERLAY=(6:C'N',15:SEQNUM,8,ZD,RESTART=(1,4))),                 
  IFTHEN=(WHEN=GROUP,BEGIN=(15,8,ZD,EQ,1),PUSH=(15:7,8)),         
  IFTHEN=(WHEN=((7,8,ZD,EQ,1,AND,15,8,ZD,GT,1),OR,7,8,ZD,GT,1),   
  OVERLAY=(6:C'Y'))                                               
/*                                                               
Back to top
View user's profile Send private message
kvkchaitanya

New User


Joined: 21 May 2009
Posts: 5
Location: India

PostPosted: Thu May 21, 2009 11:01 pm
Reply with quote

Thanks!!

One Small addition If the data to be comapred is not in first 4 Bytes

i.e

A1 is at 1st position
I have some data and then
X at 12 th posiiton.

Like

A1 abcdef X
A1 deftgx X
A2 abcdef X
How can I modify the Tool to get the desired output.

A1 abcdef X Y
A1 deftgx X Y
A2 abcdef X N
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 21, 2009 11:28 pm
Reply with quote

kvkchaitanya,

*Sigh*

1. Tell me your Input LRECL and RECFM
2. What is the Postion of the keys (a,x) , are they 1 and 12?
3. What about the length of the keys (a,x) are they 4 and 1?
4. What is the output LRECL and RECFM?
5. What is the position of the flag in the OUTPUT file?
Back to top
View user's profile Send private message
kvkchaitanya

New User


Joined: 21 May 2009
Posts: 5
Location: India

PostPosted: Thu May 21, 2009 11:36 pm
Reply with quote

1) LRECL = 1220 and RECFM= FB
2) A is in Position 1
X is in Position 350
3) A is of 11 bytes length
X is of 10 Bytes lenth
4) Output LRECL = 1220 and RECFM= FB
5) Flag position is 1219
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Thu May 21, 2009 11:52 pm
Reply with quote

kvkchaitanya,

use the following control cards

Code:

//SYSIN    DD *                                                 
  INREC IFTHEN=(WHEN=INIT,                                     
  OVERLAY=(1221:1,11,350,10,SEQNUM,8,ZD,RESTART=(1221,21)))     
  SORT FIELDS=(1221,21,CH,A,1242,8,CH,D)                       
  OUTREC IFOUTLEN=1220,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(1219:C'N',1250:SEQNUM,8,ZD,RESTART=(1221,21))),     
  IFTHEN=(WHEN=GROUP,BEGIN=(1250,8,ZD,EQ,1),PUSH=(1242:1242,8)),
  IFTHEN=(WHEN=(1242,8,ZD,GT,1),OVERLAY=(1219:C'Y'))           
/*                                                             
Back to top
View user's profile Send private message
kvkchaitanya

New User


Joined: 21 May 2009
Posts: 5
Location: India

PostPosted: Fri May 29, 2009 4:44 pm
Reply with quote

On using the above sort card it is giving the following error kindly suggest.

SYSIN :
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(1221:1,11,350,10,SEQNUM,8,ZD,RESTART=(1221,21)))
SORT FIELDS=(1221,21,CH,A,1242,8,CH,D)
OUTREC IFOUTLEN=1220,IFTHEN=(WHEN=INIT,
*
OVERLAY=(1219:C'N',1250:SEQNUM,8,ZD,RESTART=(1221,21))),
IFTHEN=(WHEN=GROUP,BEGIN=(1250,8,ZD,EQ,1),PUSH=(1242:1242,8)),
IFTHEN=(WHEN=(1242,8,ZD,GT,1),OVERLAY=(1219:C'Y'))
WER161B ALTERNATE PARM USED
WER268A OUTREC 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
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri May 29, 2009 8:27 pm
Reply with quote

Hello,

You are using Syncsort rather than DFSORT.

Suggest you talk with your system support people to have the current version of Syncsort installed if you are not running Syncsort 1.3.n.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Jun 01, 2009 4:49 pm
Reply with quote

kvkchaitanya,

We dont really need a 'WHEN=GROUP' clause here. I have modified Kolusu's job to achieve the same without the 'WHEN=GROUP' clause.
May be you can try this out which should work for SyncSort for z/OS 1.2.
Code:
//SYSIN    DD *                                                 
  INREC IFTHEN=(WHEN=INIT,                                     
  OVERLAY=(1221:1,11,350,10,SEQNUM,8,ZD,RESTART=(1221,21)))     
  SORT FIELDS=(1221,21,CH,A,1242,8,CH,D)                       
  OUTREC IFOUTLEN=1220,IFTHEN=(WHEN=INIT,                       
  OVERLAY=(1219:C'Y',1250:SEQNUM,8,ZD,RESTART=(1221,21))),     
  IFTHEN=(WHEN=(1242,8,ZD,EQ,1,AND,1250,8,ZD,EQ,1),OVERLAY=(1219:C'N'))
/* 
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 FTP VB File from Mainframe retaining ... JCL & VSAM 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top