Home > Archive > Cobol > January 2005 > Mainframe Code
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| SkippyPB 2005-01-24, 8:55 pm |
| OK, Doc, this is NOT homework. It is a real world situation I've come
across that someone else already coded, but I'd like to get other
opinions and options. I'll not reveal how the other person did this
until I see some postings so as not to influence anyone.
We have an input field that is defined thusly:
SUPP-DATA-VALUE PIC X(50).
We are interested in only the left most 10 bytes which contain a
number that is from 1 to 10 bytes long. All unused portions of the
field are spaces. This number will become part of a key to read
another file and it must be numeric right justified. Our key field is
defined thusly:
WS-OBLIGATION PIC 9(11).
As an example, if SUPP-DATA-VALUE contained in the first 10 bytes the
following data:
98354bbbbb
where b = blanks
After move and/or manipulation WS-OBLIGATION should contain:
0000098354
The environment is z/OS390, Cobol compiler is the latest one.
How would you best achieve this?
Regards,
////
(o o)
-oOO--(_)--OOo-
"I always wanted to be the last man on earth,
just to see if all those women were lying to me."
-- Ronnie Shakes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Remove nospam to email me.
Steve
| |
| Frederico Fonseca 2005-01-24, 8:55 pm |
| On Mon, 24 Jan 2005 17:48:39 -0500, SkippyPB
<swiegand@neo.rr.NOSPAM.com> wrote:
>OK, Doc, this is NOT homework. It is a real world situation I've come
>across that someone else already coded, but I'd like to get other
>opinions and options. I'll not reveal how the other person did this
>until I see some postings so as not to influence anyone.
>
>We have an input field that is defined thusly:
>
>SUPP-DATA-VALUE PIC X(50).
>
>We are interested in only the left most 10 bytes which contain a
>number that is from 1 to 10 bytes long. All unused portions of the
>field are spaces. This number will become part of a key to read
>another file and it must be numeric right justified. Our key field is
>defined thusly:
>
>WS-OBLIGATION PIC 9(11).
>
>As an example, if SUPP-DATA-VALUE contained in the first 10 bytes the
>following data:
>
>98354bbbbb
>
>where b = blanks
>
>After move and/or manipulation WS-OBLIGATION should contain:
>
>0000098354
>
IF SUPP-DATA-VALUE(1:1) NOT = SPACES
UNSTRING SUPP-DATA-VALUE DELIMITED BY SPACES
INTO WS-OBLIGATION
ELSE
MOVE ZEROS TO WS-OBLIGATION
END-IF.
The above assumes that SUPP-DATA-VALUE can only have numbers or
spaces.
If it can have other values then the above will not work and on this
case I suggest the old reliable perform ... until.
Frederico Fonseca
ema il: frederico_fonseca at syssoft-int.com
| |
| William M. Klein 2005-01-24, 8:55 pm |
| With Enterprise COBOL (or any compiler including the '89 Standard Intrinsic
Functions), I would do
Compute WS-OBLIGATION = Function NumVal (SUPP-DATA-VALUE (1:10))
This would ALSO "handle" cases where the input field had leading rather than
trailing spaces (i.e. any combination of leading and trailing spaces).
--
Bill Klein
wmklein <at> ix.netcom.com
"SkippyPB" <swiegand@neo.rr.NOSPAM.com> wrote in message
news:43uav09pe2nl2a9f6qd26onir9rmja4ge0@
4ax.com...
> OK, Doc, this is NOT homework. It is a real world situation I've come
> across that someone else already coded, but I'd like to get other
> opinions and options. I'll not reveal how the other person did this
> until I see some postings so as not to influence anyone.
>
> We have an input field that is defined thusly:
>
> SUPP-DATA-VALUE PIC X(50).
>
> We are interested in only the left most 10 bytes which contain a
> number that is from 1 to 10 bytes long. All unused portions of the
> field are spaces. This number will become part of a key to read
> another file and it must be numeric right justified. Our key field is
> defined thusly:
>
> WS-OBLIGATION PIC 9(11).
>
> As an example, if SUPP-DATA-VALUE contained in the first 10 bytes the
> following data:
>
> 98354bbbbb
>
> where b = blanks
>
> After move and/or manipulation WS-OBLIGATION should contain:
>
> 0000098354
>
> The environment is z/OS390, Cobol compiler is the latest one.
>
> How would you best achieve this?
>
> Regards,
>
> ////
> (o o)
> -oOO--(_)--OOo-
>
>
> "I always wanted to be the last man on earth,
> just to see if all those women were lying to me."
> -- Ronnie Shakes
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Remove nospam to email me.
>
> Steve
| |
| Robert Wagner 2005-01-24, 8:55 pm |
| On Mon, 24 Jan 2005 17:48:39 -0500, SkippyPB
<swiegand@neo.rr.NOSPAM.com> wrote:
>OK, Doc, this is NOT homework. It is a real world situation I've come
>across that someone else already coded, but I'd like to get other
>opinions and options. I'll not reveal how the other person did this
>until I see some postings so as not to influence anyone.
>
>We have an input field that is defined thusly:
>
>SUPP-DATA-VALUE PIC X(50).
>
>We are interested in only the left most 10 bytes which contain a
>number that is from 1 to 10 bytes long. All unused portions of the
>field are spaces. This number will become part of a key to read
>another file and it must be numeric right justified. Our key field is
>defined thusly:
>
>WS-OBLIGATION PIC 9(11).
>
>As an example, if SUPP-DATA-VALUE contained in the first 10 bytes the
>following data:
>
>98354bbbbb
>
>where b = blanks
>
>After move and/or manipulation WS-OBLIGATION should contain:
>
>0000098354
>
>The environment is z/OS390, Cobol compiler is the latest one.
>
>How would you best achieve this?
MOVE [function] NUMVAL(SUPP-DATA-VALUE(1:10)) TO WS-OBLIGATION.
| |
| William M. Klein 2005-01-25, 3:55 am |
| "Robert Wagner" <spamblocker-robert@wagner.net> wrote in message
news:nb3bv0piv1td4p4v85cqjd35f0r5p8ncck@
4ax.com...
> On Mon, 24 Jan 2005 17:48:39 -0500, SkippyPB
> <swiegand@neo.rr.NOSPAM.com> wrote:
>
<snip>
>
> MOVE [function] NUMVAL(SUPP-DATA-VALUE(1:10)) TO WS-OBLIGATION.
This will get a compile-time error with any IBM mainframe compiler (see subject
line - I am assuming "IBM" for mainframe).
MOVE of a numeric intrinsic function is NOT standard until the '02 ANSI/ISO
Standard and has limited frequency as an extension for various '89 Standard
compilers. (I know that some DO allow it - but I don't think the "majority" do.)
--
Bill Klein
wmklein <at> ix.netcom.com
| |
| Chuck Stevens 2005-01-25, 3:55 pm |
| I think this vendor extension to '85/'89 COBOL may be more common than you
think. Certainly the Unisys MCP environment allows it, and as you point
out, the '02 standard allows it as well, which seems to indicate that at
least some of the people involved in the development of the '02 standard
felt that enough vendors had managed to implement such an extension without
significant problems to warrant extending the context.
I wasn't there when these decisions were made, but in the '89 amendment I
see what could be regarded capricious limitations, and perhaps even as
conflicts among the definitions.
Referencing ANSI X3.23a-1989 (the amendment) and ANSI X3.23-1985 (the
standard itself): Amendment page A-29, "data item functions" are defined
as "elementary data items". Standard pages VI-103 through V-106, the MOVE
statement allows an "elementary data item" as a source field. Amendment
page A-29 again, integer functions may be used anywhere an integer operand
is required and a signed operand is allowed, but *numeric* functions,
despite their being "elementary data items" are explicitly restricted to use
within arithmetic expressions. ????? My reaction to seeing that
restriction runs along the lines of "Huh? What if it's Tuesday?".
I suspect more than one implementor of the amendment felt that, since a
numeric function is supposed to be treated as a "numeric data item", then
relaxing the restriction was likely to be at least as easy, if not easier
than, making sure it was strictly enforced!
Frequently the "first pass" of a new feature into the standard will include
restrictions that may seem capricious; often, this is done to ensure that
the basic concepts and mechanisms of the feature are well-shaken-down before
the restrictions are relaxed; I suspect this is just such a case.
-Chuck Stevens
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:dEkJd.1414168$O24.215727@news.easynews.com...
> "Robert Wagner" <spamblocker-robert@wagner.net> wrote in message
> news:nb3bv0piv1td4p4v85cqjd35f0r5p8ncck@
4ax.com...
> <snip>
>
> This will get a compile-time error with any IBM mainframe compiler (see
subject
> line - I am assuming "IBM" for mainframe).
>
> MOVE of a numeric intrinsic function is NOT standard until the '02
ANSI/ISO
> Standard and has limited frequency as an extension for various '89
Standard
> compilers. (I know that some DO allow it - but I don't think the
"majority" do.)
>
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
>
>
|
|
|
|
|