ibm-midrangecontrol-language

Create iSeries command that accepts an object name as a parameter


I'm trying to create a new command on an iSeries, where one of the parameter has to be a file name using the standard LIBRARY/FILE MEMBER syntax, something like

MYCMD FILE(MYLIB/MYFILE MYMEMBER)

or even

MYCMD FILE(MYLIB/MYFILE) MEMBER(MYMEMBER)

I tried to :

But I can't find how to create a parameter that accepts a value that is a qualified object name, like the FROMFILE parameter used with CPYTOIMPF.

UPDATE

JamesA's answers works fine, but somehow I get two extra characters in my CL's variable :

CMD

            PARM       KWD(FILE) TYPE(FNAME) PROMPT('CL +                  
                         source' 1)                                        
FNAME:      ELEM       TYPE(FILE) PROMPT('File')                        
            ELEM       TYPE(*NAME) LEN(10) PROMPT('Source +                
                         member')                                          
FILE:       QUAL       TYPE(*NAME) LEN(10)              
            QUAL       TYPE(*NAME) DFT(*CURLIB) SPCVAL(*CURLIB) PROMPT('Library') LEN(10) MIN(0)           

CL

PGM        PARM(&PFIC &OUTFILE &CODEPAGE)        
DCL        VAR(&PFIC) TYPE(*CHAR) LEN(32)        
DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)         
DCL        VAR(&FILE) TYPE(*CHAR) LEN(10)        
DCL        VAR(&MEMBER) TYPE(*CHAR) LEN(10)      

CHGVAR     VAR(&FILE) VALUE(%SST(&PFIC 3 10))  
CHGVAR     VAR(&LIB) VALUE(%SST(&PFIC 13 10))              
CHGVAR     VAR(&MEMBER) VALUE(%SST(&PFIC 23 10))     

Solution

  • You need to use a Qualifier Definition.

    CMD

        CMD
        PARM KWD(FILE) TYPE(Q1) PROMPT('File')
        PARM KWD(MBR) TYPE(*NAME) LEN(10) DFT(*FIRST) SPCVAL(*FIRST) PROMPT('Member')
    
    Q1: QUAL TYPE(*NAME) LEN(10) 
        QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) SPCVAL(*LIBL) PROMPT('Library')
    

    CL

    PGM PARM(&FILELIB &MBR)
    
    DCL VAR(&FILELIB) TYPE(*CHAR) LEN(20)
    DCL VAR(&MBR) TYPE(*CHAR) LEN(10)
    DCL VAR(&FILE) TYPE(*CHAR) LEN(10)
    DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
    
    CHGVAR VAR(&FILE) VALUE(%SST(&FILELIB 1 10))
    CHGVAR VAR(&LIB) VALUE(%SST(&FILELIB 11 10))
    
    . . .
    
    ENDPGM