IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What will the below move statement yield


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mvmadhavi

New User


Joined: 09 Nov 2006
Posts: 21

PostPosted: Thu Nov 09, 2006 6:25 pm
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Thu Nov 09, 2006 6:44 pm
Reply with quote

Quote:
what will the below move statement yield

S0C-7 Data Exception Error.

Moving Chars to Numeric Value.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 09, 2006 6:51 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Thu Nov 09, 2006 7:03 pm
Reply with quote

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
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Thu Nov 09, 2006 8:41 pm
Reply with quote

Correct me if I am wrong but a MOVE statement will never cause a S0C7.

-David P.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Nov 09, 2006 9:48 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Fri Nov 10, 2006 2:16 am
Reply with quote

Hi,

Code:
move high-values to Field-A
move sub-field-a to Field-B



I dont know what you are talking about ??????? icon_redface.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Nov 10, 2006 2:25 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Nov 10, 2006 4:19 am
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Fri Nov 10, 2006 5:48 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Sat Nov 11, 2006 3:10 am
Reply with quote

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? icon_smile.gif

Dave
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sat Nov 11, 2006 6:56 am
Reply with quote

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
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Nov 14, 2006 5:40 am
Reply with quote

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 icon_smile.gif Using ?DEFAULT? in the context I did was probably stretching a little. icon_smile.gif

Looking forward to the next time

Dave
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts How to move DB2 Installation HLQ DB2 4
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
Search our Forums:

Back to Top