ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Determining "Active" record status / SFLRNA

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

  • Determining "Active" record status / SFLRNA

    Hi, all. I'm using the SFLRNA keyword on a subfile used for data edit and entry, leaving a bunch of "inactive" records (for entry) following the records my program has filled (for edit).

    Is there a way to determine whether a particular record (using its RRN) is currently "Active"?

    One thought: CHAIN to a record and test %FOUND. Any other magical BIFs or methods?

    If a program must modify a subfile record, an active record requires the UPDATE operation, but a new record requires the WRITE operation. It gets particularly interesting if the user decides to add new records on non-contiguous lines.

    TIA,

    Jerry Gloekler

    MFCD, LLC

  • #2
    Re: Determining "Active" record status / SFLRNA

    You should be looking at the SFLNXTCHG key word for this.

    Comment


    • #3
      Re: Determining "Active" record status / SFLRNA

      Jerry I would just create a data structure of the subfile record and check for all blanks.
      if there are decimal fields remember to %xlate the 0 to *Blanks.

      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


      • #4
        Re: Determining "Active" record status / SFLRNA

        Thanks to both of you; I'm already using both of your suggestions. But typical of many forum posts ;-) I left out elaboration which might clarify my objective.

        The user can position to any line in the subfile and prompt on one of the fields, either when editing a record or creating a new record. The prompt presents a pop-up window. To display the value selected from the pop-up window, the program must either UPDATE the subfile record (if that record already exists, i.e. is active), or WRITE the new subfile record (if that record is inactive).

        My "quest" (in addition to the Holy Grail, of course) is for a function that would let me inquire of the system whether it considers a record active or inactive, so that I wouldn't have to keep track of that myself in the program. But so far, all I can come up with is ... keeping track of that myself in the program (say, via an array of flags). But I didn't want to give up without posting to a list of experienced folks. :-)

        Is my quest in vain (except for the Holy Grail, of course)?

        Comment


        • #5
          Re: Determining "Active" record status / SFLRNA

          By active you mean data entered in "A" field?

          If so -- can you use the change indicator on the subfile record?
          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


          • #6
            Re: Determining "Active" record status / SFLRNA

            Well, yes; a user entering data in a field makes an SFLINZ-initialized record active (immediately)! Unfortunately, the CHANGE keyword, for some reason, doesn't work for subfile records.

            My problem is discerning between these two scenarios:

            1) The user is "constructing" a new record on one of the blank lines at the end of the populated lines of the subfile. Without entering anything into any field, s/he prompts -- I used F4 -- the field where that's allowed. Control returns to the program, which presents the pop-up window and obtains a value. In this case, the record is still inactive when it reaches my program. There are (apparently) no change flags or MDT's set; it's as if the record (still) doesn't exist, since not a single key was pressed before F4. When I want to display the nicely-formatted line, I must use a WRITE operation.

            2) The user is updating an existing record. S/he presses F4 to prompt for a new value (again without entering anything else). Control returns to the program, the pop-up window appears, and a value is obtained. Because this record is already active (becoming so when it was first written out), I must use an UPDATE operation.

            So when the program processes F4, how can it tell which scenario it's facing? It's not rocket science to keep track of this in the program ;-) ... but before doing that I thought I'd see if anyone had encountered this and knew of something real simple -- like a "%ACTIVE" BIF -- to avoid that overhead.

            Thanks, again, for your time and thought!

            Comment


            • #7
              Re: Determining "Active" record status / SFLRNA

              when is pressed does WHERE get set to RRN?

              PHP Code:
                   A                                      SFLCSRRRN(&WHERE)           
                   
              A            WHERE          5S 0H 
              If this is the case.. once a record is written to a file and read back
              set a hidden field to state it is a "O" old record.
              all *blank subfile lines have this hidden field set to *blanks.

              when pressed, chain back to subfile record first.

              I do have to ask are you using a CF key or a CA key?
              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


              • #8
                Re: Determining "Active" record status / SFLRNA

                Yes, Jamie. "WHERE" (in your example) is correctly set to the RRN of the record on which the user is prompting. (I use CF key 04.)

                I think your solution is the best (only?) way to do this!

                Comment


                • #9
                  Re: Determining "Active" record status / SFLRNA

                  Why is the SFLNXTCHG key word not working for you? This keyword is what is used to do exactly what your looking for. An active record on a subfile is an existing record that has been changed prior to updating the subfile record, not a record that has been added. These records can now by read by the READC op code. If you need to keep the record active you just turn on the indicator for the keyword when you update the record. Using the SFLNXTCHG keyword allows you to control the active state of the subfile record.

                  Comment


                  • #10
                    Re: Determining "Active" record status / SFLRNA

                    Thanks for your thoughts. SFLNXTCHG is working well for me in other parts of the program, forcing READC to send back records that had errors on them last time (which, as I infer, is its primary intention).

                    I'm not sure I understand how its application would help in this case, however, telling whether a record on which the user pressed a function key was empty (inactive) or not. There's no problem telling which record we're dealing with; the SFLCSRRRN keyword (Jamie's "WHERE" above) give us its RRN.

                    Perhaps we may be confusing "changed" with "active". Writing the control record with SFLINZ and SFLRNA on initializes ALL (SFLSIZ) subfile records, but, to save CPU cycles, none of them are considered active until the program or user writes to them. The program writes some records to the subfile, and those records are ALL considered "active", whether the user changes them or not. Below them are a whole bunch of empty (initialized) records; those are inactive.

                    As you said, a changed (edited) subfile record (originally written by the program, and thus active) would be returned by READC. An entry anywhere below on one of the empty lines is also a changed record, would be returned by READC -- and would have become active as soon as the user typed something. ("Changed" implies "active", but not the other way around.) But I need to tell the difference (preexisting line or empty line) when the user HASN'T typed anything. S/he has told the program what the entry should be via a pop-up window, and now the program needs to spit it back out. In a sense, it's the program that's doing the data entry for the user -- but it needs to know whether to make that entry in the subfile with an UPDATE (if s/he prompted on an existing/active line) or a WRITE (if s/he prompted on an empty/inactive line). (The wrong op code yields a runtime error.)

                    I don't think they system can tell me this; I just have to keep track of it myself.

                    (Sorry for being so verbose, but I search the forums for all sorts of help and information. Maybe all my blathering will help someone else.) ;-)

                    Comment


                    • #11
                      Re: Determining "Active" record status / SFLRNA

                      An active or inactive subfile record is not whether the subfile record exists or not. You need to get that out of your head. I think that is preventing you from realizing the solution. Active = a change to an existing subfile record, Inactive = an unchanged subfile record. Active/inactive has nothing to do with whether or nor there is a subfile record. For what you are trying to do you will have to program for it. Jamie already suggested the solutions in his for you by setting a hidden field in the subfile record. Just set it to the value you need it to be when you first create the subfile record and update as needed. To check for a blank record create a data structure of the input capable fields in the subfile record, and if the data structure is blank you know you have a blank record. When you first create the subfile you know at that time if the record is blank or not. just keep track of its status form that point on.

                      Comment

                      Working...
                      X