Page 1 of 1

soc7 help

PostPosted: Fri Feb 26, 2010 11:39 am
by mainframe1
WS-SRX-TST      PIC S9(8)V9(3).

WS-NEW-RX                   PIC X(12).           
WS-SRX  REDEFINES WS-NEW-RX     PIC S9(8)V9(3). 

 RX1                      PIC X(6).       
 WS-SRX1   REDEFINES RX1      PIC V9(5). 

COMPUTE  WS-SRX-TST = WS-STRX * WS-SRX1 (WS-FACT) 

Re: soc7 help

PostPosted: Fri Feb 26, 2010 5:57 pm
by Anuj Dhawan
Per you definitions, WS-SRX1 is not a COBOL-table variable so why do yo use the subscript (WS-FACT)? What is the WS-STRX has?

Re: soc7 help

PostPosted: Fri Feb 26, 2010 6:06 pm
by Robert Sample
WS-NEW-RX                   PIC X(12).           
WS-SRX  REDEFINES WS-NEW-RX     PIC S9(8)V9(3). 
Problem 1: your WS-NEW-RX is 12 bytes long. You redefine it as an 11-byte field. Any calculations you do with WS-SRX are, by definition, not going to include the entire value of WS-NEW-RX. The same applies to your WS-SRX1 field. USAGE DISPLAY fields such as you've defined overlay the sign on the last byte of the field, which means your value will be --odd -- to say the least.

Problem 2: the picture X fields may have any data -- numeric or not. Where is your logic to verify that the redefined fields actually have numbers in them before you attempt to use them for arithmetic?

Problem 3: as alluded, if WS-SRX1 is not part of a table, why are you subscripting it?

Problem 4: your code snippet references variables whose definition you did not provide (wuch as WS-FACT) -- why?