Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Appending Flag for record for duplicates in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Appending Flag for record for duplicates in a file
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: 1703
Location: Australia

PostPosted: Thu May 21, 2009 4:48 pm    Post subject:
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    Post subject: Reply to: Appending Flag for record for duplicates in a fil
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    Post subject: Reply to: Appending Flag for record for duplicates in a fil
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    Post subject: Reply to: Appending Flag for record for duplicates in a fil
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    Post subject: Reply to: Appending Flag for record for duplicates in a fil
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    Post subject:
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    Post subject:
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    Post subject: Reply to: Appending Flag for record for duplicates in a fil
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

Site Director


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

PostPosted: Fri May 29, 2009 8:27 pm    Post subject:
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: 2285
Location: @my desk

PostPosted: Mon Jun 01, 2009 4:49 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare yesterday's date to the one o... migusd SYNCSORT 7 Fri Sep 22, 2017 11:35 pm
No new posts Split 1 file into 10 output Files - S... Prasanth Kumar SYNCSORT 5 Sat Sep 16, 2017 12:02 am
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Skip file from delete pema_yozer All Other Mainframe Topics 3 Tue Aug 29, 2017 3:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us