Filling in records instead of spaces!!!



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Filling in records instead of spaces!!!

Postby ibmmf4u » Wed Jul 25, 2012 11:45 pm

Hi Everyone,

My requirement goes this way. I would like to fill in the spaces with the records present with in a file. Below mentioned is an example of the same.

Input file:-
00001234        ERROR1                TYPE OF ERROR
00001234                              ERROR ABOUT
00001234                              TYPE2
                                      ERROR FIELD
00001234                              ERROR DESCRIPTION
00001234                              DESC ENDED
00004567        ERROR2                TYPE OF ERROR
00004567                              ERROR NAME
                                      TYPE3
00004567                              DESC ENDED   


The first 8 positions are of key fields. If there were spaces in the first 8 positions then we need to compare the key fields of before and next lines where the space exists and if they are same then we need to replace those spaces with the key fields. In the above input file the keyfields which were present above and below the spaces (which mean whose first 8 positions are spaces) are of same and the spaces should be replaced by the key field as shown in the below output file.

Output file:-
00001234        ERROR1                TYPE OF ERROR
00001234                              ERROR ABOUT
00001234                              TYPE2
00001234                              ERROR FIELD
00001234                              ERROR DESCRIPTION
00001234                              DESC ENDED
00004567        ERROR2                TYPE OF ERROR
00004567                              ERROR NAME
00004567                              TYPE3
00004567                              DESC ENDED


Can someone please provide me the sort card in achieving the same.

Thanks in advance!!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Filling in records instead of spaces!!!

Postby dick scherrer » Thu Jul 26, 2012 1:38 am

Hello,

You mention looking at the before and after records to determine how to fill the spaces in the key.

What should happen if the keys on either side of the spaces are not equal?
00004567        ERROR2                TYPE OF ERROR
00004567                              ERROR NAME
                                      TYPE3
00008798                              DESC ENDED   
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Filling in records instead of spaces!!!

Postby BillyBoyo » Thu Jul 26, 2012 6:01 am

And are consecutive records with blank keys possible?

Without consecutives:

On OUTFIL

With no KEYBEGIN on WHEN=GROUP, you can use a sequence number with RESTART for the key, then WHEN=GROUP with BEGIN = sequence = 1. Push the key.

WHEN=GROUP begin = key = blank, Push the pushed key and the entire record with blank.

WHEN=(logexp, pushed record key is blank, check pushed pushed key to current key. If equal, BUILD two output records using / (slash operator).

I have no Syncsort, so can't try it out. Try it in parts, to check it is working out before doing the whole thing.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Filling in records instead of spaces!!!

Postby ibmmf4u » Thu Jul 26, 2012 5:49 pm

Hi Bill,

Thanks a lot . I tried coding per your instructions but got stuck.I initially went with when=group option and then to generate a seq-number but it gave me a syntax error. I later tried with when=init option coded as below .( I didn't went through that part of log exp where the last statement you specified.). I got bit confused and not sure if i had followed your instructions correctly. Please help me with some sort of example if i did go wrong.

Pasted below is the piece of code:-

//STEP010  EXEC   PGM=SORT                                             
//SYSOUT   DD     SYSOUT=*                                             
//SYSPRINT DD     SYSOUT=*                                             
//SORTOUT  DD     SYSOUT=*                                             
//SORTIN   DD     *                                                   
00001234        ERROR1                TYPE OF ERROR                   
00001234                              ERROR ABOUT                     
00001234                              TYPE2                           
                                      ERROR FIELD                     
00001234                              ERROR DESCRIPTION               
00001234                              DESC ENDED                       
00004567        ERROR2                TYPE OF ERROR                   
00004567                              ERROR NAME                       
                                      TYPE3                           
00004567                              DESC ENDED                       
//SYSIN    DD     *                                                   
  SORT FIELDS=COPY                                                     
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,60,SEQNUM,8,ZD,RESTART=(1,8))),   
       IFTHEN=(WHEN=GROUP,BEGIN=(61,8,CH,EQ,C'00000001'),PUSH=(1:1,8)),
         IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C' '),PUSH=(1:1,60))     
