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
 

 

Displaying a COMP field in sysoud

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

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Wed Mar 09, 2011 7:42 pm    Post subject: Displaying a COMP field in sysoud
Reply with quote

I have a comp variable S9(5) and i am displaying this in job output. do that display sign also ?

Code:
CHAR-FIELD             PIC X(8).     
NUM-FIELD              PIC S9(5).     
NUM-COMP-FIELD         PIC S9(5) COMP.
END-COMP-FIELD         PIC S9(5) COMP.

MOVE '-0025874'         TO CHAR-FIELD.       
DISPLAY 'CHAR FIELD IS : ' CHAR-FIELD.       
                                             
MOVE CHAR-FIELD      TO NUM-FIELD.           
DISPLAY 'NUM-FIELD  IS : ' NUM-FIELD.         
                                             
MOVE NUM-FIELD       TO NUM-COMP-FIELD.       
DISPLAY 'NUM-COMP-FIELD IS : ' NUM-COMP-FIELD.
                                             
MOVE NUM-COMP-FIELD  TO END-COMP-FIELD.       
DISPLAY 'END-COMP-FIELD IS : ' END-COMP-FIELD.


I tried this but it is displaying the below.

Code:
CHAR FIELD IS : -0025874     
NUM-FIELD  IS : 25874         
NUM-COMP-FIELD IS : 0000025874
END-COMP-FIELD IS : 0000025874


could you please anyone explain this. or any link is appreciated.

Thanks
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Wed Mar 09, 2011 8:17 pm    Post subject:
Reply with quote

The MOVE CHAR-FIELD TO NUM-FIELD is where your difference comes from. The decimal point of a PIC X variable is to the right of the last digit. Hence, 25874 is moved to NUM-FIELD and your sign is lost.

This is all clearly and completely explained in the manuals (link at the top of the page), specifically section 6.2.24.2 of the COBOL Language Reference manual.
Back to top
View user's profile Send private message
PrabakarV

New User


Joined: 21 Dec 2007
Posts: 88
Location: My Desk

PostPosted: Wed Mar 09, 2011 9:04 pm    Post subject:
Reply with quote

sorry i got this.

Code:
CHAR FIELD IS : -0025874       
NUM-FIELD  IS : 2587D         
NUM-COMP-FIELD IS : 0000025874
END-COMP-FIELD IS : 0000025874
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Wed Mar 09, 2011 9:33 pm    Post subject:
Reply with quote

Code:
       77  CHAR-FIELD                  PIC X(8).
       77  CHAR-FIELD-N                REDEFINES CHAR-FIELD
                                       PIC S9(07) SIGN LEADING SEPARATE.
       77  NUM-FIELD                   PIC S9(5).
       77  NUM-COMP-FIELD              PIC S9(5) COMP.
       77  END-COMP-FIELD              PIC S9(5) COMP.

       PROCEDURE DIVISION.
           MOVE '-0025874'             TO  CHAR-FIELD.
           DISPLAY 'CHAR FIELD IS : ' CHAR-FIELD.

           MOVE CHAR-FIELD-N           TO  NUM-FIELD.
           DISPLAY 'NUM-FIELD  IS : ' NUM-FIELD.

           MOVE NUM-FIELD              TO  NUM-COMP-FIELD.
           DISPLAY 'NUM-COMP-FIELD IS : ' NUM-COMP-FIELD.

           MOVE NUM-COMP-FIELD         TO  END-COMP-FIELD.
           DISPLAY 'END-COMP-FIELD IS : ' END-COMP-FIELD.
produces results, as expected, of
Code:
 CHAR FIELD IS : -0025874
 NUM-FIELD  IS : 2587M
 NUM-COMP-FIELD IS : 000002587M
 END-COMP-FIELD IS : 000002587M
I'm not sure if you deliberately ignored my earlier post, or if you don't understand the manual, or what.
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: Wed Mar 09, 2011 10:10 pm    Post subject: Reply to: Displaying a COMP field in sysoud
Reply with quote

Hi Robert,

Interestingly, i get the "positive" nibble on the zoned-decimal field:
Code:
CHAR FIELD IS : -0025874 
NUM-FIELD  IS : 2587D     
NUM-COMP-FIELD IS : 25874
END-COMP-FIELD IS : 25874
Also, i do not have leading zeros on the COMP fields displays. . .

The difference between what you posted and what i used is that my ws-fields are level 01 rather than 77 . . .

d
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Wed Mar 09, 2011 10:19 pm    Post subject:
Reply with quote

Dick,
Out of Curiousity, did you specify SIGN LEADING SEPARATE on your redefines?
If you DID, then I will be forced to try both Robert's code and your code on my system to see whether the results differ.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Wed Mar 09, 2011 10:26 pm    Post subject:
Reply with quote

I tired 01 instead of 77 and got the same results.

My site standard compile process sets TRUNC(BIN). When I recompile with TRUNC(STD), I don't get the leading zeroes on the COMP variables, either.

I redefined the PIC X to numeric SIGN LEADING SEPARATE to pick up the sign -- hence the code post. With just the MOVE the O/P has, I get the same results you do (using TRUNC(STD) of course).
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: Wed Mar 09, 2011 10:27 pm    Post subject: Reply to: Displaying a COMP field in sysoud
Reply with quote

Hi Ronald,

Actually, i used the code initially posted by the TS - i don't have a redefines. And having said that i realize i forgot Robert's original reply. . . Agreed with this 2 hours ago and lost it . . . Dain Brammage. . . icon_redface.gif

Yeeesh. . .

d
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: Wed Mar 09, 2011 10:28 pm    Post subject: Reply to: Displaying a COMP field in sysoud
Reply with quote

Follow on. . .

Maybe i shouldn't work on things that dispense medicine or write checks today. . . icon_lol.gif

d
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Wed Mar 09, 2011 10:37 pm    Post subject:
Reply with quote

Hey, if you're writing checks can I get in line? icon_biggrin.gif
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: Thu Mar 10, 2011 1:45 am    Post subject: Reply to: Displaying a COMP field in sysoud
Reply with quote

Sure - maybe we can share the same jail cell. . . icon_cool.gif

d
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 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 How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm


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