IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Error At the time of Using PERFORM and Refrence Modification


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 11:08 am
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 11:31 am
Reply with quote

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
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 12:20 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 12:29 pm
Reply with quote

What is the definition for WS-VAR?
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 12:34 pm
Reply with quote

Hi,

Below is the declaration of WS-VAR

01 WS-VAR pic S9(6) comp-3 occurs 6 times

Thanks
Suneel
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 1:06 pm
Reply with quote

data-name-1 (leftmost-character-position:length)
data-name-1 must reference a data item described explicitly or implicitly with usage DISPLAY, DISPLAY-1, or NATIONAL.

Note the difference between Computational items and Display items...
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 1:37 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 1:47 pm
Reply with quote

Define WS-VAR without the comp-3.
Back to top
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 3:58 pm
Reply with quote

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
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 4:04 pm
Reply with quote

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
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 4:16 pm
Reply with quote

Could you post some sample data as well.

After each iteration move packed decimal field to numeric.
then use reference-modification.
Back to top
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 4:24 pm
Reply with quote

Hi,

This is the new requirement for me i need to enter the data and for my testing.

Thanks
Suneel
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 4:40 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Apr 07, 2009 4:41 pm
Reply with quote

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
View user's profile Send private message
suneelv

New User


Joined: 26 Aug 2008
Posts: 52
Location: inida

PostPosted: Tue Apr 07, 2009 5:23 pm
Reply with quote

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
View user's profile Send private message
leo_sangha

New User


Joined: 11 Aug 2005
Posts: 85
Location: England

PostPosted: Tue Apr 07, 2009 6:05 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Apr 07, 2009 9:19 pm
Reply with quote

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 icon_confused.gif 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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 9:33 pm
Reply with quote

I think this is homework.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1248
Location: Richfield, MN, USA

PostPosted: Tue Apr 07, 2009 10:03 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Apr 19, 2009 8:19 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Help on IMS -API URL migrating from P... IMS DB/DC 1
No new posts JES datasets IO Error ABENDS & Debugging 3
No new posts Error to invoke MPP program through B... IMS DB/DC 3
No new posts PKZIP error ZPFM121E and ZPCE009E JCL & VSAM 6
No new posts OpenPGP Decryption job getting LRECL ... IBM Tools 7
Search our Forums:

Back to Top