PARSE with STARTAFT gives unexpected results !!



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

PARSE with STARTAFT gives unexpected results !!

Postby ranga_subham » Wed Jul 25, 2012 2:05 pm

Hi,

I am trying to learn PARSE with SORT and ran below SORT but don't get expected results if I use STARTAFT but get it upon using ENDBEFR !!

//JS001    EXEC PGM=SORT                     
//SYSOUT   DD SYSOUT=*                       
//SORTIN   DD *                               
ABC123.ABVP.SCHOOL.INT                       
ABVP.ABC234.INT.KANNAN                       
RAJI.SHIVAM.INT.ABC345                       
FAPI.MATRIX.ABC456.INT                       
VISU.POTLUX.ABC567.INT                       
JNKY.ABC678.ARJUNS.INT                       
//SORTOUT  DD SYSOUT=*                       
//SYSIN    DD *                               
  SORT FIELDS=COPY                           
  INREC PARSE=(%00=(FIXLEN=6),               
               %01=(STARTAFT=C'.',FIXLEN=6), 
               %02=(STARTAFT=C'.',FIXLEN=6), 
               %03=(STARTAFT=C'.',FIXLEN=6)),
  BUILD=(1:%00,11:%01,21:%02,31:%03)   
/*
//*     


Results:
ABC123    ABVP.S    INT
ABVP.A    INT.KA       
RAJI.S    INT.AB       
FAPI.M    ABC456    INT
VISU.P    ABC567    INT
JNKY.A    ARJUNS    INT


Expected Results:
ABC123    ABVP      SCHOOL    INT   
ABVP      ABC234    INT       KANNAN
RAJI      SHIVAM    INT       ABC345
FAPI      MATRIX    ABC456    INT   
VISU      POTLUX    ABC567    INT   
JNKY      ABC678    ARJUNS    INT   


Can you please let me know where I am going wrong and why?

Thanks.
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

Re: PARSE with STARTAFT gives unexpected results !!

Postby bodatrinadh » Wed Jul 25, 2012 3:55 pm

Hi Ranga,

Here is the detail explaination abt STARTAFT and ENDBEFR...

STARTAFT=string Optionally specifies a string, which indicates the start of the
parsed extraction of the variable field one byte after the string
(for example, a comma). The start position of the cursor for the
next parsed field is then set at the byte after the string. If the
string is not present, then blank characters will be inserted into
the current parsed field and all subsequent parsed fields.

You can specify the string as a character string constant
(C'string') or hexadecimal string constant (X'hh...hh'). For
example, a comma would be specified as STARTAFT=C','.

You can specify multiple instances and combinations of any
STARTAFT and STARTAT subparameter for a single %pp
parsed field. For example, PARSE=(%01=(STARTAFT=C'/',
STARTAFT=C'<',STARTAT=C'*',FIXLEN=5)). From left to
right, the first STARTAFT or STARTAT criterion to be satisfied
will be the one to be implemented.

ENDBEFR=string Optionally specifies a string, which indicates the end of the
parsed extraction of the variable field one byte before the string
(for example, a comma). The start position of the cursor for the
next parsed field is then set at the byte after the string.


If the string is not present, then data from the field will
continue to be extracted up until the end of the record. Blank
characters will be inserted into all subsequent parsed fields.

You can specify the string as a character string constant
(C'string') or hexadecimal string constant (X'hh...hh'). For
example, a comma would be specified as ENDBEFR=C','.

You can specify multiple instances and combinations of any
ENDBEFR and ENDAT subparameter for a single %pp parsed
field. For example, PARSE=(%01=(ENDBEFR=C'/',
ENDBEFR=C'<',ENDAT=C'*',FIXLEN=5)). From left to right,
the first ENDBEFR or ENDAT criterion to be satisfied will be
the one to be implemented.
Last edited by bodatrinadh on Wed Jul 25, 2012 4:01 pm, edited 1 time in total.
Thanks
-3nadh
User avatar
bodatrinadh
 
Posts: 67
Joined: Thu Jan 12, 2012 9:05 pm
Has thanked: 0 time
Been thanked: 4 times

Re: PARSE with STARTAFT gives unexpected results !!

Postby ranga_subham » Wed Jul 25, 2012 3:58 pm

3nath, I got the results with your code. But, why using of STARTAFT was not giving similar results? Whats wrong in it?

Thanks.
ranga_subham
 
Posts: 279
Joined: Fri Jul 18, 2008 7:46 pm
Has thanked: 0 time
Been thanked: 1 time

Re: PARSE with STARTAFT gives unexpected results !!

Postby BillyBoyo » Wed Jul 25, 2012 4:27 pm

You take %00 as being six bytes. In some cases that is "eating" your first ".".

Similarly, even having started after a "." you still have a length which is sometimes eating another "." because you specify no "end".

Read the documentation (some is even provide by 3nath) and experiment until you fully understand the options of PARSE. Then you will be able to answer your own question.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post