ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Issues displaying records column wise using printer file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues displaying records column wise using printer file

    I have a file that has (say 12 records). I have to read 12 records and arrange them as 3 columns with 4 records per column.
    I have defined report structure like below -
    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

    Program logic:
    C Eval Cnt = 1
    C Read File
    C Dow not %eof
    C If %Rem(Cnt:3) = 1
    C Eval FLDN1 = GLFLDN
    C Eval FLDD1 = GLFLDD
    C EXCEPT DESC1
    C ElseIf %Rem(Cnt:3) = 2
    C Eval FLDN2 = GLFLDN
    C Eval FLDD2 = GLFLDD
    C EXCEPT DESC2
    C Else
    C Eval FLDN3 = GLFLDN
    C Eval FLDD3 = GLFLDD
    C EXCEPT DESC3
    C EndIf
    C Eval Cnt = Cnt + 1
    C Read File
    C EndDo
    Issue:
    First and second record gets written in proper order. When it comes to third record, it goes to next line. What is the reason for the same?

  • #2
    Look at the skip/space before/after on the O spec exception line.

    Also, "If %Rem(Cnt:3) = 1" is convoluted. Why not just "If Cnt = 1" or "If Cnt = 2" etc?

    Comment

    Working...
    X