View previous topic :: View next topic
|
Author |
Message |
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I have a varible WS-VAR which occurs 6 times declared as
01 WS-VAR pic S9(6) comp-3 occurs 6 times with field length 4
i am checking each digit in the ws-var whether it is zero or not by using refrence modification for the 6 occurences by using
Code: |
PERFORM PARA-A VARYING A-READ FROM 1 BY 1 UNTIL A-READ > 6.
PARA-A.
PERFORM VARYING A-ZERO-CHECK FROM 1 BY 1
UNTIL A-ZERO-CHECK > 4
IF WS-VAR(A-READ(A-ZERO-CHECK:1)) = 0
WS-COUNTER = WS-COUNTER + 1
END-IF
END-PERFORM
IF WS-COUNTER < 4
PERFORM S3040-WRITE-PARA. |
At the time of compilation i got the Severe error as below
A subscript or index was subscripted, indexed or reference modified. The statement was discarded. for the line
IF WS-VAR(A-READ(A-ZERO-CHECK:1)) = 0
could you please let me know the statment is coded corretly or not.
Thanks
suneel
Edited: Please use BBcode when You post some code/error, that's rather readable, Thanks... Anuj |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Shouldn't that be something more like: WS-VAR (A-READ) (A-ZERO-CHECK:1)?
And shouldn't the check be "= X'00'"? |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I have coded like below
WS-VAR(A-READ) (A-ZERO-CHECK:1) EQUAL TO ZERO
At that time i got the severe error like below
Reference-modified data item "WS-VAR" was not defined with "USAGE
DISPLAY", "USAGE DISPLAY-1" or "USAGE NATIONAL". The statement was discarded.
Please let me know how to resolve this error., the WS-VAR is comp-3 variable.
Thanks
Suneel |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
What is the definition for WS-VAR? |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Below is the declaration of WS-VAR
01 WS-VAR pic S9(6) comp-3 occurs 6 times
Thanks
Suneel |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Thnaks, but how i can do refrence modification this, to check each digit in the field as zero or not.
Thanks
suneel |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Define WS-VAR without the comp-3. |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
suneelv wrote: |
Hi,
Below is the declaration of WS-VAR
01 WS-VAR pic S9(6) comp-3 occurs 6 times
Thanks
Suneel |
You cannot use OCCURS clause at 01 level. OCCURS clause is for table/subordinate entries.
And when you use a COMP-3 field, it is advisable to us odd number of digits in PICTURE definition for efficiency.
[/url] |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Sorry the occurs clause is not in 01 level
But as per the requirement the field is Comp-3 and i need to check the each digit of the field whether it is zero or non zero.
Regards
Suneel |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
Could you post some sample data as well.
After each iteration move packed decimal field to numeric.
then use reference-modification. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
This is the new requirement for me i need to enter the data and for my testing.
Thanks
Suneel |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
well each comp-3 field contains:
unused half-byte used half-byte-1 / used half-byte-2 used half-byte-3/used half-byte-4 used half-byte-5/used half-byte-6 sign half-byte/
only the second and third byte can be checked for x'00'.
the last can be checked for x'0C'.
the first must be unpacked and the second byte of the unpacked field checked for 0.
it can be argued that the left side of the higher byte of an even numbered packed-decimal field will always be b'0000', but I don't think the documentation explicitly says so.
actually, this is a very poor exercise for reference modification. probably dreamed up by the same idiot mentality that provides interview questions. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
suneelv wrote: |
i need to check the each digit of the field whether it is zero or non zero. |
If this is your requirement, then you cannot check directly into the COMP-3 field,
because each byte contains 2 digits (except last byte, of course).
As leo_sangha suggested, move COMP-3 field to DISPLAY field, then use reference modification to check each digit (which is then one digit per byte). |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Thanks for all your suggestions , moving comp-3 to DISPLAY field and doing the refrence modification and move back again to comp-3 field.
Thanks
Suneel |
|
Back to top |
|
|
leo_sangha
New User
Joined: 11 Aug 2005 Posts: 85 Location: England
|
|
|
|
hello suneelv,
are you saying that you're moving back numeric field back to comp-3 for output ?
you already have comp-3 field in WS-VAR(A-READ), |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Thanks for all your suggestions , moving comp-3 to DISPLAY field and doing the refrence modification and move back again to comp-3 field.
|
Time to back up and think about what you are doing . . .
If you move the comp-3 field to a display field and the comp-3 field is not numeric, you will probably get an 0c7 before you ever have a chance to check the digits.
Why are you trying to check individual digits of a comp-3 number? This is not how things are normally done If some comp-3 field needs to be checked for numeric, simply code "IF COMP-3-FLD NOT NUMERIC. . .".
Possibly there is something i am missing. . . |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I think this is homework. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
Suneel,
Your indentation makes your code difficult to follow. Maybe that was caused by the retrofitting of BBCode, but at any rate, I think you want something like the following which is untested due to non-access to a mainframe:
Code: |
01.
05 WS-VAR OCCURS 6 TIMES
INDEXED BY WS-INDEX
PIC S9(6) COMP-3.
05 WS-VAR-DISPLAY PIC 9(6).
SET WS-INDEX TO 1
PERFORM PARA-A 6 TIMES
.
PARA-A.
MOVE WS-VAR (WS-INDEX) TO WS-VAR-DISPLAY
IF WS-VAR-DISPLAY > 99
PERFORM S3040-WRITE-PARA
END-IF
SET WS-INDEX UP BY 1
. |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
suneelv wrote: |
Hi,
Thanks for all your suggestions , moving comp-3 to DISPLAY field and doing the refrence modification and move back again to comp-3 field.
Thanks
Suneel |
Sorry for the delay: no, if you don't change the value, you don't need to move it back. |
|
Back to top |
|
|
|