Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Error At the time of Using PERFORM and Refrence Modification

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Error At the time of Using PERFORM and Refrence Modification
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: 2150
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 11:31 am    Post subject:
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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: 2150
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 12:29 pm    Post subject:
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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: 2150
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 1:06 pm    Post subject:
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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: 2150
Location: At my coffee table

PostPosted: Tue Apr 07, 2009 1:47 pm    Post subject:
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    Post subject: Re: Reply to: Error At the time of Using PERFORM and Refrenc
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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: 6970
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 4:40 pm    Post subject:
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: 1247
Location: Israel

PostPosted: Tue Apr 07, 2009 4:41 pm    Post subject: Re: Reply to: Error At the time of Using PERFORM and Refrenc
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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    Post subject: Reply to: Error At the time of Using PERFORM and Refrence Mo
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

Site Director


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

PostPosted: Tue Apr 07, 2009 9:19 pm    Post subject:
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: 6970
Location: porcelain throne

PostPosted: Tue Apr 07, 2009 9:33 pm    Post subject:
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: 1249
Location: Richfield, MN, USA

PostPosted: Tue Apr 07, 2009 10:03 pm    Post subject:
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: 1247
Location: Israel

PostPosted: Sun Apr 19, 2009 8:19 pm    Post subject: Re: Reply to: Error At the time of Using PERFORM and Refrenc
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Comparision with current time arunsoods DFSORT/ICETOOL 5 Thu Nov 09, 2017 10:37 am
This topic is locked: you cannot edit posts or make replies. Comparing current time with the time ... arunsoods SYNCSORT 1 Mon Oct 30, 2017 4:07 pm
No new posts -502 Error - Cursor already open anand jeyapaul DB2 7 Sun Oct 29, 2017 4:22 am
This topic is locked: you cannot edit posts or make replies. Incrementing current time field by 30... arunsoods DFSORT/ICETOOL 11 Thu Oct 26, 2017 3:22 pm
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us