Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field 
Author Message
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

I am reading a value from a line sequential file.
This file is a spreadsheet saved in CSV format so
the values I am reading are being disected and
then moved into a text field of PIC X(20).

The problem I am having is then moving the text
value into a signed field like PIC S9(8)V9(2)
COMP 3. Due to the way that cobol treats charater
fields its is being left justified instead of
right justified.

I have tried moving the text value into a field
defined as PIC ZZZZZZZ9.99- and then moving to
the signed field but when I do this I get 65976.00
instead of 657.76

Any pointers in the right direction would be
appreciated.

Regards
Craig

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sat, 03 May 2003 13:20:21 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
I am reading a value from a line sequential file.
This file is a spreadsheet saved in CSV format so
the values I am reading are being disected and
then moved into a text field of PIC X(20).

The problem I am having is then moving the text
value into a signed field like PIC S9(8)V9(2)
COMP 3. Due to the way that cobol treats charater
fields its is being left justified instead of
right justified.

I have tried moving the text value into a field
defined as PIC ZZZZZZZ9.99- and then moving to
the signed field but when I do this I get 65976.00
instead of 657.76

Any pointers in the right direction would be
appreciated.

Regards
Craig

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 03 May 2003 13:20:23 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

Quote:

>I am reading a value from a line sequential file.
>This file is a spreadsheet saved in CSV format so
>the values I am reading are being disected and
>then moved into a text field of PIC X(20).

>The problem I am having is then moving the text
>value into a signed field like PIC S9(8)V9(2)
>COMP 3. Due to the way that cobol treats charater
>fields its is being left justified instead of
>right justified.

>I have tried moving the text value into a field
>defined as PIC ZZZZZZZ9.99- and then moving to
>the signed field but when I do this I get 65976.00
>instead of 657.76

Craig,

Please give an example of the contents of the X(20) field

Willem Clements
Brainbench MVP for COBOL II
http://www.brainbench.com



Sat, 03 May 2003 15:31:16 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
Look at JUSTIFIED RIGHT to right align your field.
Clear out the spaces on the left with INSPECT-REPLACING.


Quote:
> I am reading a value from a line sequential file.
> This file is a spreadsheet saved in CSV format so
> the values I am reading are being disected and
> then moved into a text field of PIC X(20).

> The problem I am having is then moving the text
> value into a signed field like PIC S9(8)V9(2)
> COMP 3. Due to the way that cobol treats charater
> fields its is being left justified instead of
> right justified.

> I have tried moving the text value into a field
> defined as PIC ZZZZZZZ9.99- and then moving to
> the signed field but when I do this I get 65976.00
> instead of 657.76

> Any pointers in the right direction would be
> appreciated.

> Regards
> Craig

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
Craig,

Go here:

http://www.s390.ibm.com/bookmgr-cgi/bookmgr.cmd/BOOKS/IGYVA002/CCONTENTS

Look at paragraph 2.4.1.3.  It might be of help....

Cliff


Quote:
> I am reading a value from a line sequential file.
> This file is a spreadsheet saved in CSV format so
> the values I am reading are being disected and
> then moved into a text field of PIC X(20).

> The problem I am having is then moving the text
> value into a signed field like PIC S9(8)V9(2)
> COMP 3. Due to the way that cobol treats charater
> fields its is being left justified instead of
> right justified.

> I have tried moving the text value into a field
> defined as PIC ZZZZZZZ9.99- and then moving to
> the signed field but when I do this I get 65976.00
> instead of 657.76

> Any pointers in the right direction would be
> appreciated.

> Regards
> Craig

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

Quote:

>I am reading a value from a line sequential file.
>This file is a spreadsheet saved in CSV format so
>the values I am reading are being disected and
>then moved into a text field of PIC X(20).

>The problem I am having is then moving the text
>value into a signed field like PIC S9(8)V9(2)
>COMP 3. Due to the way that cobol treats charater
>fields its is being left justified instead of
>right justified.

Ummmmmm... before we go any further might you be so kind as to mention how
many years it has been since you started working as a COBOL programmer?

DD



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
Look at the NUMVAL function.  If you have an older compiler, recreate
the NUMVAL function.  I have done this in the past, and there are some
freely available code to do this (do a web search or wait for a more
knowledgeable reply)
Quote:

> I am reading a value from a line sequential file.
> This file is a spreadsheet saved in CSV format so
> the values I am reading are being disected and
> then moved into a text field of PIC X(20).

> The problem I am having is then moving the text
> value into a signed field like PIC S9(8)V9(2)
> COMP 3. Due to the way that cobol treats charater
> fields its is being left justified instead of
> right justified.

> I have tried moving the text value into a field
> defined as PIC ZZZZZZZ9.99- and then moving to
> the signed field but when I do this I get 65976.00
> instead of 657.76

> Any pointers in the right direction would be
> appreciated.

> Regards
> Craig

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field


Quote:
> Look at the NUMVAL function.  If you have an older compiler, recreate
> the NUMVAL function.  I have done this in the past, and there are some
> freely available code to do this (do a web search or wait for a more
> knowledgeable reply)

you could try:

http://www.etk.com/download/etkpak/etkpak.htm#GETNBR



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
<snip>
Quote:
> The problem I am having is then moving the text
> value into a signed field like PIC S9(8)V9(2)
> COMP 3. Due to the way that cobol treats charater
> fields its is being left justified instead of
> right justified.

<snip>

Ok, have you looked up JUST or JUSTIFIED?  You specify it after
the PIC clause of the TARGET field of the move.  Be careful with
this.  I suggest that you redefine the field for further
operations:

    05  Right-Just-Workarea       PIC X(10) JUST.
    05  Numeric-field-workarea    REDEFINES Right-Just-Workarea
                                  PIC S9(8)V9(2) DISPLAY.

     MOVE ????????? to Right-Just-Workarea.
     IF Right-Just-Workarea NUMERIC
        MOVE Numeric-field-workarea to [whatever numeric you
want]
     ELSE
        MOVE ZERO                   to [whatever numeric you
want]
     END-IF

Ok, perhaps that was overkill, but, you need to make sure that
you did get numeric data or you risk a PIC7 (S0C7 under
MVS-OS/390, and VSE/VM will give some type of DATA CHECK for
this).

Now, you did not say how you are pealing the CSV data apart.  I
must trust that this is being done properly.  But, are you aware
that you could have done this with a "variable" length move by
basing the size of the Receiving field on the number of
characters you obtained?  But this is another story.

One more thing:  How are you going to determine if this is a
negative number?
--
Steve Thompson
OSP LLC
330/335-9907 office
330/334-2097 fax

Remove "_" in email address to contact me -- anti-spam measures
in use



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field


Quote:
> > The problem I am having is then moving the text
> > value into a signed field like PIC S9(8)V9(2)
> > COMP 3. Due to the way that cobol treats charater
> > fields its is being left justified instead of
> > right justified.
> <snip>

> Ok, have you looked up JUST or JUSTIFIED?  You specify it after
> the PIC clause of the TARGET field of the move

this comes up about every six months. The JUST does *not*
right-justify the data within a data-item. What it does can be
illustrated by this:

02  AAA PIC X(20) JUST.
02  BBB PIC X(10).

MOVE "12345" TO BBB
MOVE BBB TO AAA

AAA now contains:
bbbbbbbbbb12345bbbbb
where "b" is a blank



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

Quote:


<snip>
> this comes up about every six months. The JUST does *not*
> right-justify the data within a data-item. What it does can be
> illustrated by this:

> 02  AAA PIC X(20) JUST.
> 02  BBB PIC X(10).

> MOVE "12345" TO BBB
> MOVE BBB TO AAA

> AAA now contains:
> bbbbbbbbbb12345bbbbb
> where "b" is a blank

Yes, but, if I did the whole assignment, what would one learn?
And I did leave a hint about variable length moves...

-
Steve Thompson
OSP LLC
330/335-9907 office
330/334-2097 fax

Remove "_" in email address to contact me -- anti-spam measures
in use



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

Quote:

> Please give an example of the contents of the X(20) field

> Willem Clements
> Brainbench MVP for COBOL II
> http://www.brainbench.com

Example of the file layout. Items on the right are the ones that I am
having trouble with ie 605.76, 121, -747.36 etc

80158962,605.76
50059349,121
80219910,-747.36
40022758,261.52

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field

Quote:

> Ummmmmm... before we go any further might you be so kind as to
mention how
> many years it has been since you started working as a COBOL
programmer?

> DD

Ummmmmmm.... Its been about 12 years since I studied Cobol at Uni but
don't you bother about replying as I can't stand a smart arse.

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field


Quote:


> > Look at the NUMVAL function.  If you have an older compiler,
recreate
> > the NUMVAL function.  I have done this in the past, and there are
some
> > freely available code to do this (do a web search or wait for a more
> > knowledgeable reply)

> you could try:

> http://www.etk.com/download/etkpak/etkpak.htm#GETNBR

Thankyou Howard, and Leif. You guidance is appreciated.

Sent via Deja.com http://www.deja.com/
Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 Moving a PIC X(20) to PIC S9(8)V9(2) COMP 3 field
If you don't want to hear the answer, then don't ask the question.


Quote:

> > Ummmmmm... before we go any further might you be so kind as to
> mention how
> > many years it has been since you started working as a COBOL
> programmer?

> > DD

> Ummmmmmm.... Its been about 12 years since I studied Cobol at Uni
but
> don't you bother about replying as I can't stand a smart arse.

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sat, 03 May 2003 03:00:00 GMT  
 
 [ 54 post ]  Go to page: [1] [2] [3] [4]

 Relevant Pages 

1. moving data from pic 99 to pic 99

2. Moving PIC X(06) to PIC 9(06)

3. Moving PIC X(06) to PIC 9(06)

4. moving in S9(7)V9(2) comp-3

5. PIC S9(9) V99 COMP-3

6. PIC S9(9) V99 COMP-3

7. Pic S9(4) Comp definition question.

8. PIC S9(4) COMP-5

9. PIC S9(x)V99

10. PIC 9(20)

11. PIC S9(6)V99 help please

12. HELP: Maximum size of PIC X fields ?

 

 
Powered by phpBB® Forum Software