ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

COPY Directive and Subfiles

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

  • COPY Directive and Subfiles

    If I copy input or output fields only for a subfile, the compiler listing shows the I-O format. For example:

    Code:
    Working-storage section.
    01  Sfl-in.   copy dd-sfl01-I of somedspf.
    01  Sfl-out.  copy dd-sfl01-O of somedspf.
    The compiler shows this for the first COPY and the same sort of thing for the second COPY:

    Code:
     01   Sfl-in.
                    copy dd-SFL01-I of somedspf.
    *     I-O FORMAT:SFL01      FROM FILE SOMEDSPF     OF LIBRARY MYLIB
    *
              05   SFL01.
                    06 . . .
    Does the compiler always treat subfile as I-O, even if I ask for input or output only?
    Does this mean I may as well use one COPY for both input and output instead of defining separate buffers?

  • #2
    Re: COPY Directive and Subfiles

    If the input and output buffers are different, it will generate INPUT-FORMAT for the input and OUTPUT-FORMAT for the output. The buffers will be different if the subfile has some input-only fields, or if INDARA isn't specified and it has conditioning or response indicators. So unless you know for they're the same (and always will be), I think you should define both.

    Code:
    A          R SFL                       SFL
    A            FIELDI        10A  I  5 10BLANKS(01)
    A            FIELDB        10A  B  5 30BLANKS(02)
    A  03        FIELDO        10A  O  5 50
    Code:
      01  Sfl-in.
                   copy dd-sfl-I of sfldsp.
    *  INPUT FORMAT:SFL        FROM FILE SFLDSP
    *
           05  SFL-I.
               06 SFL-I-INDIC.
                    07 IN01             PIC 1  INDIC 01.
                    07 IN02             PIC 1  INDIC 02.
               06 FIELDI                PIC X(10).
               06 FIELDB                PIC X(10).
               06 FIELDO                PIC X(10).
     01  Sfl-out.
                   copy dd-sfl-O of sfldsp.
    * OUTPUT FORMAT:SFL        FROM FILE SFLDSP
    *
           05  SFL-O.
               06 SFL-O-INDIC.
                    07 IN03             PIC 1  INDIC 03.
               06 FIELDB                PIC X(10).
               06 FIELDO                PIC X(10).

    Comment


    • #3
      Re: COPY Directive and Subfiles

      Thanks, Barbara. It's strange to me that you are getting different results from mine. In fact, I can't even create your display file.

      Code:
      A                                      DSPSIZ(24 80 *DS3)
      A          R SFL                       SFL               
      A            FIELDI        10A  I  5 10BLANKS(01)        
      A            FIELDB        10A  B  5 30BLANKS(02)        
      A  03        FIELDO        10A  O  5 50                  
      A          R CTL                       SFLCTL(SFL)       
      A                                      SFLDSP            
      A                                      SFLSIZ(   2)      
      A                                      SFLPAG(   1)
      gives me message CPD7814 (Option indicators not allowed on fields in subfile record.)

      I'm sure I'm overlooking the obvious. Someone please be kind enough to point out my error.

      Comment


      • #4
        Re: COPY Directive and Subfiles

        Hi Ted, I have SFLSIZ and SFLPAG the same in my control record. When I make them different, like yours, I get that error about option indicators not being allowed.

        Try

        Code:
             A                                      DSPSIZ(24 80 *DS3)
             A          R SFL                       SFL               
             A            FIELDI        10A  I  5 10BLANKS(01)        
             A            FIELDB        10A  B  5 30BLANKS(02)        
             A  03        FIELDO        10A  O  5 50                  
             A          R CTL                       SFLCTL(SFL)       
             A                                      SFLDSP            
             A                                      SFLSIZ(   2)      
             A                                      SFLPAG(   2)

        Comment


        • #5
          Re: COPY Directive and Subfiles

          Ohhhh ... CPD7814 says "Cause . . . . . : Option indicators on fields in a subfile record (SFL keyword) are only allowed when the value on the SFLSIZ keyword is the same as the value on the SFLPAG keyword."

          "Tsk tsk" to both of us for not reading the second level text of the message ...

          But you can see the different layouts of the input and output buffers just by having an input-only field, since they don't go in the output buffer. (Output-only fields do go in the input buffer because otherwise the program would have to keep track of what it had written for every subfile record.)

          Comment

          Working...
          X