ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Diff SFLNXTCHG and READC in a DoW loop

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

  • Diff SFLNXTCHG and READC in a DoW loop

    Hi,

    If ever I need to read the changed record of a subfile I do the following

    Readc SFL01
    Dow Not %EOF(SFL01)
    Readc SFL01
    <Some operations>
    EndDo

    It works fine and I am able to get all the changed records of the subfile. As per my understanding SFLNXTCHG will also give me the changed recrods of a subfile. So what is the diff between the two?

    Thanks!

  • #2
    Re: Diff SFLNXTCHG and READC in a DoW loop

    SFLNXTCHG is the keyword in DDS that allows the readc to work in RPG.
    What is odd is it need not be present in the DDS to work.

    jamie
    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: Diff SFLNXTCHG and READC in a DoW loop

      SFLNXTCHG represents a flag on the subfile record that indicates whether or not the READC will read the record. This allows you control over whether or not you want to do a READC on a subfile record.

      Comment


      • #4
        Re: Diff SFLNXTCHG and READC in a DoW loop

        Just to clarify a bit more:


        The readc opcode will always read a physically changed subfile record. It does not need the SFLNXTCHG keyword to do this.

        But there are times when you want to force the readc to read a subfile record, whether it was changed or not. Suppose you have a subfile screen of item numbers. After keying the item numbers, every subfile record would technically be picked up by the readc since they were changed. (Item numbers entered. ) Now, our code would validate each of the item numbers to make sure they were valid. If there is an invalid item number, we need to set the SFLNXTCHG flag so that the readc will pick that record back up in case the user doesnt change the item number. Without using the SFLNXTCHG, our program would perform validation on the item number entered, but if the user doesnt change the item number, that subfile record wouldnt be picked up on the next readc loop. This would make our program think that all item numbers were valid. By setting on the SFLNXTCHG keyword anytime we flag the item number as invalid, it will force the readc to read that subfile record until a valid item number is entered.

        So thats all SFLNXTCHG really does. It sets a flag so that the readc will read that record, even if it wasnt actually physically changed by the user.
        Michael Catalani
        IS Director, eCommerce & Web Development
        Acceptance Insurance Corporation
        www.AcceptanceInsurance.com
        www.ProvatoSys.com

        Comment


        • #5
          Re: Diff SFLNXTCHG and READC in a DoW loop

          ... by the way:
          Readc SFL01
          Dow Not %EOF(SFL01)
          Readc SFL01
          <Some operations>
          EndDo
          ... will omit the first changed subfile record! The following would be better:

          Readc SFL01
          Dow Not %EOF(SFL01)
          <Some operations>
          Readc SFL01
          EndDo

          Just to keep the things correct ...
          Sven

          The best way to prove your knowledge is to share it ...

          Comment


          • #6
            Re: Diff SFLNXTCHG and READC in a DoW loop

            Oops!!! My Bad... Actually.. that is wat i meant :-P

            Comment

            Working...
            X