• Rajesh A R

F1 for Mainframe

F1 for Mainframe

Tag Archives: parse

SORT – PARSE – READ EXCEL (CSV) FILE IN MAINFRAMES

28 Wednesday Mar 2012

Posted by rajeshar in SORT

≈ Leave a comment

Tags

comma, csv, excel, file, import, into, mainframe, parse, read, seperated, SORT

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

Rate this:

Subscribe

  • Entries (RSS)
  • Comments (RSS)

Archives

  • November 2020
  • July 2020
  • February 2020
  • January 2020
  • September 2019
  • August 2019
  • October 2018
  • April 2018
  • March 2018
  • December 2017
  • October 2017
  • August 2017
  • July 2017
  • June 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • May 2016
  • March 2016
  • February 2016
  • January 2016
  • May 2015
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • January 2013
  • December 2012
  • November 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • April 2011
  • March 2011
  • August 2009
  • June 2009
  • April 2009

Categories

  • Azure
  • CA7
  • CICS
  • COBOL
    • Keywords
  • DB2
  • EASYTRIEVE
  • FILEAID
  • FILEMAXX
  • IMS
  • ISPF
  • JCL
  • KNOW YOUR MAINFRAME
  • Mainframe Migration
  • MAINFRAMES
  • Others
  • REXX
  • SDSF
  • SORT
  • Training
  • TSQL
  • VSAM

Meta

  • Register
  • Log in

Create a free website or blog at WordPress.com.

  • Follow Following
    • F1 for Mainframe
    • Join 88 other followers
    • Already have a WordPress.com account? Log in now.
    • F1 for Mainframe
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar