On 18 Jul 2013 05:09:46 -0700, in bit.listserv.ibm-main you wrote: >First, and not meaning to come across as nasty, you need to learn IBM >COBOL. This is a very basic question. > >You need to read about and understand the COBOL compile option TRUNC. >http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG31/2.4.53 ><quote> >*TRUNC(BIN)* The TRUNC(BIN) option applies to all COBOL language that >processes USAGE BINARY data. When TRUNC(BIN) is in effect, all binary items >(USAGE COMP, COMP-4, or BINARY) are handled as native hardware binary >items, that is, as if they were each individually declared USAGE COMP-5: > > > - BINARY receiving fields are truncated only at halfword, fullword, or > doubleword boundaries. > > - BINARY sending fields are handled as halfwords, fullwords, or > doublewords when the receiver is numeric; TRUNC(BIN) has no effect when > the receiver is not numeric. > > - The full binary content of fields is significant. > > - DISPLAY will convert the entire content of binary fields with no > truncation. > > > *Recommendations:* TRUNC(BIN) is the recommended option for programs that >use binary values set by other products. Other products, such as IMS, DB2, >C/C++, FORTRAN, and PL/I, might place values in COBOL binary data items >that do not conform to the PICTURE clause of the data items. You can use >TRUNC(OPT) with CICS programs as long as your data conforms to the >PICTUREclause for your >BINARY data items.
Wile all bets are off if we are talking about 5.1, TRUNC(OPT) will work fine if you understand the following rules. 1. The value clause will be limited by the picture thus PIC S9(4) can not have a value 10,000 even though a half word can handle it. 2. Any move to or from a USAGE BINARY field to either USAGE DISPLAY or USAGE PACKED-DECIMAL will be based on picture with this also holding true for mixed operands in an arithmetic operation. 3. MOVEs and Arithmetic operations involving only USAGE BINARY fields and no literal will be based on word size. This means that S9(4) BINARY fields can have plus or minus 16 kibi in them while S9(9) BINARY fields can have plus or minus 2 gibi in them. They can be converted to other USAGEs by first moving the S9(4) BINARY field to an S9(9) BINARY field and the S9(9) BINARY field to a S9(10) BINARY field. Clark Morris > >USAGE COMP-5 has the effect of applying TRUNC(BIN) behavior to individual >data items. Therefore, you can avoid the performance overhead of using >TRUNC(BIN) for every binary data item by specifying COMP-5 on only some of >the binary data items, such as those data items that are passed to >non-COBOL programs or other products and subsystems. The use of COMP-5 is >not affected by the TRUNC suboption in effect. > > *Large* *literals* *in* *VALUE* *clauses:* When you use the compileroption >TRUNC(BIN), numeric literals specified in VALUE clauses for binary data >items (COMP, COMP-4, or BINARY) can generally contain a value of magnitude >up to the capacity of the native binary representation (2, 4, or 8 bytes) >rather than being limited to the value implied by the number of 9s in the >PICTURE clause. ></quote> > > >Or you need to change the definition from COMP to COMP-5 >http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR31/5.3.17.1 ><quote> >*COMPUTATIONAL-5**or* *COMP-5* *(native* *binary)* These data items are >represented in storage as binary data. The data items can contain values up >to the capacity of the native binary representation (2, 4 or 8 bytes), >rather than being limited to the value implied by the number of nines in >the picture for the item (as is the case for USAGE BINARY data). When >numeric data is moved or stored into a COMP-5 item, truncation occurs at >the binary field size rather than at the COBOL picture size limit. When a >COMP-5 item is referenced, the full binary field size is used in the >operation. > >The TRUNC(BIN) compiler option causes all binary data items (USAGE BINARY, >COMP, COMP-4) to be handled as if they were declared USAGE COMP-5. > > ></quote> > >On Thu, Jul 18, 2013 at 6:52 AM, Ron Thomas <[email protected]> wrote: > >> Hello. >> >> We have a field defined S9(04) COMP , the value that is getting populated >> to this field from programs is defined as 9(04) so that works fine >> >> Now we want the data of length 5 bytes to be moved 28281, but less than >> 32781 which is maximum that s9(04) comp holds. Kindly let me know do we >> need to change the defintion of S9(04) COMP. >> >> >> Thanks, >> Ron T >> >> ---------------------------------------------------------------------- >> For IBM-MAIN subscribe / signoff / archive access instructions, >> send email to [email protected] with the message: INFO IBM-MAIN >> ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
