ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Display records from a Physical File

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

  • Display records from a Physical File

    Hello all,
    Can some one help me in writing a RPGLE program for displaying all the data of the physical file.

    RPGLE program i tried:
    FPF9 IF E DISK
    DDS1 DS LIKEREC(RPF9)
    C *loval SETLL RPF9 90
    C READ PF9 ds1
    C DOW *in90 = *off
    C ds1 DSPLY
    C READ PF9 ds1
    C ENDDO
    C IF *in90 = *on
    C 'END' DSPLY
    C ENDIF
    C SETON LR

    Its not working, please help me correct the code as i am new to RPG

    Regards
    Nilesh

  • #2
    Re: Display records from a Physical File

    this does not affect function , but don't do it; Read and Chain to file names, dont use the record format for this. Record formats should only be used for write / Update / Delete.

    you need a 90 on the read line. You only have it on the setll (which you dont need) so it does not change. Your loop will not exit. the 'end' will only display if the 90 at the setll was turned on.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Display records from a Physical File

      I followed your suggestion, but still the error stating loval shouldnot be used.

      New code i tried was.
      FPF9 IF E DISK
      DDS1 DS LIKEREC(RPF9)
      C *loval SETLL PF9
      C READ PF9 ds1 90
      C DOW *in90 = *off
      C ds1 DSPLY
      C READ PF9 ds1 90
      C ENDDO
      C IF *in90 = *on
      C 'END' DSPLY
      C ENDIF
      C SETON LR

      Please advice

      Comment


      • #4
        Re: Display records from a Physical File

        I have no idea what the DS1 is for on the read line.
        Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

        Comment


        • #5
          Re: Display records from a Physical File

          Originally posted by DeadManWalks View Post
          this does not affect function , but don't do it; Read and Chain to file names, dont use the record format for this. Record formats should only be used for write / Update / Delete.

          you need a 90 on the read line. You only have it on the setll (which you dont need) so it does not change. Your loop will not exit. the 'end' will only display if the 90 at the setll was turned on.
          Can you please help me changing the code....it is not working

          Comment


          • #6
            Re: Display records from a Physical File

            The PF i have created is PF9
            Code:
             A              R RPF9                                                  
             A                ALPHAN        25A         TEXT( 'ALPHA NUMERIC DATA') 
             A                NUMENRIC      25S 0
            The RPGLE program i have written is ;-
            Code:
            FPF9       IF   E             DISK                                      
            DDS1              DS                  LIKEREC(RPF9)                     
            C     *loval        SETLL     PF9                                       
            C                   READ      PF9           ds1                      90 
            C                   DOW       *in90 = *off                              
            C     ds1           DSPLY                                               
            C                   READ      PF9           ds1                      90 
            C                   ENDDO                                               
            C                   IF        *in90 = *on                               
            C     'END'         DSPLY                                               
            C                   ENDIF                                               
            C                   SETON                                        LR
            Please advice what changes i need to make for the program to compile
            Last edited by tomholden; January 23, 2014, 10:11 AM.

            Comment


            • #7
              Re: Display records from a Physical File

              DS1 is a data structure to store the data....I am not sure if i should use it or not.......If i am wrong please correct it.

              Comment


              • #8
                Re: Display records from a Physical File

                I like to help, but not when its basic like this. you dont use the DS1 on a read line. You read the table, then eval the table fields into other fields. If you just want to display then you just read the table, then display the field you want.
                Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                Comment


                • #9
                  Re: Display records from a Physical File

                  Originally posted by Nilesh3110 View Post
                  still the error stating loval should not be used.
                  You can use *START.

                  Why do you need to position the file, Nilesh? Do you think it may already be open from another program?

                  Comment


                  • #10
                    Re: Display records from a Physical File

                    Originally posted by Nilesh3110 View Post
                    still the error stating loval should not be used.
                    You can use *START.

                    Why do you need to position the file, Nilesh? Do you think it may already be open from another program?

                    Comment


                    • #11
                      Re: Display records from a Physical File

                      The reason *LOVAL gives an error is because the file is not keyed (no 'K' on the F-spec). However, using *LOVAL on SETLL is almost always a bad idea, you should use *START instead.

                      Comment


                      • #12
                        Re: Display records from a Physical File

                        Originally posted by DeadManWalks View Post
                        I like to help, but not when its basic like this. you dont use the DS1 on a read line. You read the table, then eval the table fields into other fields. If you just want to display then you just read the table, then display the field you want.
                        Sir, It will be really very helpful please write the code for me........I will be really greatful to you

                        Comment


                        • #13
                          Re: Display records from a Physical File

                          no one here should write your code, you learn nothing that way. this forum (and others) is not for "free contract work" but to assist in learning or problems. considering the questions you are asking I would recommend that you find a good book since this is more of a beginner question.
                          I'm not anti-social, I just don't like people -Tommy Holden

                          Comment


                          • #14
                            Re: Display records from a Physical File

                            This has nothing to do with OP, moved to it's own thread.
                            Regards

                            Kit
                            http://www.ecofitonline.com
                            DeskfIT - ChangefIT - XrefIT
                            ___________________________________
                            There are only 3 kinds of people -
                            Those that can count and those that can't.

                            Comment


                            • #15
                              Re: Display records from a Physical File

                              STRDBG myprogramname updprd(*YES)

                              step through it and see. If you don't know how to debug then you really need a book for beginners.
                              Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                              Comment

                              Working...
                              X