One of the most irritating limits in PL/I is the limitation of strings to be no more than 32767 bytes long. This is nothing in our modern times where almost all processors and operating systems uses 64 bits for addressing. So fra IBM has not done anything to remove or increase this limit. This tip will show you some tricks to get around this limit.
I want to create a CHAR(100000) variable in my program. This is not possible so instead I create an array consisting of 100000 elements where each element is a CHAR(1). The disadvantage is of course that I cannot use functions like SUBSTR on the array. But this problem has been solved by the PL/I team a long time ago by introducing the STRING function. Here is an example:
The first assigment statement works exactly as if myBigChar was declared as a normal CHAR(n) variable. All the remaining bytes are in other words filled with spaces. The second assigment statement takes advantage of the fact that myBigChar is declared as an array and assigns an asteriks to position 60000 in the string. Using the following index function the program locates the position of the asteriks. In your first attempt you will most likely receive a different result than the expected 60000. To acheive the correct result you must compile the program using compiler option BIFPREC(31). Use PROCESS for this. The last PUT SKIP LIST will print out the text: small.
As you might have guessed by now the trick is to use string(myBigChar) in those places where you normally would use myBigChar. Unfortunately the trick does not work if you try to use substr as pseudovariable. Concatenations beyond the first 32767 bytes does not work either, so there is still room for improvement.