How to create AS/400 user defined commands

425 pts.
AS/400 commands
AS/400 user permissions
User Defined Fields
I tried to create user defined command, but couldn't understand the paramters to input in CRTCMD.

CMD          > MSG                    >   MYLIB PGM          > MESSAGE                >   MYLIB SRCFILE        QCMDSRC                    *LIBL   SRCMBR         *CMD      THDSAFE        *NO 

Here, I have created one CLP MYLIB/MESSAGE to run just one simple command DSPMSG. however I'm not sure what values to be input at SRCFILE. but few times when I tried I got the problem.. that command not created.

Do we need to create the source file for command pioir to run CRTCMD?

pls help me. thanks in advnace..

Software/Hardware used:

Answer Wiki

Thanks. We'll let you know when a new response is added.


If using PDM, take option 3 = Work with members, your file will be QCMDSRC, your library will be MYLIB, Press Enter. Press F6= Create new source member, the source member will be MESSAGE, the type will be CMD, Press Enter. You should have a blank source member. Enter CMD and Press F3 to Exit and Press Enter to confirm creating the source member.

Page up or down until you find your member MESSAGE. Enter 14 to compile and press F4. You should see MESSAGE as your command, MYLIB as your Library, MESSAGE as the program to process your command (This is your CL program), and Enter MYLIB for the library where the CLP exists. Press Enter and your command should be created.

Hope this helps,
Bill Poulin

Discuss This Question: 4  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TomLiotta
    I'm not sure what values to be input at SRCFILE. A command has source, just like your CL program has source. The command source defines things like how what parameters your command will have, what the data types and sizes the parameters will be, what requirements there are for parameters, what relationships exist for the parameters, what messages will be displayed for possible error conditions and other details. The minimum source is just a CMD command. Put CMD into a source member in a source file. That will be the entire source and that will be compiled by the CRTCMD command. Usually, the source will have one source line for the CMD statement, and that will be followed PARM statements for the parameters. If you want to see what a CMD or PARM statement looks like, you can type CMD or PARM on a command line a press F4=Prompt. The source for commands consists of a few special CL commands. Off the top of my head, others are QUAL, ELEM and DEP. They are entered into a source member the same way you entered commands for your CL program. Tom
    125,585 pointsBadges:
  • Sms121
    To create User defined command , You have to first create CMD source in your source file. *(Ex:- Open CMD1 source file whose extension is cmd and just write cmd in that file and close it , You should not compile it) Now , Type CRTCMD then followin parameter you have to specify 1) Command : --- Which you want to create. 2) Library:-- In which library you want to create that command , specify it. 3) program to process Command:-- Your CLP program name. 4) Library:- In which library Your CLP program object is present. 5) Source File:-- Specify file name in which CLPprogram source is present 6) Library:- Library name of source file. 7) Source member:- specify the name of CMD source ( Menas Name of CMD1 see above Example) And after that press enter your command will create successfully.
    185 pointsBadges:
  • WoodEngineer
    Don't know if this will help but a picture can be worth a thousand words. This is the code for a simple command we recently developed.
     Columns . . . :    1  80                                       Edit                     
     FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 
            *************** Beginning of data ***********************************************
    0001.00              CMD        PROMPT('Xmit customer/carrier data') /* CPP +            
    0002.00                                                           = TRANSC82 */          
    0003.00              PARM       KWD(COMPANY) TYPE(*CHAR) LEN(2) DFT(01) +                
    0004.00                           RANGE(01 99) FULL(*YES) PROMPT('Company')              
    0005.00              PARM       KWD(DATA) TYPE(*CHAR) LEN(1) RSTD(*YES) +                
    0006.00                           DFT(*BOTH) SPCVAL((*CUSTOMERS C) +                     
    0007.00                           (*CARRIERS T) (*BOTH B) (*CUSTRUCK W)) +               
    0008.00                           PROMPT('Data to transmit')                             
    0009.00              PARM       KWD(TRANSMIT) TYPE(*LGL) RSTD(*YES) +                    
    0010.00                           SPCVAL((*YES '1') (*NO '0')) MIN(1) +                  
    0011.00                           PROMPT('Transmit to TransWorks')                       
    0012.00              PARM       KWD(DATEESTAB) TYPE(*DATE) DFT(*ALL) +                   
    0013.00                           SPCVAL((*ALL 010180) (*TODAY 123139)) +                
    0014.00                           PROMPT('Send if cust added on/after')                  
    0015.00              PARM       KWD(FORCECTRK) TYPE(*LGL) RSTD(*YES) +                   
    0016.00                           DFT(*NO) SPCVAL((*YES '1') (*NO '0')) +                
    0017.00                           MIN(0) PROMPT('Force customer truck +                  
    0018.00                           transmit')                                             
            ****************** End of data **************************************************
    6,955 pointsBadges:
  • Kar
    Dear All, Thank you all for your valuable answers, I'm now able to work on user defined commands... Now I'll try using input value for COMMAND PARM and will let you know my understandings. -Kart!
    425 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: