Re: Setting A Hex Value in COBOL




"gary" <garyinri@xxxxxxxxx> wrote in message
news:%yj7i.172509$nh4.82579@xxxxxxxxxxxxxxx
I have to modify an old COBOL program which probably hasn't been touched
since the mid-90's. And it's probably been almost as long since I've
touched COBOL. Part of what happens in the program is the setting of some
printer control codes which are sent to some downstream printers in CICS.

The following snippet of code shows how some of the control codes are
currently being set. It seems pretty straightforward. For instance, the
redefinition of CH-FF-BIN with its value of +12 causes the CH-FF field to
contain X'0C. Simarly, CH-1D-BIN with its value of +29 causes the CH-1D
filed to contain a X'1D'.


01 CH-NL-BIN PIC S9(4) COMP VALUE +21.
01 FILLER REDEFINES CH-NL-BIN.
02 FILLER PIC X.
02 CH-NL PIC X.
01 CH-FF-BIN PIC S9(4) COMP VALUE +12.
01 FILLER REDEFINES CH-FF-BIN.
02 FILLER PIC X.
02 CH-FF PIC X.
01 CH-1D-BIN PIC S9(4) COMP VALUE +29.
01 FILLER REDEFINES CH-1D-BIN.
02 FILLER PIC X.
02 CH-1D PIC X.
01 CH-56-BIN PIC S9(4) COMP VALUE +86.
01 FILLER REDEFINES CH-56-BIN.
02 FILLER PIC X.
02 CH-56 PIC X.
01 CH-31-BIN PIC S9(4) COMP VALUE +49.
01 FILLER REDEFINES CH-31-BIN.
02 FILLER PIC X.
02 CH-31 PIC X.

My question is this. I need to add a field which would end up containing
a
X'E5'. The decimal equivalent is +229. Since the value of the field is
3-digits, will it still "fit" into the PIC X field? Would it look
something
like this?

01 CH-E5-BIN PIC S9(4) COMP VALUE +229.
01 FILLER REDEFINES CH-E5-BIN.
02 FILLER PIC X.
02 CH-E5 PIC X.

This is some old MVS COBOL II code. Is there actually a better way to be
performing this function? Is there anything like MOVE X'E5' to CH-E5?

Whether anything is better may be entirely subjective;
but two other methods come to mind, both of which
seem to have become available with VS COBOL II.

1. Symbolic characters (ANSI 85):
[Note that values given here are 1 greater than the
actual character.]

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYMBOLIC CHARACTERS
CH-NL IS 22
CH-FF IS 13
CH-1D IS 30
CH-56 IS 87
CH-31 IS 50
CH-E5 IS 230.

2. Hexadecimal literals (VS COBOL II extension):

DATA DIVISION.
WORKING-STORAGE SECTION.
01 FILLER.
02 CH-NL PIC X VALUE X"15".
02 CH-FF PIC X VALUE X"0C".
02 CH-1D PIC X VALUE X"1D".
02 CH-56 PIC X VALUE X"56".
02 CH-31 PIC X VALUE X"31".
02 CH-E5 PIC X VALUE X"E5".

The use of symbolic characters may generate MVI
instructions and not require any working-storage.
This use of hexadecimal literals in working-storage
may generate MVC instructions; but use less
working-storage than the existing method. Extending
the existing method may be more consistent with
other programs in the system. These are the choices
I see.



.



Relevant Pages

  • Re: Setting A Hex Value in COBOL
    ... 01 FILLER REDEFINES CH-NL-BIN. ... Symbolic characters: ... allowed to submit compiles without the DBA's approval... ...
    (comp.lang.cobol)
  • Re: Filler keyword not mandatory?
    ... There's a difference between a declaration and an initialization. ... That would be one-downs-man-ship given that coding FILLER is, ... I believe that coding FILLER is acceptable. ... COBOL standard. ...
    (comp.lang.cobol)
  • Re: Filler keyword not mandatory?
    ... Since the reserved word FILLER is optional in the 1985 ANSI COBOL ... you could get more of the literal ona single line by omitting the word ...
    (comp.lang.cobol)
  • Re: Filler keyword not mandatory?
    ... FILLER is an optional word ... It has nothing to do with coding style in COBOL or any ... For me the "benefit" in coding FILLER is that I can immediately see what ... the real question is: "Is there enough benefit to coding FILLER to make ...
    (comp.lang.cobol)
  • Re: excluding fields in SELECT statement
    ... The closest thing I know is FILLER in Cobol. ...
    (comp.databases.ms-sqlserver)