IBM i Global

IBM i Global

Connect, learn, share, and engage with IBM Power.

 View Only
Expand all | Collapse all

Regarding DSPPGMREF

  • 1.  Regarding DSPPGMREF

    Posted Sat February 03, 2024 12:39 PM

    Hi,

    When testing this :-IBM-i-RPG-Free-CLP-Code/PGM_REFS/Readme.MD at master · SJLennon/IBM-i-RPG-Free-CLP-Code · GitHub

    CALL  mylib/mypgm ('driver'  'lib1'  '*ALL'  0)
    ******************************************************
                                    Command Entry              
                                                              R
    Previous commands and messages:                            
       > CALL mylib/mypgm ('driver', 'lib1' ,   '*ALL' ,  '0')       
         Character ',' not valid following string ''driver'  '.
         Character ' ' not valid following string ',         '.
         Character ' ' not valid following string ',         '.
         Error found on *N command.                            
                                                       
    ****************************************************************************
                            Additional Message Information                        
                                                                                  
    Message ID . . . . . . :   CPD0020                                            
    Date sent  . . . . . . :   02/03/24      Time sent  . . . . . . :   11:12:01  
                                                                                  
    Message . . . . :   Character ',' not valid following string ''driver'  '.    
                                                                                  
    Cause . . . . . :   A delimiter is missing between two values or a delimiter  
      that is not valid was found.                                                
    Recovery  . . . :   Change the character that is not valid or if a delimiter  
      is missing insert one. More information on delimiters can be found in the   
      Information Center.          

    what i am doing wrong to call to test this procedure , how to correct this error so that i could get the desired call stack in the table defined inside this procedure?

    Thanks                                              
                                                                                  
                                                                                  



    ------------------------------
    jerry ven
    ------------------------------


  • 2.  RE: Regarding DSPPGMREF

    Posted Sun February 04, 2024 02:10 AM
    Edited by Satid Singkorapoom Sun February 04, 2024 02:12 AM

    Dear Jerry

    From your post, I suspect that you did the CALL from a 5250 session command line which does not support calling a DB2 stored procedure.  Since this is an SQL stored procedure, the best place for youto do the CALL for Db2 SP is from IBM i ACS - Run SQL Scripts tool session. 

     


    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 3.  RE: Regarding DSPPGMREF

    Posted Sun February 04, 2024 02:29 AM

    Hi,

    But previously I was able to call this procedure (from the command line) without 'Run SQL Scripts tool. ' and table containing references for the called programs was generated successfully.

    This time why is it showing this error not sure?

    Thanks



    ------------------------------
    jerry ven
    ------------------------------



  • 4.  RE: Regarding DSPPGMREF

    Posted Sun February 04, 2024 05:18 AM

    Hi,

    I just remembered that I was able to call it using STRSQL session and this time though CALL statement was successful inside from STRSQL session but when I checked table then found "it seems DSPPGMREF fails internally, *ERROR will appear in the three USES_* fields in the REFS file. If you get a lot of these check you have your library list correct."

    also my lib. was correct i kept these table and stored procedure objects in my library and it was on top of library list and the program whose references i was looking to be summarized in this table was also in the library which was in the library list already still this happened this time.

    Thanks




  • 5.  RE: Regarding DSPPGMREF

    Posted Mon February 05, 2024 09:42 AM

    Aside from the library list, I would suggest using SET SCHEMA to your library as well.



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 6.  RE: Regarding DSPPGMREF

    Posted Mon February 05, 2024 12:12 PM

    How can i set schema? 



    ------------------------------
    jerry ven
    ------------------------------



  • 7.  RE: Regarding DSPPGMREF

    Posted Mon February 05, 2024 12:27 PM

    SET SCHEMA <yourschema>



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 8.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 05:37 AM

    Hi,

    I did not find any such command exists.

    Thanks




  • 9.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 08:05 AM

    Hi Jerry,
    I think these are the steps you're looking for:

    STRSQL
    SET SCHEMA yourlibrary
    CALL yourprogram



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 10.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 09:12 AM

    even though this set command ran successfully in STRSQL session but main table entries show same *error and same message DSPPGMREF failed.

    Thanks.



    ------------------------------
    jerry ven
    ------------------------------



  • 11.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 10:19 AM

    Hm ok.  I'm sorry, I don't know what else to suggest.



    ------------------------------
    Steven Riedmueller
    Certified IBM i Admin
    Speaker, Mentor, and Advocate
    ------------------------------



  • 12.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 09:51 AM

       > CALL mylib/mypgm ('driver', 'lib1' ,   '*ALL' ,  '0')       
         Character ',' not valid following string ''driver'  '.
         Character ' ' not valid following string ',         '.
         Character ' ' not valid following string ',         '.
         Error found on *N command.                            

    Have you tried without commas (CALL mylib/mypgm ('driver'  'lib1'    '*ALL'   '0'))?



    ------------------------------
    Carlos Romero
    ------------------------------



  • 13.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 10:21 AM

    Yes just tried without commas as well now the error is with message ID SQL0104:-"Token  'mypgm'(the program whose references I have been trying to find out) was not valid. Valid tokens: ) '. 

    Thanks. 



    ------------------------------
    jerry ven
    ------------------------------



  • 14.  RE: Regarding DSPPGMREF

    Posted Tue February 06, 2024 10:30 PM

    Dear Jerry

    Have you tried running this in Run SQL Scripts tool yet?   Do not stick to STRSQL because it has many limitations due to the fact that it has not been enhanced for several years now and there is no documentation explaining the difference support between STRSQL and Run SQL Script tool but the latter is definitely superior in all respects.  Sometimes when I have a problem running SQL from STRSQL and switch to Run SQL Script tool, it solves the issue.



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 15.  RE: Regarding DSPPGMREF

    Posted Fri February 09, 2024 12:48 PM

    Thanks for all these suggestions.

    1) Does this utility also allow me to get the bound modules list as well, does it allow me to get the list of bound modules from the associated programs and service programs as well?
    2) What about the Procedures, Sub procedures and copybooks can we get that information using this utility? or is there any standard IBM i SQL query which can provide this information?
    3) To get the information of all the objects to get their references from all the libraries in the system can I run it like CALL MYLIB/Thispgm ('*ALL' , '*ALL'  ,'*ALL' ,0' )
    Thanks.



  • 16.  RE: Regarding DSPPGMREF

    Posted Fri February 09, 2024 02:56 PM

    The first lines of program source named pgm_refs.sql (from https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/blob/master/PGM_REFS/pgm_refs.sql#L1) starts with

    --  Procedure to run DPSPGMREF, then run DSPPGMREF on each of its objects
    --  by calling itself recursively.
    --  Result is a file named REFS containing all the objects that 
    --  DSPPGMREF knows about an object, to an essentially unlimited depth.

    -- There are two places you need to change the library name, following
    -- a comment like this:  -- <<<<<< Change this table library >>>>>>>

    CREATE OR REPLACE PROCEDURE PGM_REFS (
         IN p_INLIB     varCHAR(10)
        ,IN p_INPGM     varCHAR(10)
        ,IN p_INTYPE    varCHAR(10) default '*PGM'
        ,in p_Depth     integer     default(0)
        )

    So, The program accepts four parameters initial library, initial program, initial program type and depth 

    As to your 1st question my first thought is it will list programs, modules and files per the program definitions. It will not be checking the QCMDEXC commands, though

    As to your 2nd question, DSPPGMREF command does not check source files. It checks the compiled objects

    As to your 3rd question, CALL MYLIB/Thispgm ('*ALL' , '*ALL'  ,'*ALL' ,0' ) will list  per the DSPPGMREF help "The information is shown for all programs and query definitions in the library or libraries" , . Keep in mind what objects the user profile has authority to and that probably it will list the operating system programs too. Also I assuming pgm_refs.sql is compiled as thispgm, in library MYLIB

    For reference, The 3rd parameter for the progam is type. Type in DSPPGMREF "Specifies the object type for which information is displayed", per the green screen help. DSPPGMREF command accepts "ALL" "*PGM   " "*SQLPKG" "*SRVPGM" "*MODULE" and "*QRYDFN" as types



    ------------------------------
    Carlos Romero
    ------------------------------



  • 17.  RE: Regarding DSPPGMREF

    Posted Fri February 09, 2024 09:32 PM

    Dear Jerry

    Run SQL Script tool is good for running all kinds of SQL in DB2i and getting information relevant to tuning SQL performance of individual statement. Do a Google search and search in Youtube on "ibm i run sql scripts" and you will find more useful information on this great tool. 

    I do not have sufficient experience to answer all your questions but I suspect you may get it by doing Metadata query (SELECT relevant columns) to DB2i Catalog Views in QSYS2 library such as shown in the picture below.    If you have further question relating SQL in DB2i, I suggest you ask your future questions in SQL group of this community.



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 18.  RE: Regarding DSPPGMREF

    Posted Mon February 12, 2024 02:01 PM

    Hi,

    Thanks for all these answers.

    I have couple of more questions with this respect to this utility as it uses stored procedure in this example and shows references of service programs as well..

    1) Can we know all the stored procedure names as well  using this DSPPGMREF utility (this GITHUB program ?) , if not then how to know their names, how to idenify them and distinguish them from a normal RPGLE ,SQLRPGLE,CLLE or any other IBM i object ?

    2) how to call them ? ( here it was called using RUNSQLSTM or right click on 'RUN SQL SCripts' options ) what is their object type ? ( here for this PGM_REFS it was found to be 'CLE' so is this the only object type of stored procedures always ( i mean for all type of stored procdures with in IBM i ?)

    3) 

     If a service program is being reffered by any program object then is it mandatry that  it's being called from the main
    program object or it's reference just exists (here in DSPPGMREF REFS Table) becuase it was just needed to compile that program object ?

    Thanks




  • 19.  RE: Regarding DSPPGMREF

    Posted Mon February 12, 2024 08:55 PM

    Dear Jerry

    1) You do a query to QSYS2.SYSPROCS catalog view to see all the procedure's names. Normal RPG/CL/COBOL/C programs do not appear in QSYS2.SYSPROCS catalog view. 

     

    2) You call a DB2i procedure from ANY SQL interface within (such as embedded SQL, RUNSQL command) or outside of IBM i (such as Run SQL Scripts tool, ODBC, JDBS, DRDA).  A DB2i procedure exists as a *PGM object type with an attribute of CLE (ILC C program -this applies to purely SQL procedure as well) or RPGLE (ILE RPG). 

    3) CREATE PROCEDURE statement in SQL does an equivalent of program object ceation in native IBM i. 

    For more information on procedure, you should read this IBM i redbook : SQL Procedures, Triggers, and Functions on IBM DB2 for i at  https://www.redbooks.ibm.com/abstracts/sg248326.html



    ------------------------------
    Chance favors only the prepared mind.
    -- Louis Pasteur
    ------------------------------
    Satid S.
    ------------------------------



  • 20.  RE: Regarding DSPPGMREF

    Posted Tue February 13, 2024 03:02 AM
    Edited by Christian Jorgensen Tue February 13, 2024 03:02 AM

    Hi,

    When using code from a GitHub repository, you should ask for help on GitHub, not here. It is my experience, that the creators/maintainers of open source utilities are more than willing to help using their utility and fix any errors encountered using it.

    So create an issue here: https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code/issues

    and you will get expertise support from the creator himself.



    ------------------------------
    Christian Jorgensen
    IT System Administrator
    Network of Music Partners A/S
    ------------------------------



  • 21.  RE: Regarding DSPPGMREF

    Posted Tue February 27, 2024 07:34 AM

    suppose i have created a file based on caller name and caller library using this program and then i want to compare it with the file (which is created as a out file of  using DSPOBJD  for all the *pgm objects in the system) then how to get the records (unique caller name, unique caller_library) matching from this out file whose last used date is with in 1 year from today's date ?

    thanks



    ------------------------------
    jerry ven
    ------------------------------



  • 22.  RE: Regarding DSPPGMREF

    Posted Tue February 27, 2024 12:17 PM

    Hi,

    I tried below SQL queries to get the count of such records but none of these worked , could someone please share the corrected SQL query to get the desired result here?

    1) SELECT COUNT(*)                                                    
    FROM (                                                             
      SELECT DISTINCT t1.CALLER_NAME, t1.CALLER_LIBRARY                
      FROM lib2/f2                                                       
      INNER JOIN lib1/f1                                        
      ON testfile.ODOBNM = t1.CALLER_NAME AND f1.ODLBNM =        
    f2.CALLER_LIBRARY                                                  
      WHERE DATE(                                                      
        SUBSTR(testfile.ODUDAT,5,2) || '-' ||                          
        SUBSTR(testfile.ODUDAT,1,2) || '-' ||                          
        SUBSTR(testfile.ODUDAT,3,2)                                    
      ) >= CURRENT_DATE - 365                                          
    ) AS temp                                                          
    ****************

    2)

    SELECT COUNT(*)                                               
    FROM (                                                        
      SELECT DISTINCT f2.CALLER_NAME, f2.CALLER_LIBRARY           
      FROM lib2/f2                                                  
      INNER JOIN lib1/f1                                    
      ON f1.ODOBNM = f2.CALLER_NAME AND testfile.ODLBNM =   
    f2.CALLER_LIBRARY                                             
      WHERE DATE(                                                 
        CONCAT('20', SUBSTR(DIGITS(testfile.ODUDAT),5,2)),        
        CONCAT(SUBSTR(DIGITS(testfile.ODUDAT),1,2),               
        CONCAT(SUBSTR(DIGITS(testfile.ODUDAT),3,2))               
      ) >= CURRENT_DATE - 1 YEAR                                  
    ) AS temp                  

    Note :- f1 is a file created using DSPOBJD for all the program objects in the system in a library let's say in 'lib1'.

    and f2 is the file created in a library let's say 'lib2' when I ran this DSPPGMREF program (GitHub link) which has this caller_name,caller_library etc. details in it.

    Thanks                      



    ------------------------------
    jerry ven
    ------------------------------



  • 23.  RE: Regarding DSPPGMREF

    Posted Wed February 28, 2024 02:29 AM

    Anyone has any idea on the same please? 

    Thanks. 




  • 24.  RE: Regarding DSPPGMREF

    Posted Thu February 29, 2024 02:03 AM

    Sorry, for being a little late ... and may be someone already answered your question correctly ...

    The problem is the SQL Call! Parameters must be separated by a comma (and not just by a blank).



    ------------------------------
    Birgitta Hauser
    Database and Software Engineer
    Selfemployed - Modernization-Education-Consulting on IBM i
    Kaufering
    +49 170 5269964
    ------------------------------