ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Front End to IBM Command

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

  • Front End to IBM Command

    I am in the need of creating a front end to the STRSQL command. If someone keys the STRSQL command from the command line I want it to call a CL that will perform a couple of things before the STRSQL command is actually run. What I'm doing now is I have created a library called PRXQSYS that is above QSYS in the system library list. I created a new STRSQL command (with no parameters) in that library that uses a CPP that I have created that will do the things I want and then run QSYS/STRSQL in the new CPP.

    This works great EXCEPT if the user prompts the new PRXQSYS/STRSQL command (using F4) I need somehow to pass that along to the new CPP and use the question mark (?) in front of the QSYS/STRSQL command to allow the user to change the parameters.

    Can I do this? Any other suggestions?

  • #2
    Might be a prettier way of doing it but maybe give the user the option in your PRXQSYS/STRSQL command to display the STRSQL prompt?

    So the PRXQSYS/STRSQL command passes a variable to your CL, if it's Y show ? STRSQL if it's N show STRSQL

    Example;

    Code:
    CMD        PROMPT('STRSQL')                           
    PARM       KWD(PROMPT) TYPE(*CHAR) LEN(1) DFT('N') +  
                 CHOICE('Y OR N') PROMPT('Display STRSQL +
                 prompt?')
    Code:
    PGM        PARM(&PROMPT)                          
    
    DCL        VAR(&PROMPT) TYPE(*CHAR) LEN(1)        
    
    
    /* DO SOMETHING */                                
    
    
    IF         COND(&PROMPT = 'Y' *OR &PROMPT = 'y') +
                 THEN(DO)                             
    ?          STRSQL                                 
    ENDDO                                             
    
    IF         COND(&PROMPT = 'N' *OR &PROMPT = 'N') +
                 THEN(DO)                             
    STRSQL                                            
    ENDDO                                             
    
    ENDPGM

    Comment


    • #3
      Heh. That is exactly what I just did as a workaround.

      Genius minds think alike, huh????

      Thanks!!!!

      Comment


      • #4
        Apologies, I misread what you put - I thought it said CLP (CL Program) not CPP - I'm not sure what a CPP is.

        I also made a couple of mistakes;

        DFT changed from 'N' to N in comand source;
        Code:
        CMD        PROMPT('STRSQL')                           
        PARM       KWD(PROMPT) TYPE(*CHAR) LEN(1) DFT(N) +    
                     CHOICE('Y OR N') PROMPT('Display STRSQL +
                     prompt?')
        MONMSG put in to capture user cancelling the prompt and end program accordingly;
        Code:
                    PGM        PARM(&PROMPT)                           
        
                    DCL        VAR(&PROMPT) TYPE(*CHAR) LEN(1)         
        
        
                    /* DO SOMETHING */                                 
        
        
                    IF         COND(&PROMPT = 'Y' *OR &PROMPT = 'y') + 
                                 THEN(DO)                              
                    ?          STRSQL                                  
                    MONMSG     MSGID(CPF6801) EXEC(GOTO CMDLBL(ENDPGM))
                    ENDDO                                              
        
                    IF         COND(&PROMPT = 'N' *OR &PROMPT = 'N') + 
                                 THEN(DO)                              
                    STRSQL                                             
                    ENDDO                        
        
        
        ENDPGM:     ENDPGM

        Comment


        • #5
          Ah right, fair enough! Glad you sorted it

          Comment


          • #6
            CPP is the "command processing program" which is a CLP.

            Comment


            • #7
              Oh and thanks for the MONMSG heads up. I had forgotten about that, too! :-)

              Comment


              • #8
                That is really not the best way to deal with it, IMO. This allows for IBM like commands to be put in place that can do nefarious functions. It would be better to create a different command to be used that ultimately calls STRSQL and not put ANY user libraries above QSYS. This is the one thing that has kept me from considering MAXAVA for DR is the practice of requiring their library above QSYS.

                Comment


                • #9
                  Any chance that you could use an exit point, here, instead of putting your own command ahead of IBM's? That would allow you to use the original command without problems, but still insert your own processing into it. But, not everything can be done that way, so I guess it depends on what you're trying to acccomplish.

                  To me, passing a parameter telling it to prompt the command is absolutely awful. It trains your users to do basic things like prompting in a non-standard way.

                  Then there's the security issue that Rocky points out (though, simply restricting authority to your special library would solve that.)

                  Comment


                  • #10
                    I thought about an exit program but really got confused whether it would do what I wanted or not. I want to execute the STRDBMON before the STRSQL command is run so I can capture what is being performed during the STRSQL session. Then when STRSQL is exited I would execute the ENDDBMON. Then if there is a question about someone's usage of STRSQL we have a trail.

                    Hope you are doing well, Scott. Haven't talked since I left ICS....

                    Comment


                    • #11
                      I'd create an alternate command that does STRDBMON, STRSQL and ENDDBMON and remove access to STRSQL to all users - they HAVE to use the new command before I'd put a library above QSYS - it just goes against the grain for me... but i do tend to be OCD about some things.

                      Alternatively I do have CONTROLER from Cilasoft (now Syncsort) that would accomplish all of this w/o modifying anything.

                      Comment

                      Working...
                      X