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

SYNCSORT- Record should be picked by a condition


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

New User


Joined: 22 Sep 2008
Posts: 49
Location: Chennai,Tamilnadu

PostPosted: Sat Nov 01, 2008 12:19 pm
Reply with quote

I have a requirement

In my input file:

I need to get records based a condition such

1) a record should be picked by a condition (5-9 characters should be 'PLUS') and written to output file

2) The immediate subsequent record should also be written to output file(without any condition)

Any solution to this requirement?
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Nov 04, 2008 3:41 am
Reply with quote

lokeshwar,

Is 'PLUS' included in the first record of the file? If so, assuming the input file is FB/80, you can code the following:
Code:
//SYSIN DD *
  SORT FIELDS=COPY                             
  OUTREC OVERLAY=(81:SEQNUM,8,ZD,RESTART=(5,4))
  OUTFIL INCLUDE=(81,8,ZD,EQ,1),BUILD=(1,80)   
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 04, 2008 9:32 am
Reply with quote

lokeshwar,

It would be better if you post some sample input/output records.
Back to top
View user's profile Send private message
lokeshwar_manoharan

New User


Joined: 22 Sep 2008
Posts: 49
Location: Chennai,Tamilnadu

PostPosted: Tue Nov 04, 2008 2:16 pm
Reply with quote

Input

Code:

     PLUS STUDENT SSN   000-09-6843       
 11111111 F EFF 032408-000000 AGD 0531
     PLUS STUDENT SSN   000-09-6842       
 22222222 F EFF 032408-000000 AGD 0531
 32222222 F EFF 032408-000000 AGD 0531
 42222222 F EFF 032408-000000 AGD 0531
     PLUS STUDENT SSN   000-09-6842   
 52222222 F EFF 032408-000000 AGD 0531
 


Output should be

Code:

    PLUS STUDENT SSN   000-09-6843       
 11111111 F EFF 032408-000000 AGD 0531
    PLUS STUDENT SSN   000-09-6842       
 22222222 F EFF 032408-000000 AGD 0531
    PLUS STUDENT SSN   000-09-6842   
 52222222 F EFF 032408-000000 AGD 0531



ie whenever a record has PLUS in 5th position should be written and also the immediate record should also be written to output file
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 04, 2008 3:42 pm
Reply with quote

lokeshwar,

Try this SYNCTOOL job.

Code:


//STEP01  EXEC PGM=SYNCTOOL                               
//TOOLMSG   DD SYSOUT=*                                   
//DFSMSG    DD SYSOUT=*                                   
//IN        DD DSN= Input file ---- FB,LRECL=80           
//T1        DD DSN=&&T1,DISP=(,PASS)                     
//OUT       DD SYSOUT=*                                   
//TOOLIN    DD *                                         
  COPY   FROM(IN) TO(T1) USING(CTL1)                     
  SELECT FROM(T1) TO(OUT) ON(81,8,CH) ALLDUPS USING(CTL2)
//CTL1CNTL  DD *                                         
   INREC IFTHEN=(WHEN=INIT,                               
                 OVERLAY=(81:SEQNUM,8,ZD)),               
         IFTHEN=(WHEN=(5,4,CH,EQ,C'PLUS'),               
                 OVERLAY=(81:81,8,ZD,ADD,+1,M11,LENGTH=8))
//CTL2CNTL  DD *                                         
   OUTFIL BUILD=(1,80)                                   
