sponsored links

Collapse

Announcement

Collapse
No announcement yet.

Difference between %EOF & Not %Found

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

  • Difference between %EOF & Not %Found

    Gentlepeeps:

    Can someone go over a simplistic definition of the difference between:

    Code:
    Chain SKU SKUMst;
    If Not %eof( SKUMst );
    
    EndIF;
    and

    Code:
    Chain SKU SKUMst;
    If %Found( SKUMst )
    
    EndIF;
    And why would you use one over the other?

    Thanks!
    -Rick

    _____________________________

    Need a Managed File Transfer Solution -OR- iSeries Encryption?
    GoAnywhere and Crypto Complete by Linoma Software


  • #2
    Re: Difference between %EOF & Not %Found

    Hey FaStOnE:

    Found this:
    Where %Eof, %Equal, and %Found may be used



    This is from a V4R2 article in News400, but I still refer to it to make sure I'm using the right BIF.

    Chain - %Found
    Check - %Found
    CheckR - %Found
    Delete - %Found
    LookUp - %Equal, %Found
    Read - %Eof
    ReadC - %Eof
    ReadE - %Eof
    ReadP - %Eof
    ReadPE - %Eof
    Scan - %Found
    SetGT - %Found
    SetLL - %Equal, %Found
    Write (subfile only) - %Eof
    here:
    http://www.think400.dk/adhoc_2.htm#eks0019


    Chain/EOF......like Oil/Water


    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: Difference between %EOF & Not %Found

      Can someone go over a simplistic definition of the difference between:

      Code:
      Chain SKU SKUMst;
      If Not %eof( SKUMst );
      
      EndIF;

      The really simple answer is that a failed chain does not set the file pointer to end of file. So a failed chain would almost always execute the code within the NOT %eof( file ) section.

      Basically, you use the bif %found with chain operations, %eof with read(x) operations, and %equal with setll if you want the setll to tell you if the key was found.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #4
        Re: Difference between %EOF & Not %Found

        You have been redirected to this page

        Some reasons:

        1) Your ISP has been 'blacklisted' in SORB's or others

        2) The IP address you're using has been 'blacklisted' or is in my .htaccess


        I thought it was like this. %Eof is switched on when you attempt to move the record pointer past the last record. %Found is switched on when an exact match is found for the key you used to do the lookup with.

        In general this means you use %Eof with reads and %Found with chains. However, take the following examples.

        PHP Code:
        Setll (Key1:Key2FILE;
        If %
        Found(FILE);
        ... 
        PHP Code:
        Chain (Key1:Key2FILE;
        If %
        Found(FILE);
        ... 
        Both of these code blocks are perfectly valid. Both are effectively checking if a particular record exists in FILE. The difference is the Setll one will run faster because it doesn't have to read the record. If you just want to check the record exists, you should use Setll. If you want to check it exists and then use that record, you should use chain.
        Ben

        Comment


        • #5
          Re: Difference between %EOF & Not %Found

          I guess I just couldn't see the reason for the "Chain If NOT %Eof()" piece. But, we found this in come code that is having iffy results.

          Just wanted some feedback...

          Thanks peeps!
          -Rick

          _____________________________

          Need a Managed File Transfer Solution -OR- iSeries Encryption?
          GoAnywhere and Crypto Complete by Linoma Software

          Comment


          • #6
            Re: Difference between %EOF & Not %Found

            One of the big problems with Chain and %EOF is because the %EOF is not set by chain, it might still be set on by a prior operation. The CHAIN will not reset.

            Comment


            • #7
              Re: Difference between %EOF & Not %Found

              Originally posted by BenThurley View Post

              I thought it was like this. %Eof is switched on when you attempt to move the record pointer past the last record. %Found is switched on when an exact match is found for the key you used to do the lookup with.
              On the SETLL, the %found will be true if there is a record in the file it can position to. It's not the same as a %found on a chain, which means the exact key has to be in the file. In order to use SETLL in lieu of the CHAIN op code, you would need to check the %EQUAL bif for the condition.
              Michael Catalani
              IS Director, eCommerce & Web Development
              Acceptance Insurance Corporation
              www.AcceptanceInsurance.com
              www.ProvatoSys.com

              Comment


              • #8
                Re: Difference between %EOF & Not %Found

                Copied from the RPG Reference:
                1. %EOF
                %EOF returns ’1’ if the most recent read operation or write to a subfile ended in an end of file or beginning of file condition; otherwise, it returns ’0’. The operations that set %EOF are:
                • “READ (Read a Record)” on page 750
                • “READC (Read Next Changed Record)” on page 753
                • “READE (Read Equal Key)” on page 755
                • “READP (Read Prior Record)” on page 758
                • “READPE (Read Prior Equal)” on page 760
                • “WRITE (Create New Records)” on page 821 (subfile only).

                The following operations, if successful, set %EOF(filename) off. If the operation is not successful, %EOF(filename) is not changed. %EOF with no parameter is not changed by these operations.
                • “CHAIN (Random Retrieval from a File)” on page 611
                • “OPEN (Open File for Processing)” on page 737
                • “SETGT (Set Greater Than)” on page 781
                • “SETLL (Set Lower Limit)” on page 785

                2. %FOUND

                %FOUND returns ’1’ if the most recent relevant file operation found a record, a string operation found a match, or a search operation found an element. Otherwise, this function returns ’0’. The operations that set %FOUND are:
                File operations:
                • “CHAIN (Random Retrieval from a File)” on page 611
                • “DELETE (Delete Record)” on page 633
                • “SETGT (Set Greater Than)” on page 781
                • “SETLL (Set Lower Limit)” on page 785
                String operations:
                • “CHECK (Check Characters)” on page 614
                • “CHECKR (Check Reverse)” on page 617
                • “SCAN (Scan String)” on page 776
                Note: Built-in function %SCAN does not change the value of %FOUND.

                Search operations: “LOOKUP (Look Up a Table or Array Element)” on page 689

                If %FOUND is used without the optional file_name parameter, then it returns the value set for the most recent relevant operation. When a file_name is specified, then it applies to the most recent relevant operation on that file.

                For file operations, %FOUND is opposite in function to the ″no record found NR″ indicator.

                Birgitta

                Comment


                • #9
                  Re: Difference between %EOF & Not %Found

                  If...

                  Code:
                  Chain (Key1) File1;
                  If %Found(File1);
                     DoW Not %EoF(File1);
                        // something something
                     ReadE (Key1) File1;
                     EndDo;
                  EndIf;
                  ...is the very ugly version of...

                  Code:
                  SetLL (Key1) File1;
                  ReadE (Key1) File1;
                  DoW Not %EoF(File1);
                     // something something
                  ReadE (Key1) File1;
                  EndDo;
                  can i just simply change the old (ugly) code to the newer one?? i think that some records were not read in a similar looking line in my work because it uses chain/eof like that.... oil/water i tell you...

                  Comment


                  • #10
                    Re: Difference between %EOF & Not %Found

                    yes but i would check %EQUAL after the SETLL if no matching record is found you can bypass the loop since there's nothing for it to process.
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment


                    • #11
                      Re: Difference between %EOF & Not %Found

                      thanks tom, i just learned something new today

                      Comment

                      sponsored links

                      Collapse

                      Working...
                      X