Page 1 of 1

Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 1:03 pm
by nikesh_rai
Hi,

Is it possible to use JUSTIFIED RIGTH or LEFT with numeric or edit numeric filed. How far I know, it is not possible but if any can suggest me a alternet way to do it, it will be helpful to me.

06 WV55-INCLD-ALWC PIC Z(10)V9(4) VALUE ZEROES .

I want to align the value of WV55-INCLD-ALWC to right or left as per my requirment.

Thanks
Nikesh

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 1:19 pm
by BillyBoyo
A numeric field is justified to the right anyway, so can you be more exact about what you mean, with some examples, please.

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 1:32 pm
by nikesh_rai
Thanks Billy,

Say 06 WV55-INCLD-ALWC have a value like 31.8200 . Based on some other key values, I have to decide whether it should be populated as Justified left or Justified right. Since the numeric fields are always right justified.. is there any way I can change them into Left Justified whenever required.

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 3:02 pm
by enrico-sorichetti
Since the numeric fields are always right justified.. is there any way I can change them into Left Justified whenever required.


let' s get the terminology right ...
numbers are numbers, char-strings are char-strings

once that AS YOU SAY a number has been left justifies it is not a number any longer

but if You take the EDITED number, which at this point is just a string of characters
You can justify left the string

search the forum for examples

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 3:05 pm
by BillyBoyo
Again, please show some examples.

Show your input definition. Show sample values. Show the required output for the sample values.

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 3:42 pm
by nikesh_rai
Thanks Billy

Here is the list of values for example
WV55-INCLD-ALWC
7/PS           
(42-48)       
10-------------
***-CAPS OFF-*
              0
              0
        31.8200
              0
              0
        45.4600
        45.4600
              0
              0
              0
              0
        31.8200
              0
              0
              0
              0


I need to change their allingenment to left.. and the result should looks like

0
0
31.82
0
0
45.46
45.46
0
0
0
0
31.82
0
0
0
0


Code'd

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 3:55 pm
by BillyBoyo
You need to learn how to use the Code tags to preserve your spacing. If you want to see what I did, click on Quote on your post. You highlight the block and use the Code button on the full editor input screen. Use the Preview button to check it looks how you want.

Are all your values only a length of two for the integer part? What do you want 1.2100 to look like?

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 4:19 pm
by nikesh_rai
if the value is like
 
      0
      0
31.8200
      0
      0
45.4600
45.4600
      0
      0
 1.2100
      0


it should be displayed like

 
0
0
31.8200
0
0
45.4600
45.4600
0
0
1.2100
0

Re: Using Justified with Numeric field

PostPosted: Mon Dec 10, 2012 5:10 pm
by BillyBoyo
OK, so now things have changed. All you want to do his have the "zero" left-justified, leaving anything else as-is.

01  the-left-right-number.
    88  value-is-zero VALUE "      0".
    05  location-of-left-just-zero PIC X.
    05  space-for-left-just-zero.
        10  FILLER PIC X.
        10  FILLER PIC X.
            88  decimal-point-is-present VALUE ".".
        10  FILLER PIC X(03).
        10  right-just-zero PIC X.


EVALUATE TRUE
  WHEN value-is-zero
    MOVE right-just-zero TO location-of-left-just-zero
    MOVE SPACE TO space-for-left-just-zero
  WHEN decimal-point-is-present
    CONTINUE
  WHEN OTHER
    deal with an unexpected situation
END-EVALUATE