× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 10/06/2009, at 6:04 AM, Scott Lindstrom wrote:

My COBOL skills are quite a bit rusty and I have a production problem that
needs solving. I have an old COBOL program that is our ODBC/SQL log
program. It makes some references to some fields in QSYSINC/EZDAEP that
must have changed between V4R4 (the last time the program was compiled) and
V5R4 (the release we are on now).

This include changed at VRM450.

In 440 the structure for QZDA-NDB-FORMAT2 defined LIB-NAME as: OCCURS 00001 TIMES. In 450 and later it is commented out because it is a varying-length array (i.e., the number of elements varies according to the NBR-OF-LIBRARIES field value.

In 440 the structure for QZDA-SQL-FORMAT2 defined SQL-STATEMENT-TEXT as: PIC X(00001). In 450 and later it is commented out because it is a varying-length character field (i.e., its length is determined by the value of SQL-STATEMENT-TEXT-LEN.

Why did this happen? Because all the non-C language includes are generated from the C includes. They changed from initially defining the first element (or byte) of the field in 440 (and earlier) to simply commenting the existence of the field. The first form works very well in C because it has no concept of an array out-of-bounds error thus the programmer can reference an array element that was never defined (as long as sufficient storage exists for it). Because IBM code supplies the data structure to your exit program you can be sure (barring a defect in IBM code) that the structure is correctly populated thus if the structure says 7 libraries are in the list you can be sure that the structure has space for at least 7 libraries.

I think IBM stopped using this technique once structures started to have more than one varying-length field. Although the first such field would be correctly addressed by a structure defining only the first element or byte any subsequent varying-length fields would not be correctly addressed.

This change requires the programmer to use based storage to address the varying length fields.


First - I reference these fields:

LIB-NAME OF QZDA-NDB-FORMAT2 (1)
LIB-NAME OF QZDA-NDB-FORMAT2 (2)
LIB-NAME OF QZDA-NDB-FORMAT2 (3)
LIB-NAME OF QZDA-NDB-FORMAT2 (4)
LIB-NAME OF QZDA-NDB-FORMAT2 (5)

First question: How can you be sure there will only be at most 5 library names? The structure allows an open limit. Your code really needs to handle the actual number of libraries supplied.


This used to work but the copybook now is defined as:

05 NBR-OF-LIBRARIES PIC S9(00009) BINARY.
* Number of libraries in list
* 05 LIB-NAME PIC X(00010)
* OCCURS xxxxx TIMES.
* Varying number
* of library names

with LIB-NAME commented out. How can I readily access the first 'x' number
of occurrences of LIB-NAME (up to 5 of them) so I can move these fields to
the logfile record.

You will need to define your own array of library names and base it on a pointer. Set that pointer to the address of the structure plus the current length of the structure. Then process your array for as many elements as the NBR-OF-LIBRARIES filed says is supplied.


Second - I reference this field:
SQL-STATEMENT-TEXT OF QZDA-SQL-FORMAT2

which now is defined as:

05 SQL-STATEMENT-TEXT-LEN PIC S9(00009) BINARY.
* Length of SQL Stmt text
* 05 SQL-STATEMENT-TEXT PIC X(xxxxx).
* Varying length
* SQL statement text

Again, SQL-STATEMENT-TEXT is now commented out. How I can reference the
SQL-STATEMENT-TEXT?

Similar thing here. Define your own large field based on a pointer. Set the pointer to the address of the structure plus its current length. Limit your character processing to the number of bytes specified in SQL-STATEMENT-TEXT-LEN

TIA for pointing me in the correct direction,


Did that help?


Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.