ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

File EOF Condition Problem

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

  • File EOF Condition Problem

    Hi Folks,

    I have a file and 2 pgms.

    In PGM 1, Im reading the file and loading a subfile
    In PGM 2, Im reading the same file and have to load the subfile

    In both the PGMs the file is read with a Key Field with different values in both the PGMs

    What is happening is that, in PGM 1 subfile loads fine, but in PGM 2 when I read the same
    file with a different Key Value the EOF condition is met and the subfile in PGM 2 does not.

    I have used USROPN in both the PGMs and Im opening the file just before the read and closing
    the file after the loading to the subfile but even then the EOF condition is being met in PGM 2 so that the subfile is not getting loaded in PGM 2.

    Any ideas as to what needs to be done...

    Thanks...G

  • #2
    Re: File EOF Condition Problem

    Hi Giduturi:

    Just a guess here but does the common file have a shared open data path? (dspfd)
    If so does PGM1 hit EOF?
    You can do a file override [share(*no)].

    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: File EOF Condition Problem

      GLS,

      No the common file does not have shared ODP.

      I have checked in debug also just to see whether is there any shared ODP but there was nothing.

      Is it mandatory to use OVRDBF with Share(*NO) if we use the same file in both PGMs....I don't think so....

      Strange problem...

      Comment


      • #4
        Re: File EOF Condition Problem

        are you using the same file in both programs where programs are getting executed one after another?
        If so, try setting pointer in 2nd program to top of the file (Begining of the file).

        I have faced similar problem where my 2nd program was reading file and hence the pointer location was getting changed while returning to 1st program.

        So you need to open two different paths for the two programs.

        Try to see the open paths in debug ( if it has two diff paths then its strange prob,) if it has single data path then you need to use two diff paths

        Comment


        • #5
          Re: File EOF Condition Problem

          in your second programe write this code just before loading......
          Code:
          [B]*start   setll   file name[/B]
                           read   filename
                           dow    not %eof(file name)
                    load something in SFL..........
                         enddo
          Hope it will help
          Young people knows how to run fast but old people knows the way..

          Comment


          • #6
            Re: File EOF Condition Problem

            Folks,

            Always before doing a Read, I perform *LOVAL SETLL then my Read Stmt follows...

            So no problem with pointer positioning...i gues...

            I'm even OPENing and CLOSing the files in both programs before actually reading from the file..

            It shud be something else.....

            For now I have got around with the problem by using a totally different file but having the same data....

            Using this file I basically load my menus from the data present in the file.

            Regards...Shankar

            Comment


            • #7
              Re: File EOF Condition Problem

              Other way you can set EOF indicator equal to zero in your programe ....if it is problem of EOF file..

              Code:
              eval   eof=0 ( for that file) 
              
              read  filename
              
              dow  eof='0'
               
              do something here...........
              
              read   file name
              
              enddo
              Young people knows how to run fast but old people knows the way..

              Comment


              • #8
                Re: File EOF Condition Problem

                Param,

                What is tht "eof = 0" ????

                wt is eof???

                Is it a variable/indicator/opcode....

                Comment


                • #9
                  Re: File EOF Condition Problem

                  does the logical have a descending key value in it???

                  please post code for (DDS) for logical in error

                  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


                  • #10
                    Re: File EOF Condition Problem

                    eof is indicator for end of file...........contains alphanumeic value 0 or 1 only

                    at end of file it stores '1' and when not end of file it stores '0'

                    hope it will help
                    Young people knows how to run fast but old people knows the way..

                    Comment

                    Working...
                    X