Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
softwareengineer

New User

Joined: 24 Aug 2005
Posts: 24

 Posted: Thu Feb 22, 2007 11:39 am    Post subject: what happens to spaces when we move x(23) to 9(23) ? What happens when we move spaces from x(23) to 9(23)..... For Ex: if I move x(23) which has value ''123456789 '' to 9(23).... what value wil be populated to Numeric value..... How to pad zeroes instead of Spaces while this movement....as I need that Numeric value for computation?? Please help.

raak

Active User

Joined: 23 May 2006
Posts: 166
Location: chennai

 Posted: Thu Feb 22, 2007 12:39 pm    Post subject: To Pad Zeroes instead of Spaces while moving, u have to use INSPECT VARIABLE-2 REPLACING ALL SPACES BY ZEROES. And u have to define the Variable-2 which is 9(23) as JUSTIFIED RIGHT.
Phrzby Phil

Active Member

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

 Posted: Thu Feb 22, 2007 6:36 pm    Post subject: Why not actually test your question and DISPLAY the result field?
rajesh_mbt

New User

Joined: 27 Mar 2006
Posts: 95
Location: India

Posted: Fri Feb 23, 2007 11:07 am    Post subject: Re: what happens to spaces when we move x(23) to 9(23) ?

 softwareengineer wrote: What happens when we move spaces from x(23) to 9(23)..... For Ex: if I move x(23) which has value ''123456789 '' to 9(23).... what value wil be populated to Numeric value..... How to pad zeroes instead of Spaces while this movement....as I need that Numeric value for computation?? Please help.

Hi
I think it will start from Left to Right (Left alignment) since, the movement is from alpa-num to num, and the remaining space would be filled by zeros.

Eg

MOVE X TO N

WHERE X IS PIC X(10) VALUE ?12345?
N IS PIC 9(10).

For the above example.

N will contain 1234500000 unless you explicitly specify as right alignment.
sachin_star3
Warnings : 1

New User

Joined: 30 Sep 2006
Posts: 78
Location: pune

 Posted: Fri Feb 23, 2007 11:39 am    Post subject: YES RAJESH IS CORRECT REMAING FILLED IS AUTOMATICALLY FILLED BY ZEROES FROM - SACHIN BORASE
dick scherrer

Site Director

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

Posted: Fri Feb 23, 2007 9:33 pm    Post subject:

Hello,

Rather that post what we think will happen, it is most often better to just run a little test and be sure what will happen (at least on your system),

This code
 Code: 01  SOMESTUFF3.                                               05 THE-XFIELD   PIC X(10) VALUE '12345     '.            05 THE-NUMBER   PIC 9(10).                              MOVE THE-XFIELD TO THE-NUMBER.            DISPLAY THE-NUMBER.

gives

 Code: 12345    0

Changing the x field to
 Code: 05 THE-XFIELD   PIC X(10) VALUE '12345'.

gives the same result.

 Code: 05 THE-XFIELD   PIC X(10) VALUE '12345ABCD+'.

gives
 Code: 12345ABCD

Changing the instructions to move a value into the x field, then moving the x field to the number
 Code: MOVE 12345 TO THE-XFIELD.                      MOVE THE-XFIELD TO THE-NUMBER.                DISPLAY THE-NUMBER.                            MOVE '12345__)) ' TO THE-XFIELD.              MOVE THE-XFIELD TO THE-NUMBER.                DISPLAY THE-NUMBER.

gives
 Code: 12345    0    12345__))0

Note that in no case was the receiving field padded with zeros.

If you'd like to try any others, have a go on your system. . . .
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

Posted: Sat Feb 24, 2007 10:50 am    Post subject:

Hi SE,

Probably the simplest way to "move" it is:
 Code: COMPUTE PIC-9 = FUNCTION NUMVAL (PIC-X)

These intrinsic functions (e.g. NUMVAL) can also be invoked thru LE subroutines (their prefix is CEE - check the manual for details).

One advantage is that they return a non-zero code when the sending field contains invalid data - e.g. 12Y456, where the FUNCTION will abend the pgm. But if you're sure of the content the FUNCTION approach might be OK.
dick scherrer

Site Director

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

 Posted: Sun Feb 25, 2007 12:24 am    Post subject: Hello, Before the COMPUTE you could/should specifically check if NOT NUMERIC and deal with it before the code can abend - a programmed error message/user abend is far preferable to an 0c7 or other uncontrolled abend.
mmwife

Super Moderator

Joined: 30 May 2003
Posts: 1592

 Posted: Sun Feb 25, 2007 10:11 pm    Post subject: Hi Dick, Unfortunately there may be spaces in the sending field causing the NUMERIC test to fail. I think the LE call may be the only way to get around that problem. That, or the brute force method of moving it byte by byte to a zero filled receiving field, checking for non-numerics along the way.
dick scherrer

Site Director

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

 Posted: Mon Feb 26, 2007 1:09 am    Post subject: Yup, there may be - i'm guessing there will be. I should have been more complete with my "NOT NUMERIC" suggestion. For TS - Before any "move" can be done with that PIC X data to some kind of numeric field, the rules for the field have to be defined. Are both leading and trailing spaces valid? Might there be commas, a decimal point, or a sign? And on, and on. . . Simply changing the spaces to zeros will most likely give an undesirable result. Replacing 3 trailing spaces with 3 zeros just multiplied the value by 1000. Putting the code into production without the proper edits is just begging for a call when the job abends in the middle of the night. . .
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am RMM Cannot move a volume from SHELF l... tspr52 IBM Tools 0 Thu Mar 01, 2018 3:48 pm Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 9 Thu Dec 14, 2017 3:52 pm how can i move s9(9) to s9(9) usage comp HARENDRA CHOUDHARY COBOL Programming 3 Mon Nov 06, 2017 12:10 am Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us