IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

parsing with startat and endbefr


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Wed May 04, 2022 7:55 pm
Reply with quote

hello,
I am having trouble with parse and unable to find what is wrong.
I have several records starting with '#', variable length and ending with blanks.
so I thought parsing the lines would work fine.
Except that I am not able to see what is the issue in the following:
Code:
INREC PARSE=(%1=(STARTAFT=BLANKS,FIXLEN=4),
                       %2=(STARTAT,C=#',ENDBEFR=C' '),
                                                     *
                       %3=(ENDBEFR=C' '')),
 BUILD=(%1,C' ',%2,C' ',%3)

Its rejecting the %2.
so what am I missing here?
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Wed May 04, 2022 8:01 pm
Reply with quote

sorry... this is the correct code/message

Code:
 SYSIN :                                                               
    INREC  PARSE=(%1=(STARTAFT=BLANKS,FIXLEN=4),                       +
                  %2=(STARTAT=C'#',ENDBEFR=BLANKS),                    +
                                                  *                     
                  %3=(ENDBEFR=C' ')),                                  +
    BUILD=(%1,C' ',%2,C' ',%3,C' ')                                     
[/code]
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1175
Location: Dublin, Ireland

PostPosted: Wed May 04, 2022 8:57 pm
Reply with quote

I think you should use %01 & %02 as indicated in the manual, not %1 & %2.

Garry.
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Wed May 04, 2022 10:47 pm
Reply with quote

thank you Garry
but it didn't make a difference .
Still getting the same error

Code:
SYSIN :                                                               
   INREC  PARSE=(%01=(STARTAFT=BLANKS,FIXLEN=4),                      +
                 %02=(STARTAT=C'#',ENDBEFR=C' '),                     +
                                                *                     
                 %03=(FIXLEN=5)),                                     +
   BUILD=(%01,C' ',%02,C' ',%03,C' ')                                 
 SORT FIELDS=(01,40,CH,A)                                             
WER813I  INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED         
WER268A  INREC STATEMENT   : SYNTAX ERROR


The following is a sample of the data in the input file:
LN3T.X33.BRTFILE L01P #BR85.ISX.CRB.wcrx.** 1043, 1301,
LN3T.X33.BRTFILE L01P #BR85.ISX.CRB.ctsx.** 1584 50

What I would like to get out of this sort is L01P as %01, #BR85.*.** as %02, and 1043, as %03.
The trouble is none of them start in the same position. %02 is variable length, and %03 could contain a comma.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1617

PostPosted: Wed May 04, 2022 11:29 pm
Reply with quote

Any syntax %1, and %01 is allowed.

The problem with %2 is, missing mandatory parameter FIXLEN=

Code:
SYSIN :                                                               
   INREC  PARSE=(%01=(STARTAFT=BLANKS,FIXLEN=4),                      +
                 %02=(STARTAT=C'#',ENDBEFR=C' '),                     +
                                                *                     
                 %03=(FIXLEN=5)),                                     +
   BUILD=(%01,C' ',%02,C' ',%03,C' ')                                 
 SORT FIELDS=(01,40,CH,A)                                             
WER813I  INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED         
WER268A  INREC STATEMENT   : SYNTAX ERROR
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Wed May 04, 2022 11:57 pm
Reply with quote

Indeed. that made the difference.

so, FIXLEN is for the output field?
in that case I got it wrong.
Thanks Sergeyken
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 911
Location: Bamberg, Germany

PostPosted: Thu May 05, 2022 9:51 am
Reply with quote

Sample:
Code:
OPTION COPY                                                     
INREC IFTHEN=(WHEN=INIT,                                         
  PARSE=(%01=(STARTAFT=BLANKS,ENDBEFR=BLANKS,FIXLEN=4),         
         %02=(STARTAT=NONBLANK,ENDBEFR=BLANKS,FIXLEN=44),       
         %03=(STARTAT=NUM,ENDBEFR=C',',ENDBEFR=BLANKS,FIXLEN=8)),
  BUILD=(%01,C'|',%02,C'|',%03,C'|'))                           
END

Output:
Code:
****** **************************** Datenanfang ********************
000001 L01P|#BR85.ISX.CRB.wcrx.**                       |1043    | 
000002 L01P|#BR85.ISX.CRB.ctsx.**                       |1584    | 
****** **************************** Datenende **********************
Back to top
View user's profile Send private message
migusd

New User


Joined: 08 Aug 2014
Posts: 44
Location: USA

PostPosted: Thu May 05, 2022 7:02 pm
Reply with quote

thanks Joerg
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1617

PostPosted: Thu May 05, 2022 8:04 pm
Reply with quote

Code:
. . . . .
  BUILD=(%01,C'|',%02,C'|',%03,JFY=(SHIFT=RIGHT),C'|'))                           
. . . .


This is to align the numerics properly.
Back to top
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 911
Location: Bamberg, Germany

PostPosted: Fri May 06, 2022 12:36 am
Reply with quote

sergeyken wrote:
Code:
. . . . .
  BUILD=(%01,C'|',%02,C'|',%03,JFY=(SHIFT=RIGHT),C'|'))                           
. . . .


This is to align the numerics properly.

Just wanted to demonstrate how it could be coded. icon_wink.gif

To align properly, I would go with SFF or UFF.
Code:
BUILD=(%01,C'|',%02,C'|',%03,UFF,C'|'))
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 1617

PostPosted: Fri May 06, 2022 2:40 am
Reply with quote

UFF operates with numeric values only, while JFY works with any data.

If, by a chance, the parsed value is not fully numeric (such as ‘256MB’), then the result of conversion to UFF may be surprising… icon_lol.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts XML Parsing in COBOL creating "h... COBOL Programming 0
This topic is locked: you cannot edit posts or make replies. Parsing more than 1000 columns in a s... SYNCSORT 10
No new posts Parsing single liner XML into readabl... COBOL Programming 1
No new posts Need help in parsing record in VBA file DFSORT/ICETOOL 4
No new posts Unexpected token parsing JSON value u... PL/I & Assembler 3
Search our Forums:

Back to Top