Tags

, , , , , , , , , ,

SORT – PARSE – READ EXCEL (CSV) FILE IN MAINFRAMES (REFORMAT VARIABLE FIELDS)

Sometimes you will have your input data as provided below, when you import from Excel (CSV) to Mainframes. To use this file in a COBOL program, you will need fields to be in a format. Each field will not start at a particular column. To reformat these records, you can make use of PARSE parameter.

RAJESH,M,111,AAAA

RAMS,M,22,BBB

SURESH,M,3333,CCCC

SUNIL,M,4,DDDDDDD

OUTPUT

RAJESH 111 AAAA

RAMS 22 BBB

SURESH 3333 CCCC

SUNIL 4 DDDDDDD

SORT CARD

OUTREC PARSE=(%01=(ENDBEFR=C’,’,FIXLEN=8),

%=(ENDBEFR=C’,’),

%03=(ENDBEFR=C’,’,FIXLEN=5),

%04=(FIXLEN=10)),

BUILD=(%01,X,%03,X,%04)

  1. The %01 parsed field is used to extract the first variable field into an 8-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=8 tells DFSORT that the %01 parsed field is 8 bytes long.
  1. The % parsed field is used to skip the second variable field without extracting anything for it
  1. The %03 parsed field is used to extract the third variable field into a 5-byte fixed parsed field. ENDBEFR=C’,’ tells DFSORT to stop extracting data before the next comma (the comma after the third variable field). FIXLEN=5 tells DFSORT that the %03 parsed field is 5 bytes long.
  1. The %04 parsed field is used to extract the fifth variable field into a 10-byte fixed parsed field. FIXLEN=10 tells DFSORT that the %04 parsed field is 10 bytes long.

PARSE Parameters

You can use the following parameters in PARSE to define the rules for extracting variable position/length data to %nn fixed parsed fields:

  1. FIXLEN=m: Specifies the length (m) of the fixed area to contain the extracted variable data for this %nn fixed parsed field.
  2. ABSPOS=p: Start extracting data at input position p.
  3. ADDPOS=x: Start extracting data at the current position + x.
  4. SUBPOS=y: Start extracting data at the current position – y.
  5. STARTAFT=string: Start extracting data at the byte after the end of the character or hexadecimal string.
  6. STARTAFT=BLANKS: Start extracting data after the end of the next group of blanks.
  7. STARTAT=string: Start extracting data at the first byte of the character or hexadecimal string.
  8. STARTAT=BLANKS: Start extracting data at the start of the first group of blanks.
  9. STARTAT=NONBLANK: Start extracting data at the next nonblank.
  10. ENDBEFR=string: Stop extracting data at the byte before the start of the character or hexadecimal string.
  11. ENDBEFR=BLANKS: Stop extracting data at the byte before the next group of blanks.
  12. ENDAT=string: Stop extracting data at the last byte of the character or hexadecimal string.
  13. ENDAT=BLANKS: Stop extracting data at the end of the next group of blanks.
  14. PAIR=APOST: Do not search for strings or blanks between apostrophe (‘) pairs.
  15. PAIR=QUOTE: Do not search for strings or blanks between quote (“) pairs

——————————————————————————————————–

In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog

——————————————————————————————————–

You may also like to look at:

Working on Mainframes – Is Change to a different technology necessary
Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
SAS – SAMPLE PROGRAM
SORT – CONVERT PD to ZD IN DISPLAYABLE FORMAT (ZDF)
SORT – Alphanumeric Tests for INCLUDE and OMIT
SORT – EQUALS Option
SORT – PARSE – REFORMAT VARIABLE FIELDS
SORT – FINDREP, IFTHEN and INREC
SORT – JUSTIFY, SQUEEZE and OVERLAY
SORT – LOOKUP AND CHANGE
SORT – CONVERT PD to ZD and BI to ZD
SORT – OUTREC – TRAN
SORT – OUTREC – INSERT ZEROES, BLANKS, STRINGS
SORT – OUTPUT DATASET DCB (LRECL,RECFM,BLKSIZE)
SORT – INCLUDE and OMIT
SORT – Process Order of CONTROL Statements
SORT – How to use VB dataset (VLSHRT)
SORT – EDIT MASK PATTERNS
SORT – EDIT NUMERIC FIELDS (I,T,S)
SORT – EDIT FIRST AND LAST RECORD
SORT – SYMBOLS
SORT – TO REPLACE A CHAR WITH ANOTHER CHAR – ALTSEQ
SORT – SET RETURN CODE ‘04’ IF OUTPUT FILE IS EMPTY
SORT – INREC, INCLUDE and OMIT
SORT – SKIPREC and STOPAFT
SORT – INREC
SORT – SUM FIELDS
SORT – REMOVE DUPLICATES AND WRITE THEM TO XSUM
DFSORT – Informational and Error Messages
SORT JOIN – UNPAIRED RECORDS INDICATOR
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
SORT JOB – SIMPLE COPY
SORT TIPS

 

Advertisement