Massimo,
Your issue is not with PARSE but you wanting to perform a horizontal sort
based on the values. So here is a Job that would give you the desired
results. You need to parse the data and then validate the values and
arrange them accordingly.
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
*F00:FIELD00*F01:FIELD01*F02:FIELD02*
*F01:FIELD01*F00:FIELD00*F02:FIELD02*
*F02:FIELD02*F00:FIELD00*F01:FIELD01*
*F00:FIELD00*F02:FIELD02*
*F00:FIELD00*F02:FIELD02*F01:FIELD01*
*F02:FIELD02*F01:FIELD01*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC PARSE=(%01=(STARTAFT=C'*',
ENDBEFR=C':',
FIXLEN=3),
%02=(ENDBEFR=C'*',
FIXLEN=15),
%03=(ENDBEFR=C':',
FIXLEN=3),
%04=(ENDBEFR=C'*',
FIXLEN=15),
%05=(ENDBEFR=C':',
FIXLEN=3),
%06=(ENDBEFR=C'*',
FIXLEN=15)),
BUILD=(01:%01,C'=',%02,
21:%03,C'=',%04,
41:%05,C'=',%06)
*** RE-ARRANGE THE VALUES F00,F01,F02 VALUES ***
OUTREC IFTHEN=(WHEN=(01,3,CH,GE,21,3,CH),
BUILD=(01:21,20,21:01,20,41:41,20),HIT=NEXT),
IFTHEN=(WHEN=(21,3,CH,GE,41,3,CH),
BUILD=(01:01,20,21:41,20,41:21,20),HIT=NEXT),
IFTHEN=(WHEN=(01,3,CH,GE,21,3,CH),
BUILD=(01:21,20,21:01,20,41:41,20),HIT=NEXT),
*** CHECK FOR F00 AND F01 IF IT IS IN ITS RIGHT SLOT **
IFTHEN=(WHEN=(01,3,CH,EQ,C' ',AND,21,3,CH,EQ,C'F00'),
BUILD=(01:21,20,21:C'F01=',41:41,20),HIT=NEXT),
IFTHEN=(WHEN=(21,3,CH,EQ,C' ',AND,41,3,CH,EQ,C'F01'),
BUILD=(01:21,20,21:41,20,41:C'F02='),HIT=NEXT),
*** INIT F00 F01 F02 INIT VALUES FOR MISSING VALUES **
IFTHEN=(WHEN=(01,3,CH,EQ,C' '),
OVERLAY=(01:C'F00=',15X),HIT=NEXT),
IFTHEN=(WHEN=(21,3,CH,EQ,C' '),
OVERLAY=(21:C'F01=',15X),HIT=NEXT),
IFTHEN=(WHEN=(41,3,CH,EQ,C' '),
OVERLAY=(41:C'F02=',15X),HIT=NEXT)
//*
The output from this job is
F00=FIELD00 F01=FIELD01 F02=FIELD02
F00=FIELD00 F01=FIELD01 F02=FIELD02
F00=FIELD00 F01=FIELD01 F02=FIELD02
F00=FIELD00 F01= F02=FIELD02
F00=FIELD00 F01=FIELD01 F02=FIELD02
F00= F01=FIELD01 F02=FIELD02
Further if you have any questions please let me know
Thanks,
Sri Hari Kolusu
DFSORT Development
IBM Corporation
From: Massimo Biancucci <[email protected]>
To: [email protected]
Date: 05/27/2016 08:40 AM
Subject: Re: Sort PARSE, ABSPOS and SUBPOS. How to PARSE when one
or more fields are missed.
Sent by: IBM Mainframe Discussion List <[email protected]>
In my mind there was something "parse the record and find the fields".
So, starting from this input:
*F00:FIELD00*F01:FIELD01*F02:FIELD02*
*F01:FIELD01*F00:FIELD00*F02:FIELD02*
*F02:FIELD02*F00:FIELD00*F01:FIELD01*
*F00:FIELD00*F02:FIELD02*
*F00:FIELD00*F02:FIELD02*F01:FIELD01*
*F02:FIELD02*F01:FIELD01*
I'm expecting:
F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
F00=FIELD00 -F01= -F02=FIELD02 -
F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
F00= -F01=FIELD01 -F02=FIELD02 -
because at record n.4 F00 and F02 are present and at record n. 5 both F01
and F02 are present.
Hope it's clear now.
Thanks a lot.
Massimo
2016-05-27 17:30 GMT+02:00 Sri h Kolusu <[email protected]>:
> Massimo,
>
> It is not clear as to what you are trying to do. Can you please show us
> the desired output from the sample you have given? Also please tell us
> about the DCB properties of the input and output datasets.
>
> Thanks,
> Sri Hari Kolusu
> DFSORT Development
> IBM Corporation
>
>
>
> From: Massimo Biancucci <[email protected]>
> To: [email protected]
> Date: 05/27/2016 05:36 AM
> Subject: Sort PARSE, ABSPOS and SUBPOS. How to PARSE when one or
> more fields are missed.
> Sent by: IBM Mainframe Discussion List <[email protected]>
>
>
>
> Hi everybody,
>
> I'm trying to parse a variable record where some fields can and cannot
be
> present.
>
> It seems, after the first search failure (pointer hit the end of record)
> there's no chance to restart the parsing from the beginning.
>
> This is a test:
>
> //SORTIN DD *
> *F00:FIELD00*F01:FIELD01*F02:FIELD02*
> *F01:FIELD01*F00:FIELD00*F02:FIELD02*
> *F02:FIELD02*F00:FIELD00*F01:FIELD01*
> *F00:FIELD00*F02:FIELD02*
> *F00:FIELD00*F02:FIELD02*F01:FIELD01*
> *F02:FIELD02*F01:FIELD01*
> /*
> //SORTOUT DD SYSOUT=*
> //SYSIN DD *
> INREC PARSE=(%00=(STARTAFT=C'F00:',
> ENDBEFR=C'*',
> FIXLEN=15),
> %=(ABSPOS=1,FIXLEN=1),
> %01=(SUBPOS=1000,STARTAFT=C'F01:',
> ENDBEFR=C'*',
> FIXLEN=15),
> %=(ABSPOS=1,FIXLEN=1),
> %02=(STARTAFT=C'F02:',
> ENDBEFR=C'*',
> FIXLEN=15)),
> BUILD=(C'F00=',%00,C'-F01=',%01,C'-F02=',%02,C'-')
> SORT FIELDS=COPY
> /*
>
> The output is:
>
> F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
>
> F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
>
> F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
>
> F00=FIELD00 -F01= -F02= -
>
> F00=FIELD00 -F01=FIELD01 -F02=FIELD02 -
>
> F00= -F01= -F02= -
>
>
> I tried with:
>
> //SYSIN DD *
> INREC PARSE=(%00=(STARTAFT=C'F00:',
> ENDBEFR=C'*',
> FIXLEN=15),
> %01=(SUBPOS=1000,STARTAFT=C'F01:',
> ENDBEFR=C'*',
> FIXLEN=15),
> %02=(SUBPOS=1000,STARTAFT=C'F02:',
> ENDBEFR=C'*',
> FIXLEN=15)),
> BUILD=(C'F00=',%00,C'-F01=',%01,C'-F02=',%02,C'-')
> SORT FIELDS=COPY
> /*
>
> too with no difference.
>
> The behaviour is the same for DFSort and SyncSort.
>
> This does lead me to think I didn't fully understand the following
manual
> statement (from DFSort):
>
> "*ABSPOS=p*
> Sets the Start Pointer for this parsed field to p. p can be 1 to 32752.
By
> default, the Start Pointer for the first %nn parsed field is position 1
> for
> fixed-length records or position 5 for variable-length records, and the
> Start
> Pointer for each subsequent %nn parsed field is the Start Pointer set by
> the
> previous %nn field. You can use ABSPOS=p to set the Start Pointer to
> position p to override the default Start Pointer. If the resulting Start
> Pointer
> is less than position 5 for variable length records, it will be set to
> position
> 5."
>
> and
>
> " *SUBPOS=y*
> Decrements the Start Pointer for this parsed field by y. y can be 1 to
> 32752.
> By default, the Start Pointer for the first %nn parsed field is position
1
> for
> fixed-length records or position 5 for variable-length records, and the
> Start
> Pointer for each subsequent %nn parsed field is the Start Pointer set by
> the
> previous %nn field. You can use SUBPOS=y to decrement the Start Pointer
> by x to override the default Start Pointer. If the resulting Start
Pointer
> is
> less than position 1 for fixed-length records, it will be set to
position
> 1. If
> the resulting Start Pointer is less than position 5 for variable-length
> records, it will be set to position 5."
>
> Thanks a lot for your support.
> Massimo
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>
>
>
>
>
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN