Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Printed Output in RPG with X'00'
has no ratings.
Published: 23 Apr 2012
Revised: 23 Jan 2013 - 1520 days ago
Last viewed on: 22 Mar 2017 (3302 views) 

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.

Printed Output in RPG with X'00' Published by: Bob Cozzi on 23 Apr 2012 view comments(7)

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.

Example 1: Normal Output

*... 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".

Example 2: Output with the "NAME" Field containing all X'00'

*... 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".

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 29 days 22 hours 23 minutes ago

What happens if there are normally 2 literal spaces between <name field> and from Chicago?

Posted by: clbirk
Premium member *
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 29 days 21 hours 37 minutes ago

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 ...

 

 

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 29 days 16 hours 25 minutes ago

I thought of that too, but iSeries Navigator also shows it shifted...

Posted by: DaleB
Premium member *
Reading, PA
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 29 days 1 hours 4 minutes ago

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.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 25 days 23 hours 12 minutes ago

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.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 25 days 23 hours 4 minutes ago
Edited: Fri, 27 Apr, 2012 at 10:02:56 (1791 days ago)

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 

 

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Printed Output in RPG with X'00'
Posted: 4 years 10 months 25 days 22 hours 46 minutes ago
Edited: Fri, 27 Apr, 2012 at 10:20:49 (1791 days ago)

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.