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
 

 

SYNCSORT- Record should be picked by a condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: SYNCSORT- Record should be picked by a condition
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: 500
Location: USA

PostPosted: Tue Nov 04, 2008 3:41 am    Post subject:
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: 2179
Location: @my desk

PostPosted: Tue Nov 04, 2008 9:32 am    Post subject:
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    Post subject:
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: 2179
Location: @my desk

PostPosted: Tue Nov 04, 2008 3:42 pm    Post subject:
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: 500
Location: USA

PostPosted: Tue Nov 04, 2008 9:41 pm    Post subject:
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: 2179
Location: @my desk

PostPosted: Tue Nov 04, 2008 11:21 pm    Post subject:
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: 500
Location: USA

PostPosted: Tue Nov 04, 2008 11:38 pm    Post subject:
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: 500
Location: USA

PostPosted: Wed Nov 05, 2008 1:23 am    Post subject:
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    Post subject:
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: 2179
Location: @my desk

PostPosted: Thu Nov 06, 2008 11:53 pm    Post subject:
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    Post subject:
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    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 Syncsort Help to group fields sudhakarraju SYNCSORT 6 Thu Dec 29, 2016 1:38 am
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 7 Fri Dec 02, 2016 9:47 am
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Syncsort - Hard coded Value in output PORYES SYNCSORT 1 Thu Nov 03, 2016 9:23 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


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