View previous topic :: View next topic
|
Author |
Message |
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
I am working on a project and had the following fields:
Code: |
01 STATUS-DATE.
05 STAT-DATE-MM PIC 99.
05 STAT-DATE-DD PIC 99.
05 STAT-DATE-YY PIC 99.
01 STATUS-DATE-PACKED PIC S9(7) COMP-3.
MOVE STATUS-DATE TO STATUS-DATE-PACKED.
|
This resulted in a S0C7.
Changing the STATUS-DATE to this:
Code: |
01 STATUS-DATE PIC 9(06).
01 FILLER REDEFINES STATUS-DATE.
05 STAT-DATE-MM PIC 99.
05 STAT-DATE-DD PIC 99.
05 STAT-DATE-YY PIC 99.
|
Results in successful process.
COBOL is a funny duck. |
|
Back to top |
|
|
Devzee
Active Member
Joined: 20 Jan 2007 Posts: 684 Location: Hollywood
|
|
|
|
Moving alphanumeric to comp-3 will cause abend. |
|
Back to top |
|
|
kiran_65
New User
Joined: 01 Apr 2005 Posts: 46
|
|
|
|
Initialize the comp-3 variable. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Well, doing this
Quote: |
Initialize the comp-3 variable. |
is always a good idea, but initializing the receiving field will have no affect on a move. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Assuming Enterprise COBOL, The move is legal.
Does STATUS-DATE contain numeric data?
It would be interesting to see the difference in the generated code and which instruction actually got the exception. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
This may sound a dumb question but did MOVE result in S0C7?
Group data items are alphanumeric, so the move will be considered as alphanumeric move. For such alphanumeric moves compiler will generate MVC instruction. Even if the STATUS-DATE contains numeric data, this may result in moving invalid data in COMP-3 variable.
Example:
Code: |
01 STATUS-DATE VALUE '012345'.
05 STAT-DATE-MM PIC 99.
05 STAT-DATE-DD PIC 99.
05 STAT-DATE-YY PIC 99.
01 STATUS-DATE-PACKED PIC S9(7) COMP-3.
PROCEDURE DIVISION.
MOVE STATUS-DATE TO STATUS-DATE-PACKED.
ADD 1 TO STATUS-DATE-PACKED. ======> soc7 |
|
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi SD,
In the orig case you moved a group item to a packed field and no conversion took place.
Withthe redfef you changed the orig field to an elementary item and conversion took place. |
|
Back to top |
|
|
socker_dad
Active User
Joined: 05 Dec 2006 Posts: 177 Location: Seattle, WA
|
|
|
|
Of course! By NOT defining the group level as numeric, it defaulted to alphanumeric - making the move to a comp-3 field invalid.
Must have had an alzheimer's moment.......
Thanks guys! (and gals) |
|
Back to top |
|
|
kbmkris
Active User
Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Is there any way to define the group variable as numeric? i.e. to change from the default of alphanumeric
Thanks,
Bala |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
No. By definition, group fields are alpha-numeric.
You can sometimes use the content as numeric, but the definition of group fields is alpha-numeric. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
No, the only way is to redefine it. |
|
Back to top |
|
|
kbmkris
Active User
Joined: 24 Jun 2006 Posts: 101
|
|
|
|
Thanks dick & Jack:-) |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
You're welcome |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
My pleasure. |
|
Back to top |
|
|
|