ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

No records in the file

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

  • No records in the file

    Is there a way in Free Formatted RPG to tell if there are no records in the file? I have a process that is producing a report but need to only run the process if there are records in the file.

    Thanks,

    DAC

    SetLL *Start TMP400LGL;
    Read TMP400LGL;

    It would be nice if there was an opt code that I could use to see if there any records in TMP400LGL.

  • #2
    Re: No records in the file

    You could call the QDBRTVFD API to get the number of records in a file.

    Never trust a dog to watch your food.

    Comment


    • #3
      Re: No records in the file

      Originally posted by dcutaia View Post
      Is there a way in Free Formatted RPG to tell if there are no records in the file? I have a process that is producing a report but need to only run the process if there are records in the file.

      Thanks,

      DAC

      SetLL *Start TMP400LGL;
      Read TMP400LGL;

      It would be nice if there was an opt code that I could use to see if there any records in TMP400LGL.
      I'm not aware of an opt code, however I'm sure there is an API.

      You can check here

      for more information

      Comment


      • #4
        Re: No records in the file

        Once again someones fingers are faster than mine

        Comment


        • #5
          Re: No records in the file

          This should do it...



          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


          • #6
            Re: No records in the file

            If you really dig in the manual, I believe you can also determine the number of records using the IFDS (Informational File Data Structure). I haven't used this in a long time so I don't remember, I did calculate the RRN, but that was years ago and I have better tools now.
            Never trust a dog to watch your food.

            Comment


            • #7
              Re: No records in the file

              Personally, I think you're on the right track. You could just:

              Setll *Loval TMP400LGL;
              Read TMP400LGL;
              DoW NOT(%eof(TMP400lgl));
              Report records;
              Read TMP400LGL;
              EndDo;

              You check the INFDS on open for # of records but I don' remember which subfield that is.

              HTH,

              Jonas
              Jonas Temple
              Got FROG?
              Got Tadpole? No, because it's not done yet! Stay tuned....

              01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

              Comment


              • #8
                Re: No records in the file

                How many people does it take to answer a technical question?

                Man, we're helpful around here!
                Jonas Temple
                Got FROG?
                Got Tadpole? No, because it's not done yet! Stay tuned....

                01010111 01100001 01110011 01110011 01110101 01110000 00100000 01100100 01101111 01100111 00111111

                Comment


                • #9
                  Re: No records in the file

                  Can I get a little clarification. How do I use this API to determine if there are no records in the file. Can I use it in CL so it doesn't call the RPG program if there are no records in the file.

                  Thanks,

                  DAC

                  Comment


                  • #10
                    Re: No records in the file

                    You could call this command
                    PHP Code:
                     ===> DSPFD FILE(MYLIB/MYFILETYPE(*MBROUTPUT(*OUTFILEOUTFILE(MYLIB/MYOUTPUTF
                    And read the file that you created. The field is "MBNRCD Current number of records"

                    Why can you not just call the program regardless if are records in the file or not. Just handle the scenario if you didn't get any records read in.


                    87 more ways before we skin this cat.
                    Never trust a dog to watch your food.

                    Comment


                    • #11
                      Re: No records in the file

                      I am using the API QDBRTVFD in my CL. When I review the variable &FDATA. It looks like this:
                      ....5...10...15...20...25...30...35...40...45...50 ...55...60
                      ' µ µ �  *ALL    '
                      '  1070117143828 TMPPMASTER for Status code = 798 Leg'
                      'al QDDSSRC TMP400LGL RMSV61OBJ N '
                      '  / '
                      ' { '
                      ' µ  ARV5R3M0 '
                      ' ° ENUUS DN '
                      ' U 00000000000'
                      ' '
                      ' LGL400R '
                      ' '

                      Does anyone know the bite that represents the number of records in the file?

                      Thanks,

                      DAC

                      Comment


                      • #12
                        Re: No records in the file

                        When using CL you can use the RTVMBRD command, NBRCURRCD contains the number of records within that member.

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

                        Comment


                        • #13
                          Re: No records in the file

                          Or, you could do it the easy way

                          SetLL *Start TMP400LGL;
                          If NOT %Equal(TMP400LGL);
                          ... skip processing

                          Comment


                          • #14
                            Re: No records in the file

                            aarow,
                            I thought you charged by the number of lines you code. You won't make much doing things the simple way
                            Never trust a dog to watch your food.

                            Comment


                            • #15
                              Re: No records in the file

                              Nah, I charge by the lines I don't write.
                              Example: I could write a pgm using 300 lines, but do it in 100. So I charge for 200.

                              Comment

                              Working...
                              X