Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
I have observed a "new to me" issue in RPG. I first observed it in RPG IV and thought it was a bug in the compiler, but RPGIII does the identical thing. After talking with the IBM Canada RPG IV developers, the speculation is that it is a PRINTER file issue. Here's the summary:
When multiple fields (5 in our example) are output using Output Specs in RPG to a PRINTER file, such as QPRINT, if all 5 fields have data or blanks in them, the output is as expected.
However, if field 3 contains all X'00' characters then the output that is produced is shifted to the left. That is field's 4 and 5 are shifted to the left on top of field 3, beginning with position 2 of field 3.
*... v ...1 ...|... 2 ...v... ! ...v... 4 .!.v... ! ...v... 6 !..v... 7 Hello World My Name is Bob Cozzi from Chicago IL
Note that I inserted bars above each field's start position as a "field marker".
*... v ...1 ...|... 2 ...v... ! ...v... 4 .!.v... ! ...v... 6 !..v... 7 Hello World My Name is from Chicago IL
Note that the values "from Chicago" and "IL" have been shifted to the left over top of the NAME field's positions in the output line. They are actually overlaying position 2 of the name field. My assumption is that PRINTER support is looking at "null terminators" (a C language term) and causing this type of screw up.
Too bad we no longer have access to a real AS/400 (CISC processor) to see if the old compilers actually did the same thing. Because without proof that it is a bug, it will no doubt become a "feature".
What happens if there are normally 2 literal spaces between <name field> and from Chicago?
Are you phyiscally sure it is moving? That it is not your "display" emulator doing such?
What I mean by that is if I have in telnet/5250 client a field that is hex 00, it simply ignores and shifts to the left. But in reality it is really there.
You may need to copyprt to a diskfile and use wrkf to do a hex look and see if it is really there but ...
I thought of that too, but iSeries Navigator also shows it shifted...
Might help if you showed some DDS, or is this program-described? Either way, I tend to use fixed output columns, rather than the +n thing, which might solve this for you.
Dale, the +n thing is supposed to convert it into the same output as "ending position" notation does. In other words, it shouldn't matter. I can stub out a simply example to reproduce the issue and post it in a follow up message here.
Here is the RPGIII example that does the shifting on my v7.1 system.
To test RPG IV, just use IBM's CVTRPGSRC command to move it to RPG IV and recompile it with a different name.
.....H FQPRINT O F 132 OV PRINTER IOD DS I 1 10 OBJ I 11 20 LIB I 21 30 TYPE I 31 46 TEXT C MOVE *ON *INLR * C MOVEL'PGM0100' OBJ C MOVEL'QGPL' LIB C MOVEL'*PGM' TYPE C MOVEL'TEST PGM'TEXT C EXCPTDETAIL * C MOVEL'PGM0300' OBJ C MOVEL'QUSRSYS' LIB C MOVEL*ALLX'00' TYPE C MOVEL'This is 'TEXT C MOVE 'the text'TEXT C EXCPTDETAIL OQPRINT E 1 DETAIL O OBJ + 1 O LIB + 1 O TYPE + 1 O TEXT + 1
So the display is treating x'00' as null and suppresses it from the line, so you end with the leading space and trailing space literals only. And I would guess that if you had absolute line position declared rather than just +1, the text field would place correctly. Since I almost always use absolute spacing on print files and display files, this is not an issue I think I've ever encountered.
And on Personal Communications iSeries Access for Windows Workstation Program Version 5.8 for Windows - in 25 x 132 it looks ok to me no suppression of the x'00' here. I don't have a local printer that I'm set up to use.