AS/400 printer file – record automatically moves to next line

105 pts.
Tags:
AS/400
DDS
DDS printing
I am trying to read a file containing 12 records and want to display in spool file as 4 rows and 3 columns. First record and second record are written properly (into 1st and 2nd columns of first line) however, third record automatically moves to second line (3rd column):
Printer file code:
O          E            DESC1       2                      
O                        FLDN1                4             
O                        FLDD1               25             
O          E            DESC2                              
O                        FLDN2               28             
O                        FLDD2               49             
O          E            DESC3                              
O                        FLDN3               52             
O                        FLDD3               73             
RPGLE Code:
C                   Eval       Cnt = 1
C                   Read      File1
C                   Dow       not %eof
C                   If            %Rem(Cnt:3) = 1
C                   Eval      FLDN1 = Val_N
C                   Eval      FLDD1 = Val_D
C                   EXCEPT    DESC1
C                   ElseIf    %Rem(Cnt:3) = 2
C                   Eval      FLDN2 = Val_N
C                   Eval      FLDD2 = Val_D
C                   EXCEPT    DESC2
C                   Else
C                   Eval      FLDN3 = Val_N
C                   Eval      FLDD3 = Val_D
C                   EXCEPT    DESC3
C                   EndIf
C                   Eval      Cnt = Cnt + 1
C                   Read     File1
C                   EndDo

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • azohawk

    In your O specs, specify space before and after as 0 for DESC2 and DESC3. Not sure if that will fix the issue, it has been a very long time since I have written O specs, but for some reason I am recalling that if not specified default is 1 after.

    I would make the output all one record that is only printed when cnt = 3 and after the loop if the last record did not print. Unless you have a reason to keep the cnt after 3, I would consider resetting it. Even if I needed cnt value, I would use a value for the column no and reset back to 1 if it exceeds 3  (i.e. col# += 1;  if col# > 3; col# = 1; endif;  this would make you code more straightforward to someone else needing to work on it.

    2,745 pointsBadges:
    report
  • sri8707
    Hi azohawk, appreciate your reply on this. 
    Setting space before and after DESC2 and DESC3 as 0, worked :)

    105 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: