I need help for a simple problem...



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

I need help for a simple problem...

Postby CMHOUSE2010 » Wed Nov 26, 2008 11:09 am

Hi!
I am working on a program called lookup and I have one error i cannot solve.

Here is the paragraph...
 001101  450-LOOKUP.
 001102      MOVE 1 TO HOLD-SUB
 001103      PERFORM
 001104          UNTIL HOLD-SUB > 8 OR LOOKUP-FLAG = 'YES'
 001105            IF DIV-MANAGER(HOLD-SUB) = HOLD-DIV
 001106                MOVE HOLD-DIV TO HEAD-CENTER
 001107                MOVE DIV-NAME(HOLD-SUB) TO HEAD-NAME
 001108                MOVE 9 TO HOLD-SUB
 001109            END-IF
 001110      END-PERFORM.

This is the error

   001101 450-LOOKUP.
   000247         001102     MOVE 1 TO HOLD-SUB
   000248         001103     PERFORM
   000249         001104         UNTIL HOLD-SUB > 8 OR LOOKUP-FLAG = 'YES'
   000250      1  001105           IF DIV-TABLE(HOLD-SUB) = HOLD-DIV

==000250==> IGYPS2120-S Expected a reference-modification specification but found ')' the IF
statement was discarded.

   000251      2  001106               MOVE HOLD-DIV TO HEAD-CENTER
   000252      2  001107               MOVE DIV-NAME(HOLD-SUB) TO HEAD-NAME
   000253      2  001108               MOVE 9 TO HOLD-SUB
   000254      1  001109           END-IF
   000255         001110     END-PERFORM.

Somebody tell me what am I doing wrong.

PS: Sorry how do you get the the print screen function to work?
CMHOUSE2010
 
Posts: 3
Joined: Wed Nov 26, 2008 11:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: I need help for a simple problem...

Postby dick scherrer » Wed Nov 26, 2008 11:57 am

Hello and welcome to the forum,

Sorry how do you get the the print screen function to work?
Do you mean to print on paper or to capture info to post here? If you want to post the content of part or all of a screen, it is best to use copy/paste and then use the "Code" tag (i've coded your initial post as a demonstration. To use the cCde tag, highlight the code and click Code (near the top of the Reply panel. You can also Preview to see how yor post will appear to the forum. When you are satisfied with how your post looks, click Submit.

You have 2 sets of the 450-lookup para. One says this: IF DIV-MANAGER(HOLD-SUB) = HOLD-DIV
the other says: IF DIV-TABLE(HOLD-SUB) = HOLD-DIV .
Is this as you intended or did something happen when the code was posted to the forum.

It may help if you post the data division code for DIV-MANAGER and DIV-TABLE.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: I need help for a simple problem...

Postby CMHOUSE2010 » Wed Nov 26, 2008 2:18 pm

You have 2 sets of the 450-lookup para. One says this: IF DIV-MANAGER(HOLD-SUB) = HOLD-DIV
the other says: IF DIV-TABLE(HOLD-SUB) = HOLD-DIV .


Whoops! sorry about that! I must have pulled from the wrong output file.
So lets start over. I have this paragraph

001101 450-LOOKUP.
001102 MOVE 1 TO HOLD-SUB
001103 PERFORM
001104 UNTIL HOLD-SUB > 8 OR LOOKUP-FLAG = 'YES'
001105 IF DIV-MANAGER(HOLD-SUB) = HOLD-DIV
001106 MOVE HOLD-DIV TO HEAD-CENTER
001107 MOVE DIV-NAME(HOLD-SUB) TO HEAD-NAME
001108 MOVE 9 TO HOLD-SUB
001109 END-IF
001110 END-PERFORM.

Everytime I compile, it throws an error stating that "IGYPS2120-S Expected a reference-modification specification but found ')' the IF
statement was discarded. "

I still cannot see what is wrong with this.
CMHOUSE2010
 
Posts: 3
Joined: Wed Nov 26, 2008 11:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: I need help for a simple problem...

Postby dick scherrer » Wed Nov 26, 2008 10:42 pm

Hello,

Without seeing the definitions, i can only guess that you have specified (hold-sub) on a field that is not within an occurs.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: I need help for a simple problem...

Postby CMHOUSE2010 » Thu Nov 27, 2008 6:21 am

dick scherrer wrote:Hello,

Without seeing the definitions, i can only guess that you have specified (hold-sub) on a field that is not within an occurs.


So you want to see the table I created ?
Very well then.

004900  01  SUBSCRIPTS                BINARY.                                 
005000      10  HOLD-SUB              PIC 9(02).                               
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007400  01  DIV-MANAGER.                                                   
007500      10  FILLER                PIC X(30) VALUE                         
007600          '010WILL SMITH'.                                               
007700      10  FILLER                PIC X(30) VALUE                         
007800          '020BOB COSTAS'.                                               
007900      10  FILLER                PIC X(30) VALUE                         
008000          '031MELINDA JACKSON'.                                         
008100      10  FILLER                PIC X(30) VALUE                         
008200          '040JOHNNY DEPP'.                                             
008300      10  FILLER                PIC X(30) VALUE                         
008400          '050HUGH LAUREY'.                                             
008500      10  FILLER                PIC X(30) VALUE                         
008600          '060ALEX HANDY'.                                               
008700      10  FILLER                PIC X(30) VALUE                         
008800          '070DAVID UMPHRESS'.                                           
008900      10  FILLER                PIC X(30) VALUE                         
009000          '080RICHARD CHAPMAN'.                                         
009100      10  FILLER                PIC X(30) VALUE                         
009200          '** INVALID COST CENTER **'.                                   
009300      10  FILLER                PIC X(30) VALUE                         
009400          '999*** FINAL TOTALS ***'.                                     
009500                                                                         
009600  01  DIVISION-TABLE            REDEFINES DIV-MANAGER.               
009700      10  DIVISION-SECTION      OCCURS 10 TIMES.                         
009800          15  HEAD-CENTER   PIC X(03).                               
009900          15  HEAD-NAME     PIC X(27).   
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
001101   450-LOOKUP.
001102         MOVE 1 TO HOLD-SUB
001103         PERFORM
001104         UNTIL HOLD-SUB > 8 OR LOOKUP-FLAG = 'YES'
001105             IF DIV-MANAGER(HOLD-SUB) = HOLD-DIV
001106                   MOVE HOLD-DIV TO HEAD-CENTER
001107                   MOVE DIV-NAME(HOLD-SUB) TO HEAD-NAME
001108                   MOVE 9 TO HOLD-SUB
001109              END-IF
001110         END-PERFORM.

// HOLD DIV IS A BREAK FIELD.
Soo... does this work for you?
CMHOUSE2010
 
Posts: 3
Joined: Wed Nov 26, 2008 11:01 am
Has thanked: 0 time
Been thanked: 0 time

Re: I need help for a simple problem...

Postby dick scherrer » Thu Nov 27, 2008 10:44 am

Hello,

Please review the code you posted and fix the inconsistencies. Also, practice using the Code tag to preserve the alignment of your posts.

You have done what i suspected when i posted the earlier reply. You have coded a subscript on a field that has only a single occurrence. You have coded no subscript on a field that is part of an occurs and requires asubscript.

DIV-MANAGER(HOLD-SUB) - div-manager is the level 01 and occurs 1 time - why is there a subscript? HEAD-NAME is in the aray and references to it require a subscript. The code has none.

Given that the array redefnies the individual values, you will not need/want to move the way you have. You will just reference the entry at the proper displacement.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post