Link to home
Start Free TrialLog in
Avatar of Theo Kouwenhoven
Theo KouwenhovenFlag for Netherlands

asked on

Required parameter in Command

Hi experts,

First my command source then the quiestion:

             CMD        PROMPT('Archive PF Member (Multiple)')        
             PARM       KWD(FILE) TYPE(QUAL1) MIN(1) PROMPT('File +  
                          name')                                      
                                                                     
             PARM       KWD(ARCH) TYPE(QUAL2) MIN(1) PROMPT('Archive +
                          name')                                      
                                                                     
             PARM       KWD(RET) TYPE(*CHAR) LEN(1) RSTD(*YES) +      
                          DFT(*PERIOD) SPCVAL((*PERIOD P) (*DATE +    
                          D)) MIN(0) PROMPT('Retention type')        
                                                                     
             PARM       KWD(RETPER) TYPE(*DEC) LEN(2) PMTCTL(PCTL1) +
                          PROMPT('Retention period in month')        
                                                                     
             PARM       KWD(RETDAT) TYPE(*DEC) LEN(8) PMTCTL(PCTL2) +
                          PROMPT('Retention date')                    
                                                                     
QUAL1:      QUAL       TYPE(*NAME)                                
            QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +          
                         SPCVAL((*LIBL)) PROMPT('Library')        
                                                                 
QUAL2:      QUAL       TYPE(*NAME)                                
            QUAL       TYPE(*NAME) LEN(10) DFT(*LIBL) +          
                         SPCVAL((*LIBL)) PROMPT('Library')        
                                                                 
 PCTL1:      PMTCTL     CTL(RET) COND((*EQ 'P'))                  
 PCTL2:      PMTCTL     CTL(RET) COND((*EQ 'D'))                  


The prompt for parms RETPER and RETDAT are depending on the contents of parm ret.
The displayed parm is required, but when I use the MIN(1) option I get the error:
  PMTCTL not allowed for required parameter.

I think it must be simple  to do this with one of the options in the command source,
but how???

Regards,
Murph
Avatar of ShadowProgrammer
ShadowProgrammer

Murph,

Not exactly sure which parameter you are specifying MIN(1) for ???

But I tried to specify MIN(1) for parameter RET and got the error
"Default value not allowed for required parameter, element, or qualifier."

This basically means if you want a parameter to be required - you can't specify a default.... and you are deafaulting the special value "*PERIOD"...  so either remove the default or stick with MIN(0)...

If it's another parameter you are trying to specify MIN(1) on let me know which one....

Tony.
Murph,

just tried MIN(1) against parameter RETPER and got the error message you stated in the question...

Basically you can't specify that the parameter must have a value entered [MIN(1)] because the parameter has a prompt control defined  - if it allowed this you could end up with the user having to enter a value for a parameter that is not displayed !!!  I know what you mean though - it should only require a value if actually prompted - but I don't think IBM cater for this.

If you want to ensure you get a value for the appropriate parameter depending on a prompt control, then I think you need to either
(a) write a command validation program to validate the parameters - so that the user is informed at the time of entering the command of any errors and these must be corrected before continuing and actually calling the command program. (refer to IBM manuals for writing Validity checking programs).
or
(b) validate the parameters in your command program and inform the user the program failed.

Tony.
Avatar of Theo Kouwenhoven

ASKER

Hi ShadowProgrammer,

I SOLVED THE PROBLEM..!!!

Its not option (a) nor option (b)..... option (c) solved my problem hahahaha.
I fond the DEP statement...... that is the check I was looking for.

PARM       KWD(RET) TYPE(*CHAR) LEN(1) RSTD(*YES) +      
             DFT(*PERIOD) SPCVAL((*PERIOD P) (*DATE +    
             D)) MIN(0) PROMPT('Retention type')        
                                                         
PARM       KWD(RETPER) TYPE(*DEC) LEN(2) +        
             PMTCTL(PCTL1) PROMPT('Retention period in +
             month')                                    
DEP        CTL(&RET *EQ 'P') PARM((&RETPER *GT 0)) +    
             MSGID(CMD0001)                              
                                                         
PARM       KWD(RETDAT) TYPE(*DEC) LEN(8) DFT(19950101) +
             PMTCTL(PCTL2) PROMPT('Retention date')      
DEP        CTL(&RET *EQ 'D') PARM((&RETDAT *GT +        
             19950101)) MSGID(CMD0002)                  
                                                         

Thanks for your respons...

Regards,
Theo
Theo,

I'd forgotten about option (c) as well     8-)

Don't forget to get the question deleted, closed  or whatever it is when you solve the question yourself...

Tony
Hey,
I suggest that the question is refunded and PAQed
ASKER CERTIFIED SOLUTION
Avatar of CetusMOD
CetusMOD
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial