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

INPUT-INDEX Syntax Error IGYPA3074-S


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

New User


Joined: 13 Oct 2007
Posts: 19
Location: Fort Worth, Tx USA

PostPosted: Tue Nov 23, 2010 7:37 am
Reply with quote

What is wrong with this?

The error message is:
"INPUT-INDEX (INDEX NAME)" WAS NOT NUMERIC, BUT WAS A SENDER IN AN ARITHMETIC EXPRESSION. THE STATEMENT WAS DISCARDED."

The variables are:
Code:
01  INPUT-RECORD.                                     
    05  INPUT-CHAR              OCCURS 80 TIMES       
                                INDEXED BY INPUT-INDEX
                                PIC X(01).           
01  FILLER                      REDEFINES INPUT-RECORD
                                PIC X(01).           
    88  INPUT-RECORD-IS-A-COMMENT          VALUE '*'.     



The statement where the error occurs is:
Code:
SEARCH INPUT-CHAR                                         
       AT END MOVE LIT-1 TO LIT-1                         
       WHEN INPUT-CHAR (INPUT-INDEX) = 'A'                 
       AND  INPUT-CHAR (INPUT-INDEX + 1) = 'P'             
       AND  INPUT-CHAR (INPUT-INDEX+2) = 'P'               
       AND  INPUT-CHAR (INPUT-INDEX+3) = 'L'               
       AND  INPUT-CHAR (INPUT-INDEX+4) = 'C'               
       AND  INPUT-CHAR (INPUT-INDEX+5) = 'T'               
       AND  INPUT-CHAR (INPUT-INDEX+6) = 'N'               
       AND  INPUT-CHAR (INPUT-INDEX+7) = ' '               
       AND  INPUT-INDEX + 7 < 72                           
            PERFORM ..... etc etc etc
The error points to here:
WHEN INPUT-CHAR (INPUT-INDEX) = 'A'

I do not see "it"???
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Nov 23, 2010 9:10 am
Reply with quote

Hello,

Suggest you learn how to use the "Code" tag - this will preserve alignment and improve readability. Your post has been "Code'd".

Change this:
Code:
01  INPUT-RECORD.                                     
    05  INPUT-CHAR              OCCURS 80 TIMES       
                                INDEXED BY INPUT-INDEX
                                PIC X(01).   
to this:
Code:
01  INPUT-RECORD.                                     
    05  INPUT-CHAR              OCCURS 80 TIMES       
                                INDEXED BY INPUT-INDEX.
        10 MYCHAR               PIC X(01).   
Back to top
View user's profile Send private message
luis_pr

New User


Joined: 13 Oct 2007
Posts: 19
Location: Fort Worth, Tx USA

PostPosted: Wed Nov 24, 2010 3:48 am
Reply with quote

Thanks for the info, dick scherrer. By the way, the source code changes that you mention... from the "change this" section to the "to this" section.... were they meant to suggest that they would correct my problem? It did not look to me as if they would but I tried and still had same the error.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Nov 24, 2010 3:58 am
Reply with quote

luis_pr wrote:
What is wrong with this?

AND INPUT-INDEX + 7 < 72


INPUT-INDEX is an index and you can not add to it, you could use
Code:
and input-index < 65
for the same results.
Back to top
View user's profile Send private message
luis_pr

New User


Joined: 13 Oct 2007
Posts: 19
Location: Fort Worth, Tx USA

PostPosted: Wed Nov 24, 2010 4:13 am
Reply with quote

OMG, Craq Giegerich. Yes, that was it but for some reason the compiler generated the error message against all the lines in the WHEN Statement instead of just against that one condition. Ooooh, weeeeell. Thanks and Happy Thanksgiving everyone!
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Wed Nov 24, 2010 4:18 am
Reply with quote

Hello,

I knew i should have waited until i could actually test this before posting icon_redface.gif

This much compiles clean (using your original code).
Code:
           SEARCH INPUT-CHAR                                           
              AT END DISPLAY 'END'                                     
              WHEN INPUT-CHAR (INPUT-INDEX) = 'A'                       
                     AND  INPUT-CHAR (INPUT-INDEX + 1) = 'P'           
                   DISPLAY 'A'.                                                           


This generates the error:
Code:
           SEARCH INPUT-CHAR                                   
              AT END DISPLAY 'END'                             
              WHEN INPUT-CHAR (INPUT-INDEX) = 'A'               
                     AND  INPUT-CHAR (INPUT-INDEX + 1) = 'P'   
                     AND  INPUT-INDEX + 7 < 72                   
                   DISPLAY 'AP'.         

34 IGYPA3074-S "INPUT-INDEX (INDEX NAME)" was not numeric, etc...

Which makes sense now that i look at it closer. . . The expression can be used as the index, but not as it is used in this statement.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Nov 24, 2010 2:27 pm
Reply with quote

Alternative to hard-coded max test, providing that INPUT-INDEX must be less than the maximum-array occurs, minus 15 -

Code:

03  WS-MAX-SUB PIC 9(08) COMP.
03  WS=FWORD PIC 9(08) COMP.
03  WS-MAX-INDEX INDEX.

DIVIDE LENGTH OF INPUT-RECORD BY LENGTH OF INPUT-CHAR (1) GIVING WS-MAX-SUB.
SUBTRACT 15 FROM WS-MAX-SUB GIVING WS-FWORD.
SET  INPUT-INDEX TO WS-FWORD.
SET  WS-MAX-INDEX TO INPUT-INDEX.
SET  INPUT-INDEX TO 1.

Then, substitute -

Code:

and input-index < 65

with -

Code:

and input-index < ws-max-index

Bill
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Error when install DB2 DB2 2
Search our Forums:

Back to Top