Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Strange Result when moving the DATE field

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ScottUrban

New User


Joined: 23 Apr 2007
Posts: 50
Location: Jefferson City, Mo

PostPosted: Fri Jan 25, 2008 7:03 pm    Post subject: Strange Result when moving the DATE field
Reply with quote

A date in USA format mm/dd/ccyy being selected off of a DB2 Table and then moved as is to an S9(8) comp-3 field did not cause an Abend. It shows up in the S9(8) comp-3 field as the example shows below;

Moving this value 08/31/2007 and it shows as +13112007

I know the field has to be converted to take out the slashes prior to moving it but after I found this problem in ther program it got me curious. Any explanations would be a great help?
Back to top
View user's profile Send private message

Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Jan 25, 2008 7:50 pm    Post subject:
Reply with quote

Seeing exact code and hex value of a DISPLAY would certainly help.
Back to top
View user's profile Send private message
ScottUrban

New User


Joined: 23 Apr 2007
Posts: 50
Location: Jefferson City, Mo

PostPosted: Fri Jan 25, 2008 8:17 pm    Post subject:
Reply with quote

END-STMT-DA PIC x(10) From DB2 table USA format 08/31/2007

WS-COMPARE-SETTLE-DA PIC S9(8) COMP-3

MOVE END-STMT-DA TO WS-COMPARE-SETTLE-DA
Results in HEX it appears to be converting X'61' to the number 1

Code:
  02 END-STMT-DA
    08/31/2007
    FF6FF6FFFF
    0813112007

Code:
02 WS-COMPARE-SETTLE-DA 
   ....@                 
   03107                 
   1120C
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Jan 25, 2008 8:33 pm    Post subject:
Reply with quote

It's not so much converting x'61' to 1 as just taking the rightmost nibble '1' and ignoring whatever is in the leftmost nibble. Since it is moving char to numeric, it "knows" that the digit value must be in the rightmost nibble: F0, F1, F2, .... One would sort of hope that this move would fail, as it contains junk, but COBOL just does the best it can.

My test LPAR is having upgrades today, so I cannot test in COBOL till Monday.
Back to top
View user's profile Send private message
ScottUrban

New User


Joined: 23 Apr 2007
Posts: 50
Location: Jefferson City, Mo

PostPosted: Fri Jan 25, 2008 8:36 pm    Post subject:
Reply with quote

Thanks, Makes sense.... I would think it would have received a S0C7 but I guess Cobol is attempting it's best guess at what the move was suppose to accomplish.. (which is kind of scary.....)
Back to top
View user's profile Send private message
ScottUrban

New User


Joined: 23 Apr 2007
Posts: 50
Location: Jefferson City, Mo

PostPosted: Fri Jan 25, 2008 8:37 pm    Post subject:
Reply with quote

let me know what you find out on Monday....

Thanks again,
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Fri Jan 25, 2008 8:42 pm    Post subject:
Reply with quote

No S0C7 because you are not doing arithmetic. Try moving any string of chars to a packed dec field and see what happens. Might as well try moving also to a COMP (binary) field.

Note that COBOL also fails to notify if it drops the left end of a longer source field - that's happening here, too.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Jan 26, 2008 8:19 pm    Post subject:
Reply with quote

Hi Phil,

As I recall, moving to a COMP-3 field does do arith. A ZAP (Zero and Add Packed) assembler instr really does the "move" into the receiving field.

In Scott's case here, the conversion produces a valid packed field (in spite of the "/"s) and therefore no 0C7 occurs.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Jan 27, 2008 1:57 am    Post subject:
Reply with quote

Hello,

To add to Jack's Excellent info, I believe different assembler may be generated depending on the fields.

In the case from this post, i'm fairly sure it will generate a ZAP instruction.

If the 2 fields were both the same length comp-3, i suspect an MVC would be generated as a "move" executes faster than the ZAP.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 27, 2008 4:46 am    Post subject:
Reply with quote

Quote:
To add to Jack's Excellent info...

You're a quick study dick.... heh heh heh.

PS. In my prev post I changed
Quote:
moving a COMP-3 field does do arith
to the following:
Quote:
moving to a COMP-3 field does do arith
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us