ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problems with Packed fields

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

  • Problems with Packed fields

    I am having touble working with packed data fields. I am writing a simple file maintenance program. This program uses a program described file that has a packed field in it. When I try to change the value of this field from say 600 to 500, it gives me a data decimal error. It is blowing up when I write this change to the file. Here are my I and O specs (spacing not correct)

    I P 292 293 0DCTY
    O DCTY 293P

    And in my progam I do a simple MOVE and Except
    MOVE val1 val2
    Except
    How do you write fields to files in a packed format?

    Thanks, Jane22

  • #2
    Re: Problems with Packed fields

    As far as I know (not current on RPG/RPGII)
    But There should be no issue moving data from one packed field
    to another.


    Instead of a move Y not TRY Z-ADD
    Are you sure that the field DCTY is the problem?
    Could it be a different in the EXCEPT (Not sure if there are other fields)

    Whats in Val1

    To test I would first just say

    DCTY ADD 1.
    EXCEPT

    I found a working program (dont ask where)
    Code:
         H      14                                                            SBIL08
         FRBLL    IP  F 256 256            DISK
         FBLL     UC  F 256 256R           DISK
         IRBLL    NS  01 256 C1
         I        NS  04 256 C4
         I       OR   05 256 C5
         I                                    P 196 1980QTY
         I                                      120 126 PMRK  L1
         I                                       51  71 A     L2
         I                                       84  90 B     L2
         I                                      127 165 CM    L2        11
         I                                       77  83 TWDTH L3
         I                                        7  20 CODE  L4
         I                                      238 238 SRTCD L5
         I                                      246 2470ITMK  L5
         I                                      204 206 HPP   L5
         I                                      252 255 SEQ   L6
         IBLL     NS  08
         C* COUNT LINES OF PRINT PER SECTION AND TOTAL QUANTITY PER ITEM
         C* AND OUTPUT TO FIRST RECORD OF SECTION/ITEM RESPECTFULLY
         C         01          Z-ADD0         NUM     30
         C           COUNT     ADD  1         COUNT   50
         C        N01QTY       ADD  TQTY      TQTY    50
         C     N11N01          SETON                     15
         C      L4             Z-ADDCOUNT     CONT    50
         C      L2             Z-ADDCOUNT     CNT     50
         C      L1   MARK      ADD  1         MARK    30
         CL2         CNT       CHAINBLL                  10
         CL2         MARK      SUB  1         MARK
         CL2         MARK      DIV  2         TEST    30 12
         CL2         TEST      MULT 2         TEST
         CL2         TEST      ADD  NUM       NUM
         CL2         NUM       ADD  2         NUM
         CL2   N12 15NUM       ADD  2         NUM
         CL2 L3NL4   NUM       ADD  2         NUM
         CL2                   Z-ADDTEST      INUM    30
         CL2         INUM      ADD  2         INUM
         CL2   N12 15INUM      ADD  2         INUM
         CL2 L3NL4   INUM      ADD  2         INUM
         CL2                   SETOF                     15
         CL2                   Z-ADD0         MARK
         CL2                   SETON                     13
         CL2                   EXCPT
         CL2                   SETOF                     13
         CL2                   Z-ADD0         TQTY
         CL4         CONT      CHAINBLL                  10
         CL4                   EXCPT
         CL4                   Z-ADD0         NUM
         OBLL     E        L2 08 13
         O                    L3NL4         207 'X'
         O                         INUM     209P
         O                         TQTY     212P
         O        E        L4 08N13
         O                         NUM      249P
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Problems with Packed fields

      Could it be the incoming file itself? If the positions occupied by the packed field (as defined in the RPG program) does not contain numeric data (e.g. has *blanks), then the program would throw an error when it tried to reference that field.

      Comment


      • #4
        Re: Problems with Packed fields

        I think pjk has the right answer. Deciaml data error with a packed field usually means "non-numeric data found". Blanks are not the same as zeros! Even reading and writing back the same data can cause this error if the field contains blanks.

        Comment


        • #5
          Re: Problems with Packed fields

          I think the problem was the data wasn't valid in the first place. I changed it to a different value and now it works. Thanks, for the advice.

          Jane22

          Comment

          Working...
          X