View previous topic :: View next topic |
Author |
Message |
ruisim Beginner
Joined: 03 Mar 2005 Posts: 2 Topics: 1
|
Posted: Thu Mar 03, 2005 7:35 pm Post subject: different length |
|
|
Hi.
I have to move one pic s9(8 ) comp with the value that can vary from 108 to 24000, to s9(4) comp.
How I can move + of 9999 for s9(4) comp?
(I cannot modify s9(4) comp)
Thanks.
Rui Simoes |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Fri Mar 04, 2005 10:36 am Post subject: |
|
|
ruisim, Quote: |
How I can move + of 9999 for s9(4) comp?
|
An item defined as S9(1) through S9(4) COMP is stored as binary halfword(2 bytes) which can store values in range of -32768 through +32767
An item defined as S9(5) through S9(9) COMP is stored as binary fullword(4 bytes) which can store values in range of -2,147,483,648 through +2,147,483,647
Programs compiled with TRUNC(STD) will only let you store a max value of 9999 in a 2 byte binary field.
With TRUNC(BIN) Compiler option you can store up to 32767 in a 2 byte binary field.
So all you need is to add the following statement as the first line in your program
And check this link for a detailed explanation of the TRUNC compiler option.
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/2.4.52?DT=20020923143836
Example pgm with TRUNC(BIN)
Code: |
CBL TRUNC(BIN)
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-NUM PIC S9(04) COMP.
PROCEDURE DIVISION.
MOVE 32767 TO WS-NUM
DISPLAY 'THE NUM VALUE: ' WS-NUM
GOBACK.
|
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
ruisim Beginner
Joined: 03 Mar 2005 Posts: 2 Topics: 1
|
Posted: Mon Mar 07, 2005 6:43 pm Post subject: |
|
|
Thanks, it's working. |
|
Back to top |
|
|
|
|