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
 

 

After the MOVE, the value contains an extra zero

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

New User


Joined: 09 Aug 2006
Posts: 5

PostPosted: Fri Sep 29, 2006 11:24 pm    Post subject: After the MOVE, the value contains an extra zero
Reply with quote

Hi,

I am trying to move a 15 digit value from PIC X(16) to PIC 9(16), after the move the value contains an extra zero in the right most digit. Can any one tell how to avoid getting the zero?
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 Sep 30, 2006 1:54 am    Post subject: Re: MOVE startment problem
Reply with quote

If you are using ecobol you can use the numval function

COMPUTE VAR-9 = FUNCTION NUMVAL (VAR-X)

See link NUMVAL

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

New User


Joined: 09 Aug 2006
Posts: 5

PostPosted: Sat Sep 30, 2006 1:57 am    Post subject: Re: MOVE startment problem
Reply with quote

I tried this,

COMPUTE VAR-9 = FUNCTION NUMVAL (VAR-X)

then it is adding zero at left most digit of the destination varible. I tried NUMVAL-C, Integer functions too but no use.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Sat Sep 30, 2006 10:51 am    Post subject:
Reply with quote

HI rdasari,

After moving X(16) TO 9(16) Move it to Z9(15).

Hope it will work.

Let us know ur result
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 30, 2006 7:11 pm    Post subject:
Reply with quote

Hi rdasari,

As far as I can see, the NUMVAL solution should work. Perhaps the last pos in VAR-X doesn't contain a space, but a non-printable char (binary zeros?).

Display the VAR-X and turn hex on in SDSF and take a look. Who knows?
Back to top
View user's profile Send private message
rdasari

New User


Joined: 09 Aug 2006
Posts: 5

PostPosted: Mon Oct 02, 2006 7:49 pm    Post subject: replay
Reply with quote

Hi,

The var-x is containing a space X'40', still if I use var-y=numval(var-9) its adding a zero at the begining of var-9.

var-x pic x(16) value is '123456789123456'
var-y pic 9(16).

var-x= numval(var-y)
then var-y contains '0123456789123456'

If do not use numval and i do normal move operaton then var-y contains
'1234567891234560'

both are not deserved results
thanks
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Oct 02, 2006 8:15 pm    Post subject: Re: After the MOVE, the value contains an extra zero
Reply with quote

Try this if target field can be modified and you always don't want zero at the end.

Define target field as:
Code:


01  VAR-Y.                                       
    05 var-y1             PIC 9(15).             
    05 var-y2             PIC 9 BLANK WHEN ZERO.
Back to top
View user's profile Send private message
rdasari

New User


Joined: 09 Aug 2006
Posts: 5

PostPosted: Mon Oct 02, 2006 8:24 pm    Post subject: Re: After the MOVE, the value contains an extra zero
Reply with quote

Hi,

I tried 'BLANK WHEN ZERO' too.. the problem with this is

01 VAR-X PIC 9(16) BLANK WHEN ZERO
01 VAR-Y PIC 9(16)
01 VAR-Z PIC 9(16)

VAR-X = 123456789123456
MOVE VAR-X TO VAR-Y.
gives good result with VAr-Y. i.e 123456789123456 and a blank.

but when I move VAR-Y TO VAR-Z, the story repeats
VAR-Z contains on extra zero at the end. I could have used BLANK WHEN ZERO for VAR-Y too but I want to know why in a simple move between two varibles of 9(16), the value is changing. adding a zero at the end makes so much difference, is COBOL can't accomidate this simple move.
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Mon Oct 02, 2006 9:01 pm    Post subject: Re: After the MOVE, the value contains an extra zero
Reply with quote

No new insight but few pointers:

Needless to say here are alignment rules:

Code:

Alignment rules                                                           
                                                                           
The standard alignment rules for positioning data in an elementary item   
depend on the category of a receiving item (that is, an item into which   
the data is moved; see "Elementary moves" in item MOVE).                   
                                                                           
Numeric                                                                   
          For such receiving items, the following rules apply:             
                                                                           
          1.  The data is aligned on the assumed decimal point and, if     
              necessary, truncated or padded with zeros.  (An assumed     
              decimal point is one that has logical meaning but that does 
              not exist as an actual character in the data.)               
                                                                           
          2.  If an assumed decimal point is not explicitly specified, the
              receiving item is treated as though an assumed decimal point
              is specified immediately to the right of the field.  The     
              data is then treated according to the preceding rule.       
                                                                           
Numeric-edited                                                             
          The data is aligned on the decimal point, and (if necessary)     
         truncated or padded with zeros at either end, except when   
         editing causes replacement of leading zeros.               


Few things to consider:

- Use copybook and define field with Blank Zero and this way you are consistent with its usage.
- Consider definition of field, why is defined a 9, in our shop we define field as 9's only when it is truly numeric. If field is some kind of indentifier (like Account identifier(number) etc) then it is defined as X.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Oct 03, 2006 7:51 am    Post subject:
Reply with quote

Hi rdasari,

Sorry, I miss-read your 2nd post. The reason you get the trailing zero on the MOVE is that the receiving field is unsigned and requires an X'Fn' formatted char in the sign position. The move function changes the X'40' to X'F0' via an OI (or immediate) assembler inst to force an "unsigned" low order digit.

You might try this to by-pass the sign "fixing":

MOVE VAR-X TO VAR-9(1:)

CAN YOU TELL US WHY YOU WOULD WANT A SPACE IN A NUMERICALLY DEFINED FIELD? WHY NOT USE PIC X(16)? i DON'T THINK YOU CAN SUCCESSFULLY PERFORM ARITH OPS USING A PIC 9 FIELD W/A SPACE IN IT.
Back to top
View user's profile Send private message
rdasari

New User


Joined: 09 Aug 2006
Posts: 5

PostPosted: Tue Oct 03, 2006 8:38 pm    Post subject:
Reply with quote

Hi,

This sounds funny but the requirement is like that. They want to use 9(16) for primary key which is an acct#. As of the this feild will contain only 15 digits and may be 16 digit in future.

We are sure that we are not going to perform any arthimetic operations with this feild, but still they want it to be numeric. I am just programer, its problem with HLD & LLD people.

Thanks,
RDasari.
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
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
This topic is locked: you cannot edit posts or make replies. Alphanumeric to Numeric move on UNIX mistah kurtz COBOL Programming 16 Wed Jul 27, 2016 8:47 pm
No new posts Need information on COBOL MOVE CORRES... subratarec COBOL Programming 10 Tue Jun 28, 2016 10:38 pm


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