0
votes

so I am just starting to learn COBOL on Z/OS. I have done quite a bit using visual cobol; however, this is still quite different.

I need to display a table starting at the Index of 1 and displaying until the index is 50

     PERFORM VARYING W03-SUBJ-INDX FROM 1 BY 1
 UNTIL W03-SUBJ-INDX = 50                 
 DISPLAY W03-SUBJ-TABLE                   
 END-PERFORM   

That is what I currently have I also tried

     PERFORM VARYING W03-SUBJ-INDX FROM 1 BY 1
 UNTIL W03-SUBJ-INDX = 50                 
 DISPLAY W03-SUBJ-TABLE(w03-subj-indx)                   
 END-PERFORM 

The top example displays only the first indexed item (To be expected) - The second example gives me an error stating ")" was unexpected.

Any help would be appreciated.. I was told I have to use the index

2
What is the Working-Storage definition of W03-SUBJ-TABLE ? - cschneid
The (To be expected) part is not really to be expected. Given that code fragment, the expectation is a display of the entire table group, 49 times. - Brian Tiffin
Without the working storage layout for this table we can't really help you. Also including the actually compile error would go a long way. - SaggingRufus
Also, are you supposed to DISPLAY index 50, or just 1 through 49? - SaggingRufus

2 Answers

0
votes

So regarding your existing code....there was some flakiness in some of the versions of the Enterprise Cobol parsers...

DISPLAY W03-SUBJ-TABLE(w03-subj-indx) 

might work as this:

DISPLAY W03-SUBJ-TABLE ( w03-subj-indx )

Some of the versions of the Enterprise Cobol compiler did not parse well without spaces. This was especially important when doing reference modification, but applied to tables as well.

Give it a try, YMMV.

0
votes

You don't mention which compiler version you are on, but there was once one -- and I can't remember the version -- that was flakey with subscripts verses reference modification.

Try plugging in some spaces:

DISPLAY W03-SUBJ-TABLE ( w03-subj-indx ) 

Also, make sure that W03-SUBJ-TABLE is the array, not a group item containing the array.