MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vertical To Horizontal , Can it be possible by SyncSort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
DGM
Beginner


Joined: 21 Sep 2003
Posts: 12
Topics: 4

PostPosted: Wed Nov 16, 2005 2:29 am    Post subject: Vertical To Horizontal , Can it be possible by SyncSort Reply with quote

Hi
I want to create a Horizontal from Vertical Row. Key is PO and 9 Byte.

Code:

INPUT

PO(9 byte char)    Change_Description(15 byte desc)
123456789          add item
123456789          del item
123456789          price change
123456789          flatbed change

234567890          po cancel
234567890          po uncancel
234567890          add item
234567890          location change
234567890          Po cancel

345678901          vendor change
345678901          item uncancel

OUTPUT

123456789          add item,  del item, price change, flatbed change
234567890          po cancel, po uncancel, add item, location change, Po cancel
345678901          vendor change, item uncancel

NOTE:Maximum 10 unique changes can be done to a PO and Maximum of 15 changes can be done to same PO.
Back to top
View user's profile Send private message Send e-mail
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Wed Nov 16, 2005 5:18 am    Post subject: Reply with quote

DGM,

Using the traditional way of horizontal merging, the above requirements can be easily accomplished provided you have fixed number of records for a PO.

Code:

Maximum 10 unique changes can be done to a PO and Maximum of 15 changes can be done to same PO.


If the number varies from 1-10 unique entries & 1-15 rows for each unique entry, you need to have latest version of syncsort which supports SPLICE (ver 1.1 or 1.2).

Code a dummy sort job (PGM=SORT) and go to sysout and see what version of sort you have. The version is displayed in the first line of sysout.

Thanks,
Phantom
Back to top
View user's profile Send private message
DGM
Beginner


Joined: 21 Sep 2003
Posts: 12
Topics: 4

PostPosted: Wed Nov 16, 2005 8:14 am    Post subject: Reply with quote

Hi
I can use splice operator by SYNCTOOL. That works in my JCL. I have SYNCSORT 1.1 . But How can I get my desired output.

Thanks
DGM
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Nov 16, 2005 9:13 am    Post subject: Reply with quote

Quote:

Hi
I can use splice operator by SYNCTOOL. That works in my JCL. I have SYNCSORT 1.1 . But How can I get my desired output.


DGM,

It can be done but it would involve at least a minimum of 4 passes of the data. you need to assign seqnum to each record first and then re-format the record for splice to work.

try this easytrieve code

Code:

//INFILE   DD *                           
----+----1----+----2----+----3----+----4---
123456789 ADD ITEM                         
123456789 DEL ITEM                         
123456789 PRICE CHANGE                     
123456789 FLATBED CHANGE                   
234567890 PO CANCEL                       
234567890 PO UNCANCEL                     
234567890 ADD ITEM                         
234567890 LOCATION CHANGE                 
234567890 PO CANCEL                       
345678901 VENDOR CHANGE                   
345678901 ITEM UNCANCEL                   
//OUTFILE  DD SYSOUT=*,LRECL=235           
//SYSIN    DD *                           
                                           
FILE INFILE                               
     IN-KEY        01 09 A                 
     IN-DATA       11 15 A                 
                                           
FILE SORTFILE FB(25 0) VIRTUAL             
     SORT-KEY      01 10 A                 
     SORT-DATA     11 15 A                 
                                           
FILE OUTFILE FB(0 0)                                   
     OUT-KEY       01 009  A                           
     OUT-REC       11 225  A                           
     OUT-DATA      11 015  A OCCURS 15 INDEX ODX       
                                                       
PREVIOUS-KEY  W 09 A VALUE ' '                         
                                                       
SORT INFILE TO SORTFILE USING (IN-KEY)                 
                                                       
JOB INPUT SORTFILE  FINISH LAST-REC                   
                                                       
  ODX  = ODX + 1                                       
                                                       
  IF SORT-KEY EQ PREVIOUS-KEY                         
     IF ODX > 15                                       
        STOP                                           
        DISPLAY 'OCCURS OVER-FLOW'
        PERFORM IN-HOUSE-ABEND-ROUTINE                   
     END-IF                                           
     OUT-DATA(ODX) = SORT-DATA                         
  ELSE                                                 
     OUT-KEY  = PREVIOUS-KEY                           
     IF RECORD-COUNT > 1                               
        PUT OUTFILE                                   
     END-IF                                           
     OUT-REC       = ' '                               
     ODX           = 1                                 
     OUT-DATA(ODX) = SORT-DATA                         
     PREVIOUS-KEY  = SORT-KEY                         
  END-IF                                               
                                                       
LAST-REC. PROC                                         
  OUT-KEY  = PREVIOUS-KEY                             
  PUT OUTFILE                                         
END-PROC                                               
                                     


Hope this helps....

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Martin
Beginner


Joined: 20 Mar 2006
Posts: 133
Topics: 58

PostPosted: Tue May 12, 2009 11:25 am    Post subject: Reply with quote

Kolusu,


Could you please provide the SORT solution for this ?

Thanks,
Martin
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue May 12, 2009 11:53 am    Post subject: Reply with quote

Martin,

Solution for what? The original post is 3 and half years old. Moreover OP wanted a syncsort solution, I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Thu May 14, 2009 10:01 am    Post subject: Reply with quote

Martin,

Here are 2 examples related to what the OP was asking for. Please note, both examples require SyncSort for z/OS 1.2.1 or later.

EXAMPLE 1:
Code:

//SORT1 EXEC PGM=SORT,PARM='EQUALS'                         
//STEPLIB DD DSN=WCS.TS.SS12DN,UNIT=SYSDA,DISP=SHR 
//SORTIN  DD *                                       
KEY1 DATA1                                         
KEY1 DATA2                                         
KEY2 DATA3                                         
KEY2 DATA4                                         
KEY3 DATA5                                         
KEY3 DATA6                                         
KEY4 DATA7                                         
KEY4 DATA8                                         
//SORTOUT DD SYSOUT=*                           
//SYSOUT  DD SYSOUT=*                           
//SYSIN   DD *                                   
  INREC IFTHEN=(WHEN=INIT,                     
       OVERLAY=(81:SEQNUM,1,ZD,RESTART=(1,4))),
        IFTHEN=(WHEN=(81,1,ZD,EQ,1),           
         BUILD=(1:1,11,12:6Z)),                 
        IFTHEN=(WHEN=(81,1,ZD,EQ,2),           
         BUILD=(1:1,5,6:6Z,12:6,5,1Z))         
   SORT FIELDS=(1,4,CH,A)                       
   SUM FIELDS=(6,4,BI,10,4,BI,14,4,BI)         
/*


Output produced:
Code:
KEY1 DATA1 DATA2
KEY2 DATA3 DATA4
KEY3 DATA5 DATA6
KEY4 DATA7 DATA8


EXAMPLE 2:
Code:
//SORT2  EXEC PGM=SORT,PARM='EQUALS'           
//SORTIN   DD *                                   
AAA 1                                             
AAA 2                                             
AAA 3                                             
BBB 1                                             
BBB 3                                             
BBB 6                                             
//SORTOUT  DD SYSOUT=*                           
//SYSOUT   DD SYSOUT=*                           
//SYSIN    DD *                                   
 SORT FIELDS=(1,3,CH,A)                           
 OUTREC IFTHEN=(WHEN=INIT,                       
        OVERLAY=(81:SEQNUM,2,ZD,RESTART=(1,3))), 
        IFTHEN=(WHEN=(81,2,ZD,EQ,1),             
        BUILD=(1:1,3,4,2,18Z)),                   
        IFTHEN=(WHEN=(81,2,ZD,EQ,2),             
        BUILD=(1:1,3,2Z,4,2,16Z)),               
        IFTHEN=(WHEN=(81,2,ZD,EQ,3),     
        BUILD=(1:1,3,4Z,4,2,14Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,4),     
        BUILD=(1:1,3,6Z,4,2,12Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,5),     
        BUILD=(1:1,3,8Z,4,2,10Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,6),     
        BUILD=(1:1,3,10Z,4,2,8Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,7),     
        BUILD=(1:1,3,12Z,4,2,6Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,8),     
        BUILD=(1:1,3,14Z,4,2,4Z)),       
        IFTHEN=(WHEN=(81,2,ZD,EQ,9),     
        BUILD=(1:1,3,16Z,4,2,2Z)),       
        IFTHEN=(WHEN=(81,1,ZD,EQ,10),     
        BUILD=(1:1,3,18Z,4,2))           
   OUTFIL NODETAIL,REMOVECC,SECTIONS=(1,3, 
           TRAILER3=(1,3,                   
           TOT=(4,2,BI,BI,LENGTH=2),       
           TOT=(6,2,BI,BI,LENGTH=2),       
           TOT=(8,2,BI,BI,LENGTH=2),       
           TOT=(10,2,BI,BI,LENGTH=2),       
           TOT=(12,2,BI,BI,LENGTH=2),       
           TOT=(14,2,BI,BI,LENGTH=2),       
           TOT=(16,2,BI,BI,LENGTH=2),       
           TOT=(18,2,BI,BI,LENGTH=2),       
           TOT=(20,2,BI,BI,LENGTH=2),       
           TOT=(22,2,BI,BI,LENGTH=2)))     
   END                                     
  /*       

Output produced:
Code:
AAA 1 2 3
BBB 1 3 6

_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
computer
Beginner


Joined: 12 Jun 2007
Posts: 64
Topics: 17
Location: Hyderabad

PostPosted: Fri May 15, 2009 6:21 am    Post subject: Reply with quote

Hi Alissa,

Looking into the solutions, I have few questions in my mind:
1. Can you please explain me how exactly the duplicates records are coming as single record. Means The how the BUILD is happening in this case.
2. And what if the I don't know the possible number of duplicate records occurences.

Thanks in Advance,
Manoj
Back to top
View user's profile Send private message
amargulies
Beginner


Joined: 10 Jan 2007
Posts: 123
Topics: 0

PostPosted: Fri May 15, 2009 1:02 pm    Post subject: Reply with quote

Manoj,

The IFTHEN/BUILD statements are reformatting the records with embedded binary zeros at various positions dependant upon the SEQNUM value.

(In order to see exactly what is being done here, you can run the job without the OUTFIL statement.)

Once the records have been reformatted, the OUTFIL TRAILER3 will total or accumulate the data for each key into a single record. With NODETAIL specified, only these TRAILER records will be written out.

In order for this code to work, you need to know the maximum possible number of equally-keyed records.
_________________
Alissa Margulies
SyncSort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group