Let’s say your input file has data that is delimited by PIPE or COMMA e.g. you have uploaded a CSV file to a mainframe or you extract database variable fields to a CSV or PIPE separated file. To open this file in a copybook or use it in the program it needs to be reformatted to a fixed-length file. This reformatting can be done by using PARSE with the BUILD parameter.
PARSE operand can be used with INREC, OUTREC, or OUTFIL to define rules that tell DFSORT how to extract the relevant data from each variable input field into a fixed parsed field
INPUT
N12345¦HMOMEDICAL¦P1234¦103¦ABCDE¦SAM DAVID¦CA¦20210101¦99991231¦A
N11133¦PPO¦A1200¦123¦ABCDE¦KIM DAVID¦CA¦20210101¦99991231¦T
N12399¦CALCARE¦P1001¦199¦ABC¦ANNA DAVID¦CA¦20210101¦99991231¦A
N00300¦DENTAL¦P1299¦999¦XYZ¦CHERYL CHRIS¦CA¦20210101¦99991231¦A
//STEP01 EXEC PGM=SORT
//SORTIN DD DISP=SHR,DSN=I/P File
//SORTOUT DD DSN=O/P File,
// DISP=(NEW,CATLG,DELETE),
// UNIT=TESTDA,SPACE=(TRK,(10,10),RLSE)
// DCB=(LRECL=80,BLKSIZE=0,RECFM=FB,DSORG=PS)
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SORTWK01 DD SPACE=(CYL,20),UNIT=SYSDA
//SORTWK02 DD SPACE=(CYL,20),UNIT=SYSDA
//SORTWK03 DD SPACE=(CYL,20),UNIT=SYSDA
//SYSIN DD *
SORT FIELDS=COPY
OUTREC PARSE=(%01=(ENDBEFR=C'¦',FIXLEN=5),
%02=(ENDBEFR=C'¦',FIXLEN=10),
%03=(ENDBEFR=C’¦’,FIXLEN=05),
%04=(ENDBEFR=C’¦',FIXLEN=03),
%=(ENDBEFR=C’¦’),
………
………
………
%10=(ENDBEFR=C'¦',FIXLEN=1)),
BUILD=(%01,%02,%03,…,%10)
/*
OUTPUT
N12345HMOMEDICALP1234103SAM DAVID CA 20210101 99991231 A
N11133PPO A1200123KIM DAVID CA 20210101 99991231 T
N12399CALCARE P1001199ANNA DAVID CA 20210101 99991231 A
N00300DENTAL P1299999CHERYL CHRIS. CA 20210101 99991231 A
The %01 parsed field is used to extract the first variable field into a 5-byte fixed parsed field. ENDBEFR=C’¦’ tells DFSORT to stop extracting data at the byte before the next comma (the comma after the first variable field). FIXLEN=5 tells DFSORT that the %01 parsed field is 5 bytes long.
The % parsed field is used to skip the variable field without extracting anything for it.
BUILD operand is used to construct the output record.
Below are the parameters in PARSE for extracting variable position/length data to %nn fixed parsed fields, where nn can be 00 to 99: Each %nn parsed field must be defined only once. FIXLEN=m: Specifies the length (m) of the fixed area to contain the extracted variable data for this %nn fixed parsed field.
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…
The Professional Agile Leadership - Evidence-Based Management (PAL-EBM) certification offered by Scrum.org is designed for…
The Professional Agile Leadership (PAL I) certification, offered by Scrum.org, is designed to equip leaders…
Choosing the right Scrum Master Certification depends on your current experience and career goals. If…