• Rajesh A R

F1 for Mainframe

F1 for Mainframe

Category Archives: COBOL

COBOL Keywords

MAINFRAME – Special characters in the data (EBCDIC values)

18 Wednesday Oct 2017

Posted by rajeshar in COBOL

≈ Leave a comment

Tags

alphabet, ascii, chars, COBOL, ebcdic, hex, mainframe, mainframef1, numeric, SPECIAL

We have scenarios where we get a file from different team/company which will be fed as input to a program. This file might have name fields which might have special characters in between. We need to clean the special characters and ensure we have only valid numeric and alphabetic characters in it.

We can do this by checking each character in the name field
– If it is special char, replace with space
– If it is lower case, convert to upper case
– If it is Upper case, Numeric then it is good to go

Below is code snippet for declaration

01 WS-TEXT PIC X(60).

01 FILLER REDEFINES WS-TEXT.

05 WS-TEXT-CHAR PIC X(01) OCCURS 60
INDEXED BY IDX.

88 WS-PUNCTUATION-CHAR VALUES ‘¢’,’.’,'<‘,'(‘,’+’,’|’,’&’,’!’,’$’,’*’,’)’,’;’,’¬’,’-‘, ‘/’,’¦’,’,’,’%’,’_’,’>’,’?’,’`’,’:’,’#’,’@’,”’,’=’,'”‘,’~’,'{‘,’}’,’\’.

88 WS-ALPHA-CHAR VALUES ‘A’ THRU ‘I’,
‘J’ THRU ‘R’,
‘S’ THRU ‘Z’.
88 WS-NUMERIC-CHAR VALUES ‘0’ THRU ‘9’.
88 WS-LOWERCASE-CHAR VALUES ‘a’ THRU ‘z’.

The above declaration has an issue with how WS-LOWERCASE-CHAR field is defined, which will allow few special chars to enter system as valid. Find below the explanation.

1. Note that in the below ASCII and EBCDIC Tables letters a-z do not have consecutive HEX values (in EBCDIC).

2. Also note that the upper case characters A-Z are split based on HEX values, so only those values are considered as valid characters.

88 WS-ALPHA-CHAR VALUES ‘A’ THRU ‘I’,
‘J’ THRU ‘R’,
‘S’ THRU ‘Z’.

3. But for lower case a-z, as code mentions VALUES ‘a’ THRU ‘z’ , when there is a check, it checks through all values between a and z (which include æ, Æ). So this values slipped through logic and came into DB2 tables.

88 WS-LOWERCASE-CHAR VALUES ‘a’ THRU ‘z’.

The ASCII and EBCDIC Tables

EBCDIC HEX TABLE

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

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
HOW TO SUBMIT A BATCH JOB FROM THE CICS PROGRAM
CICS – EXEC interface block – EIBRESP Values
CICS – EXEC interface block Fields
Flow of control between COBOL programs, run units, and CICS
CICS INTERVIEW QUESTIONS
CICS TIPS
COBOL – COPY and INCLUDE statements
COBOL – PERFORMANCE IMPROVEMENT
COBOL – SIGN STORED IN COMP, COMP-3 AND DISPLAY FORMATS
SHORTEST COBOL PROGRAM
RESTART LOGIC IN COBOL DB2 Program
GOBACK – EXIT PROGRAM – STOP RUN
Continuation lines in COBOL
Computational items – COMP, COMP 1 , COMP 2, COMP 3
COBOL program format
cobol indicator area column-7 and area a and area b
COBOL INTERVIEW QUESTIONS
COBOL TIPS
COBOL COMPILER OPTIONS
The IDENTIFICATION DIVISION
Advertisement

Rate this:

← Older posts
Newer posts →

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

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
 

Loading Comments...