/*                                                                     


Output which i got:-
00001234        ERROR1                TYPE OF ERROR         00000001 
00001234                              ERROR ABOUT           00000002 
00001234                              TYPE2                 00000003 
                                      ERROR FIELD           00000001 
                                      ERROR FIELD           00000001 
                                      ERROR FIELD           00000002 
                                      ERROR FIELD           00000001 
                                      ERROR FIELD           00000002 
                                      TYPE3                 00000001 
                                      TYPE3                 00000001 


Kindly request you to provide me some sort of pseudo code and guide me in achieving the same!!!

Thanks in advance!!!

Hi Dick,

If the keys on either side of the spaces are not equal then we are just leaving it there as the blank spaces.

Thanks!!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Filling in records instead of spaces!!!

Postby BillyBoyo » Thu Jul 26, 2012 7:44 pm

I suggest you "break it down". Do the sequence number addition first. Just that. SORTOUT to SYSOUT and look at what is produced.

Now, bear in mind that you are PUSHing over the original data. In this particular case, because we need multiple copies of the key for the comparison, that won't work. Also, when you PUSH the whole data line over itself, that also won't work, as we need the "original" line with the blank key to write out and the line after it.

So, after the sequence number, change your WHEN=GROUP to PUSH after the current end of the record (after the sequence number). Run that. Look at and understand.

Then do the PUSH of the blank key-line and the already PUSHed key.

Then when you are happy with all that, you have to identify when you know you want to replace the space key. You check the key which has been pushed twice, against the key on the current record, and put that value in the blank on the PUSHED whole record.

Then you'll need to output two lines. We'll get to that once you've got this far. This is not trivial, so it is worth spending the time on to fully understand it, and how it may help you to develop solutions in the future.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Filling in records instead of spaces!!!

Postby Alissa Margulies » Fri Jul 27, 2012 1:02 am

Hello IBMMF4U,

Here is a Syncsort solution that should produce the desired output:
//SORT1 EXEC PGM=SORT                                               
//SORTIN  DD *                                                     
00001234        ERROR1                TYPE OF ERROR                 
00001234                              ERROR ABOUT                   
00001234                              TYPE2                         
                                      ERROR FIELD                   
00001234                              ERROR DESCRIPTION             
00001234                              DESC ENDED                   
00004567        ERROR2                TYPE OF ERROR                 
00004567                              ERROR NAME                   
                                      TYPE3                         
00004567                              DESC ENDED                   
//SORTOUT DD SYSOUT=*                                               
//SYSOUT  DD SYSOUT=*                                               
//SYSIN   DD *                                                     
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(17,5,CH,EQ,C'ERROR'),PUSH=(1:1,8))
  SORT FIELDS=COPY                                                 
/*                                                                 

Please let us know if you continue to encounter difficulties.
Alissa Margulies
Syncsort Mainframe Product Services
201-930-8260
zos_tech@syncsort.com
Alissa Margulies
Global moderator
 
Posts: 369
Joined: Tue Feb 26, 2008 11:15 pm
Location: USA
Has thanked: 1 time
Been thanked: 3 times

Re: Filling in records instead of spaces!!!

Postby ibmmf4u » Fri Jul 27, 2012 11:51 pm

Hi Bill,

Thanks a lot. I went per your instructions and coded it stepwise and pasting here the output of each and every step which i did.But i got bit confused while
Then do the PUSH of the blank key-line and the already PUSHed key.
.I got stuck over there from which position do we need to PUSH am sorry for troubling you a lot but nothing is coming. Please Kindly help me.

Pasted below are the code and its output at each step mentioned by you.

I suggest you "break it down". Do the sequence number addition first. Just that. SORTOUT to SYSOUT and look at what is produced.


Source Code:-
//STEP010  EXEC   PGM=SORT                                       
//SYSOUT   DD     SYSOUT=*                                       
//SYSPRINT DD     SYSOUT=*                                       
//SORTOUT  DD     SYSOUT=*                                       
//SORTIN   DD     *                                               
00001234        ERROR1                TYPE OF ERROR               
00001234                              ERROR ABOUT                 
00001234                              TYPE2                       
                                      ERROR FIELD                 
00001234                              ERROR DESCRIPTION           
00001234                              DESC ENDED                 
00004567        ERROR2                TYPE OF ERROR               
00004567                              ERROR NAME                 
                                      TYPE3                       
00004567                              DESC ENDED                 
//SYSIN    DD     *                                               
  SORT FIELDS=COPY                                               
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,60,SEQNUM,8,ZD,RESTART=(1,8)))
/*                                                               


Output:-

00001234        ERROR1                TYPE OF ERROR         00000001
00001234                              ERROR ABOUT           00000002
00001234                              TYPE2                 00000003
                                      ERROR FIELD           00000001
00001234                              ERROR DESCRIPTION     00000001
00001234                              DESC ENDED            00000002
00004567        ERROR2                TYPE OF ERROR         00000001
00004567                              ERROR NAME            00000002
                                      TYPE3                 00000001
00004567                              DESC ENDED            00000001


So, after the sequence number, change your WHEN=GROUP to PUSH after the current end of the record (after the sequence number). Run that. Look at and understand.


Source code:-

//STEP010  EXEC   PGM=SORT                                             
//SYSOUT   DD     SYSOUT=*                                             
//SYSPRINT DD     SYSOUT=*                                             
//SORTOUT  DD     SYSOUT=*                                             
//SORTIN   DD     *                                                   
00001234        ERROR1                TYPE OF ERROR                   
00001234                              ERROR ABOUT                     
00001234                              TYPE2                           
                                      ERROR FIELD                     
00001234                              ERROR DESCRIPTION               
00001234                              DESC ENDED                       
00004567        ERROR2                TYPE OF ERROR                   
00004567                              ERROR NAME                       
                                      TYPE3                           
00004567                              DESC ENDED                       
//SYSIN    DD     *                                                   
  SORT FIELDS=COPY                                                     
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,60,SEQNUM,8,ZD,RESTART=(1,8))),   
       IFTHEN=(WHEN=GROUP,BEGIN=(61,8,CH,EQ,C'00000001'),PUSH=(71:1,8))
/*


Output:-

00001234        ERROR1                TYPE OF ERROR         00000001  00001234
00001234                              ERROR ABOUT           00000002  00001234
00001234                              TYPE2                 00000003  00001234
                                      ERROR FIELD           00000001           
00001234                              ERROR DESCRIPTION     00000001  00001234
00001234                              DESC ENDED            00000002  00001234
00004567        ERROR2                TYPE OF ERROR         00000001  00004567
00004567                              ERROR NAME            00000002  00004567
                                      TYPE3                 00000001           
00004567                              DESC ENDED            00000001  00004567


Then do the PUSH of the blank key-line and the already PUSHed key.

Then when you are happy with all that, you have to identify when you know you want to replace the space key. You check the key which has been pushed twice, against the key on the current record, and put that value in the blank on the PUSHED whole record.


Source code:-
//STEP010  EXEC   PGM=SORT                                             
//SYSOUT   DD     SYSOUT=*                                             
//SYSPRINT DD     SYSOUT=*                                             
//SORTOUT  DD     SYSOUT=*                                             
//SORTIN   DD     *                                                   
00001234        ERROR1                TYPE OF ERROR                   
00001234                              ERROR ABOUT                     
00001234                              TYPE2                           
                                      ERROR FIELD                     
00001234                              ERROR DESCRIPTION               
00001234                              DESC ENDED                       
00004567        ERROR2                TYPE OF ERROR                   
00004567                              ERROR NAME                       
                                      TYPE3                           
00004567                              DESC ENDED                       
//SYSIN    DD     *                                                   
  SORT FIELDS=COPY                                                     
  OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,60,SEQNUM,8,ZD,RESTART=(1,8))),   
     IFTHEN=(WHEN=GROUP,BEGIN=(61,8,CH,EQ,C'00000001'),PUSH=(71:1,8)),


Output:-
00001234        ERROR1                TYPE OF ERROR         00000001  00001234                                                                                                                     
00001234                              ERROR ABOUT           00000002  00001234                                                           
00001234                              TYPE2                 00000003  00001234                                                           
                                      ERROR FIELD           00000001                                                 ERROR FIELD
00001234                              ERROR DESCRIPTION     00000001                                                 ERROR FIELD
00001234                              DESC ENDED            00000002                                                 ERROR FIELD
00004567        ERROR2                TYPE OF ERROR         00000001                                                 ERROR FIELD
00004567                              ERROR NAME            00000002                                                 ERROR FIELD
                                      TYPE3                 00000001                                                 TYPE3
00004567                              DESC ENDED            00000001                                                 TYPE3



The above output which you look went out to the next line as the code tag accepts 80bytes


I am not sure if I have misunderstood completely . Please Kindly me help me out !!!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Filling in records instead of spaces!!!

Postby ibmmf4u » Fri Jul 27, 2012 11:59 pm

Hi Alissa,

The code which you have given is working fine but the input file doesn't contains ERROR from 17 till 21 potions it may keep on varying by the time.

Below mentioned is an sample input file .

Input file:-

00001234        ERROR1                TYPE OF ERROR       
00001234                              ERROR ABOUT         
00001234                              TYPE2               
                                      ERROR FIELD         
00001234                              ERROR DESCRIPTION   
00001234                              DESC ENDED           
00004567        TYPEN2                TYPE OF ERROR       
00004567                              ERROR NAME           
                                      TYPE3               
00004567                              DESC ENDED           
00006789        TESTMSGNUMBER3        ERROR DESCRIPTION   
                                      DESC OF TEST MESSAGE
00006789                              TYPE OF ERROR MESSAGE
00006789                              TESTNUMBER           


Output file:-
00001234        ERROR1                TYPE OF ERROR       
00001234                              ERROR ABOUT         
00001234                              TYPE2               
00001234                              ERROR FIELD         
00001234                              ERROR DESCRIPTION   
00001234                              DESC ENDED           
00004567        TYPEN2                TYPE OF ERROR       
00004567                              ERROR NAME           
00004567                              TYPE3               
00004567                              DESC ENDED           
00006789        TESTMSGNUMBER3        ERROR DESCRIPTION   
00006789                              DESC OF TEST MESSAGE
00006789                              TYPE OF ERROR MESSAGE
00006789                              TESTNUMBER           


Kindly help me out!!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Re: Filling in records instead of spaces!!!

Postby BillyBoyo » Sat Jul 28, 2012 12:07 am

You still need an example where you have KEY1, blanks, KEY2, as you have said that can exit.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Filling in records instead of spaces!!!

Postby ibmmf4u » Sat Jul 28, 2012 6:45 pm

Yes Bill. My apologies i forgot to mention the third control card which lead to the output specified in 3rd scenario. Below mentioned is the control statement which i used to get the output.

Then do the PUSH of the blank key-line and the already PUSHed key.

Then when you are happy with all that, you have to identify when you know you want to replace the space key. You check the key which has been pushed twice, against the key on the current record, and put that value in the blank on the PUSHED whole record.


Control card:-
IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C' '),PUSH=(71:71,8,80:1,60))


Entire code till the third scenario:-
SORT FIELDS=COPY                                                   
OUTFIL IFTHEN=(WHEN=INIT,BUILD=(1,60,SEQNUM,8,ZD,RESTART=(1,8))),   
   IFTHEN=(WHEN=GROUP,BEGIN=(61,8,CH,EQ,C'00000001'),PUSH=(71:1,8)),
   IFTHEN=(WHEN=GROUP,BEGIN=(1,8,CH,EQ,C' '),PUSH=(71:71,8,80:1,60))


I am not pretty much sure that if i had intrepreted your third statement exactly .(As when and where to push to entire blanked-line and pushed key , i mean the positions.)

Yes Bill some sort of example may help me in kindly going through the last scenario specified.

Please kindly help me out!!!!
ibmmf4u
 
Posts: 65
Joined: Wed Dec 14, 2011 10:26 pm
Has thanked: 0 time
Been thanked: 1 time

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post