View previous topic :: View next topic
|
Author |
Message |
mvmadhavi
New User
Joined: 09 Nov 2006 Posts: 21
|
|
|
|
what will the below move statement yield
01 ws-fields.
05 abc pic s(9) comp-3
05 xyz pic x(10)
05 def pic 9(4)
move "my name is this" to ws-fields |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
what will the below move statement yield |
S0C-7 Data Exception Error.
Moving Chars to Numeric Value. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the MOVE itself will generate "my name is this...." where the periods represent 1 space. WS-FIELDS is a PIC X(19). Now when any instruction attempts to use either reference <abc> or <def> (other than IF NUMERIC) then a S0C7 will occur. But <move "my name is this" to ws-fields> will generate no Compile or Run-Time errors..... |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi,
I have tried ur code and received the below ouput.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. CHKWRK.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-FIELDS.
05 ABC PIC S9(9) COMP-3.
05 XYZ PIC X(10).
05 DEF PIC 9(4).
PROCEDURE DIVISION.
PARA1.
DISPLAY " ".
DISPLAY "CHECKING WORKING STORAGE VARIABLES".
MOVE "my name is this " TO WS-FIELDS.
DISPLAY WS-FIELDS.
STOP RUN. |
Quote: |
O/P:
CHECKING WORKING STORAGE VARIABLES
my name is this |
Let me know if you need any more ... |
|
Back to top |
|
|
David P
Active User
Joined: 11 Apr 2005 Posts: 106 Location: Cincinnati Ohio
|
|
|
|
Correct me if I am wrong but a MOVE statement will never cause a S0C7.
-David P. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Code: |
01Field-A.
05 sub-field-a PIC s9(5)V99 comp-3
01 Field-B pic s9(9) binary
|
move high-values to Field-A
move sub-field-a to Field-B |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi,
Code: |
move high-values to Field-A
move sub-field-a to Field-B |
I dont know what you are talking about ??????? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
a comment was made about moves not generating S0C7's. the move of sub-field-a to field-B would. The high-values move was confusing, because that was just to load the field. actually, a better example would be:
Code: |
01 WS-FIELD-A PIC X(5) VALUE HIGH-VALUES.
01 WS-FIELD-A-SUB
REDEFINES
WS-FIELD-A PIC S9(9) PACKED-DECIMAL.
01 WS-FIELD-B PIC S9(9) BINARY.
MOVE WS-FIELD-A-SUB TO WS-FIELD-B |
The move instruction will generate a S0C7. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
ALL group variables are defined by default as alphanumeric. So, ws-fields, by default is defined as PIC X(10).
That?s why you can move ?my name is this? to ws-fields.
As a result, abc will contain hex x?94? that is not in packed decimal format and will abend with 0C7 if you attempt to use it. Xyz will contain ?y name is ?, and def will contain hex ?a38889a2?. Because you have this defined as a unsigned field, the value you will get when you use def it will be 3892. The result of adding 1 to def will result in a hex ?f3f8f9f3?, or a properly formatted 3893 value.
Dave |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
DavidatK,
Quote: |
ALL group variables are defined by default as alphanumeric. So, ws-fields, by default is defined as PIC X(10). |
there is no such thing as a default length.
WS-FIELDS is a group item with 3 elementary items of lengths 5,10,4 or a total length of 19.
otherwise, good comment. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Dick,
Quote: |
01 ws-fields.
05 abc pic s(9) comp-3
05 xyz pic x(10)
05 def pic 9(4)
|
My fat fingers while typing, my assumption is that ?abc? was meant to be S9 COMP-3, not S9(9) COMP-3., so I should have said?
Quote: |
ALL group variables are defined by default as alphanumeric. So, ws-fields, by default is defined as PIC X(15).
|
semantics: I said, by default, ws-fields is defined as (should have been) PIC X(15) (not PIC X(10)). Not that there is a default length for group variables. By default Group variables are defines as alphanumeric with a length of the Sum of the lengths of all elementary items under it.
Is that better stated?
Dave |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
hi david,
it is a little late to be playing tag with this, but I can't resist.
i assumed you had made a typo (the length), but in combination with the word default, as I said, I could not resist.
to me, default means the standard options (site, etc...) applied when no other options are used. I just pulled your chain, because saying that '... is the default length' implies that there are other options for calculating the length.
default is not a term that I would apply to description of how to calculate the length of a group item.
I appreciate your posts, I apologize, was not really an attack .... result of end of week depression. have a great weekend. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Dick my friend,
No offence taken, no need for an apology, always nice to have someone to good heartedly joust with and to keep me on my feet Using ?DEFAULT? in the context I did was probably stretching a little.
Looking forward to the next time
Dave |
|
Back to top |
|
|
|