/*     

OUT
Code:
    PLUS STUDENT SSN   000-09-6843   
11111111 F EFF 032408-000000 AGD 0531
    PLUS STUDENT SSN   000-09-6842   
22222222 F EFF 032408-000000 AGD 0531
    PLUS STUDENT SSN   000-09-6842   
52222222 F EFF 032408-000000 AGD 0531
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Nov 04, 2008 9:41 pm
Reply with quote

lokeshwar,

While Arun's SYNCTOOL application will work, it passes the data twice. The SORT step that I previously provided will only pass the data once. If your input is small, then the performance difference is negligible. However, if you have a significant amount of data, then this may be an issue.
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Tue Nov 04, 2008 11:21 pm
Reply with quote

Alissa,

The syncsort job provided by you works perfectly for the sample input given above; but I believe it may not give the desired results when the input looks like the one below. I can't test this as I m out of office now icon_sad.gif Corrections are welcome.
Code:
 ----+----+----+----+----+----+----+--
     PLUS STUDENT SSN   000-09-6843 
 11111111 F EFF 032408-000000 AGD 0531
     PLUS STUDENT SSN   000-09-6842 
 22222222 F EFF 032408-000000 AGD 0531
 32222222 F EFF 032408-000000 AGD 0531
 42222222 F EFF 032408-000000 AGD 0531
     PLUS STUDENT SSN   000-09-6842   
 52222222 F EFF 032408-000000 AGD 0531
 52222223 F EFF 032408-000000 AGD 0531
 52222224 F EFF 032408-000000 AGD 0531
 52222225 F EFF 032408-000000 AGD 0531
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Tue Nov 04, 2008 11:38 pm
Reply with quote

Arun,

That is correct. I only gave a solution for what the OP specifically asked for, based on the sample input records. My solution will not work with your sample data. For your example, you can code the following:
Code:
//SYSIN DD *                                                 
  INREC IFTHEN=(WHEN=(5,4,CH,EQ,C'PLUS'),OVERLAY=(81:C'1')), 
        IFTHEN=(WHEN=NONE,OVERLAY=(81:C'2'))               
  SORT FIELDS=COPY                                           
  OUTREC OVERLAY=(82:SEQNUM,8,ZD,RESTART=(81,1))             
  OUTFIL INCLUDE=(82,8,ZD,EQ,1),BUILD=(1,80)                 
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Nov 05, 2008 1:23 am
Reply with quote

This application will address all 3 scenarios using SyncSort:
Code:
//SYSIN DD *                                                   
  INREC IFTHEN=(WHEN=(INIT),OVERLAY=(81:SEQNUM,8,ZD)),         
        IFTHEN=(WHEN=(5,4,CH,EQ,C'PLUS'),OVERLAY=(89:C'1')),   
        IFTHEN=(WHEN=NONE,OVERLAY=(89:C'2'))                   
  SORT FIELDS=COPY                                             
  OUTREC OVERLAY=(90:SEQNUM,8,ZD,RESTART=(89,1))               
  OUTFIL OMIT=((89,1,ZD,EQ,2,AND,81,8,ZD,EQ,1),OR,             
     (90,8,ZD,NE,1)),BUILD=(1,80)                         
Back to top
View user's profile Send private message
lokeshwar_manoharan

New User


Joined: 22 Sep 2008
Posts: 49
Location: Chennai,Tamilnadu

PostPosted: Thu Nov 06, 2008 10:08 pm
Reply with quote

Thanks man its working. But I can't get what this is doing. Can u please tell in brief?



Code:

//CTL1CNTL  DD *                                         
   INREC IFTHEN=(WHEN=INIT,                               
                 OVERLAY=(81:SEQNUM,8,ZD)),               
         IFTHEN=(WHEN=(5,4,CH,EQ,C'PLUS'),               
                 OVERLAY=(81:81,8,ZD,ADD,+1,M11,LENGTH=8))
Back to top
View user's profile Send private message
Arun Raj

Moderator


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

PostPosted: Thu Nov 06, 2008 11:53 pm
Reply with quote

lokeshwar,

The first IFTHEN inserts an 8 digit sequence number 1,2,3.... at 81st position. The second IFTHEN increments the sequence number by 1 wherever it encounters a 'PLUS' at 5th pos. For your sample input the temporary dataset T1 will have something like this.
Code:
 ----+----+----+----+----+----+----+--     pos-81
     PLUS STUDENT SSN   000-09-6843        00000002
 11111111 F EFF 032408-000000 AGD 0531     00000002
     PLUS STUDENT SSN   000-09-6842        00000004
 22222222 F EFF 032408-000000 AGD 0531     00000004
 32222222 F EFF 032408-000000 AGD 0531     00000005
 42222222 F EFF 032408-000000 AGD 0531     00000006
     PLUS STUDENT SSN   000-09-6842        00000008
 52222222 F EFF 032408-000000 AGD 0531     00000008

From T1, the SELECT operator copies only those records which have duplicate entries at 81st pos which is exactly what you need. The final BUILD discards the sequence numbers which we dont need any more.
Back to top
View user's profile Send private message
lokeshwar_manoharan

New User


Joined: 22 Sep 2008
Posts: 49
Location: Chennai,Tamilnadu

PostPosted: Fri Nov 07, 2008 7:18 pm
Reply with quote

Thanks a lot..!!

Lokesh
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top