ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

USer commands in CL program

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

  • USer commands in CL program

    Hi All,

    Can anyone tell me how to retrieve all the USER COMMANDS used in a CL program ?
    If i give CL name as input i shd be able to retrieve all the user cmds used in it.

    Wats the approach to get this???

    Thks,
    Susan.

  • #2
    Re: USer commands in CL program

    Do you mean home-made commands ?
    Philippe

    Comment


    • #3
      Re: USer commands in CL program

      Hi Susan:

      If you want to know what cl programs use a particular command try prtcmdusg
      The Print Command Usage (PRTCMDUSG) command creates a
      cross-referenced listing of a specified group of CL commands that
      are used in a specified group of CL programs. The report shows,
      program by program, which of the specified commands are used in each
      program. The report can be used to identify which programs need to
      be recompiled because of changes that have been made to the command
      definition objects of commands specified on the PRTCMDUSG command.
      Note that this command can take a long time to run and can make a
      lot of printed output.
      If you want to know what programs are called.....use the dsppgmref command.

      Hope that helps
      GLS
      The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

      Comment


      • #4
        Re: USer commands in CL program

        I need to know in a particular CL program , what are the user commands used.

        Say if a CL program uses some 4 user commands,my job is to fetch all the 4 commands into a file.

        this is my requirement.

        Thks,
        Susan.

        Comment


        • #5
          Re: USer commands in CL program

          Originally posted by Mercury View Post
          Do you mean home-made commands ?
          I dono what are home-made commands, User commands means the commands which are created using CRTCMD.

          Thks,
          Susan.

          Comment


          • #6
            Re: USer commands in CL program

            I'm hoping there's a better way, but one way to do it is to perform a DMPOBJ on the cl program. This will create a spool file. A section of the Dump Output contains a list of all commands used in the CL program, including the PGM and ENDPGM statements.

            If the "USER COMMANDS" you are referring to are not system commands, but commands created by a programmer using the CRTCMD command, then you would need to take each of the commands from the dump output and perform a CHKOBJ against library QSYS. If the command is not contained in QSYS, then it is a user created command.
            Michael Catalani
            IS Director, eCommerce & Web Development
            Acceptance Insurance Corporation
            www.AcceptanceInsurance.com
            www.ProvatoSys.com

            Comment


            • #7
              Re: USer commands in CL program

              Originally posted by MichaelCatalani View Post
              I'm hoping there's a better way, but one way to do it is to perform a DMPOBJ on the cl program. This will create a spool file. A section of the Dump Output contains a list of all commands used in the CL program, including the PGM and ENDPGM statements.

              If the "USER COMMANDS" you are referring to are not system commands, but commands created by a programmer using the CRTCMD command, then you would need to take each of the commands from the dump output and perform a CHKOBJ against library QSYS. If the command is not contained in QSYS, then it is a user created command.
              Hi Micheal,

              When i tried this...
              iam getting junk values like this.......
              could u plss eloborate me abt this.

              0000A0 00000000 05400000 00000000 00000000 80000000 00000000 00000
              0000C0 00000000 00000000 00000000 00000000 00000000 00000000 00000
              0000E0 00000000 00000000 00000000 00000000 00000000 00000000 00000
              000100 00000138 2132002A 002B0132 0026402C 213A0252 00260066 02834
              000120 00000022 005F0041 00220051 00400132 00580061 10B2005B 005A0
              000140 20013042 00362001 18464000 00140004 00161CC2 C0000016 20F10
              000160 20021846 40000014 00080016 1CC2C000 001620F1 000A3042 00362
              000180 0014000C 00161CC2 C0000016 20F10010 30420036 20040093 00620
              0001A0 20052002 01320063 00130006 20052001 10420059 200110B2 005A0
              0001C0 21150065 00000093 00620060 20100006 20052002 01320013 00630
              0001E0 30B2002F 00121011 006A3011 40210036 30114020 003623EF 001F0
              000200 00310051 0283402C 214E0068 000003EF 001F001D 20011CC2 40000

              Comment


              • #8
                Re: USer commands in CL program

                Ugh. This doesnt sound that straightforward and I can't imagine why you would want to do it... But ;here is what I would do.

                1. Create a CL that creates a list of all the members in your QCLSRC physical file. I would then use that CL to loop through the file that was created and override to each specific member... one at a time.

                2. I would call an RPG from the CL described above which opens the CL source member that has been overriden to. This RPG should read through each record in the source member and do a scan for the first word in the line of source. Call a second CL passing that word as a parameter.

                3. Your second clp should do a RTVOBJD on the parameter passed into the program. If the library retrieved for that object is a user library and not an IBM system library you can assume it was a custom command.


                Thats a very basic description of how I would attack the problem.

                Comment


                • #9
                  Re: USer commands in CL program

                  i would DSPCMD to *PRINT then copy that into a PF and use FNDSTRPDM for the command names across all the source members. also you want to scan your RPG source members in case they are being used via QCMDEXC.
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: USer commands in CL program

                    You are seeing the hex characters in the dump. To the far right you can see the actual text.

                    If you copy the spool file to a physical file, you can read this info. (Use the scroll bar below to go to the far right.

                    Code:
                     000300   40404040 00000000 030a0000 00000005   d7c7d440 40404040 40400000 00000000  *                pgm             *  
                     000320   00000000 010000d6 e5d9c4c2 c6404040   40000000 00000000 00000003 0000d6d7  *       ovrdbf                 op*  
                     000340   d5d8d9e8 c6404040 00000000 00000000   00000300 00c3c1d3 d3404040 40404000  *nqryf                call       *  
                     000360   00000000 00000000 00020000 c5d5c4d7   c7d44040 40400000 00000000 00000000  *            endpgm              *  
                     000380   02000000 00000000 00000000 00000000   00000000 00000000 00000000 00000000  *                                *  
                     0003a0   00000000 00000000 00000000 00000000   00000000 00000000 00000000 00000000  *                                *

                    This is not an easy quick program. And I was hoping there's a better way of doing it, but havent seen a direct way of doing it.

                    ANother alternative is to list all commands that are not in a system library into a file. Then run the PRTCMDUSG command against each of these "user commands". You will then need to take the spool file for each user command processed and add the contents into a giant cross reference file which contains the program name, library name, and command name. Then you could write a program over this cross reference file that allows you to enter in a program name and get all of the user commands.
                    Michael Catalani
                    IS Director, eCommerce & Web Development
                    Acceptance Insurance Corporation
                    www.AcceptanceInsurance.com
                    www.ProvatoSys.com

                    Comment


                    • #11
                      Re: USer commands in CL program

                      What I'd do.
                      I'd create 2 or 3 programs.

                      PGM1 - CL
                      - Using DSPFD, create a CL to list the relevant QCLxxSRC members into a PF in QTEMP
                      - Read the QTEMP file
                      - Override QCLxxSRC with the member name just read
                      - Call the RPG program below using the member name as parameter
                      - Loop within the program up to the EOF

                      Pgm2 - RPG
                      - Create a RPG program to read the contents of the member name
                      - Scan the first blank char to isolate the command name
                      - Monitor errors to ignore the continuation lines
                      - Call the Retrieve Command Information QCDRCMDI API using the command name.
                      - Check the retrieved CPP library from the API. If this library name does NOT start by "QSYS", the command name is likely a home-made (user) command.
                      - Display the command Library/Name or print it or whatever
                      - Return to the caller
                      - We are done.

                      Actually it is exactly the same routines as Soup_Dog's but using QCDRCMDI API instead.

                      Feel free to ask any questions if necessary.
                      Last edited by Mercury; October 23, 2008, 09:58 AM.
                      Philippe

                      Comment


                      • #12
                        Re: USer commands in CL program

                        it's not as pretty as the APIs but here's a quick and dirty tool that i put together. it's a v5r2 savf just click on the link Get User Defined Command Usage http://tommyholden.com/downloads the command will let you search by library for source members that reference the user defined commands. there is a help text panel defined on the command.
                        I'm not anti-social, I just don't like people -Tommy Holden

                        Comment

                        Working...
                        X