ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CL Programming AS400: check fisical file members

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

  • CL Programming AS400: check fisical file members

    Good morning, with the STRSEU command I should query several physical files in a library and check if among the different fields in the various files there is the field beginning with DT. For each physical file where I found a match I should print a list with the name of the physical file. Is all this possible to do with CLLE programming (with an example)?

    Thanks

  • #2
    I don't see an easy way to do that with CL.
    I would do that by RPG.
    There you can read a system view (QSYS2.SYSPSTAT) to get a list of source members. For each member you can create an OVRDBF or an ALIAS to read the content of that source.
    Then you need to check the filter criterias for the fields starting with DT. I am doing this usually with regex (SQL).
    Let me know if you wanna go this way and if you need more information how to do it.

    Andreas

    Comment


    • #3
      Good morning,
      thank you for your response.
      Is it possible to have a small example of an RPG program ?​

      Comment


      • #4
        Hi,
        If you need some RPG examples, you can have a look in the qrpglesrc folder of my github project: https://github.com/andreas-prouza/ib...alib/qrpglesrc
        In the cpysrc2ifs.sqlrpgle.pgm, I read through all source members.

        Comment


        • #5
          Kindest Andreas,

          I think I explained myself wrongly. I do not need to read the records of each physical file.
          I need to read, for each physical file, the definition of the fields that conpose the same physical file.
          For example: If a field is 5 or 6 long (alphanumeric or numeric).​

          Comment


          • #6
            A quick and dirty solution:

            Do this for every physical file ( alternative *ALL instead of MYPF )
            DSPFFD FILE(MYPF) OUTPUT(*OUTFILE) OUTFILE(QTEMP/FIELDS) OUTMBR(*FIRST *ADD)

            Then create a query with WRKQRY
            and search for the fields that starts with "DT" in the file QTEMP/FIELDS

            Comment


            • #7
              In RPG you could loop the qsys2.syscolumns view.
              In it you have all definitions of all tables (PF) on the system.

              Comment


              • #8
                Hi Andreas,

                I will now write the program in RPGILE and try to read all the files contained in my library.

                I hope to succeed in the operation !!!

                if you happen to have time as well, I ask for your help in creating the pgm, so you can give me valuable suggestions without me wasting too much time.

                Thanks again​​

                Comment


                • #9
                  So, you are going to the light side of the force.
                  Sure, don't hesitate to ask if you need help.

                  Comment


                  • #10
                    Thanks Andreas

                    Comment


                    • #11
                      I started working on it again today.
                      The library containing the files has a source file at the origin and within it the different files

                      So d below:

                      MYLIB and inside

                      QDDSPF myfile01
                      QDDSPF myfile02
                      QDDSPF myfile03
                      ............
                      ............

                      I do not understand how to query, with the cl command, with RPGLE the individual files that are in the QDDSPF and check the length of the field that is repeated in the various files.

                      Comment


                      • #12
                        Can you show sample results of what you want it to look like ? So, if you had a query that works, what would your results be ?

                        Comment

                        Working...
                        X