Home > AS/400 Tips > iSeries programmer tips > User-defined commands to the rescue
iSeries 400 Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

ISERIES PROGRAMMER TIPS

User-defined commands to the rescue


Eitan Rosenberg
05.14.2001
Rating: -3.12- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


I have been noticing that many programmers are neglecting one of the nicest things on the AS/400: user define commands.

We use AS/400 commands all day long. Why not use commands for our own applications?

Have you ever had to convert numbers to strings just to send them as parameters?

Have you ever had to define CLP numeric parameter as 15(5) just to send a numeric parameter from the command line?

Have you ever had to call a program using hexadecimal format just to send a numeric parameter as pack (e.g. X'12345F') ?

If you answered yes, continue reading ...

We will be viewing a technique for submitting a report using a homegrown command.

* Please note that the parmeters go through with no hassle.
* It is possible to prompt on the command like any other AS/400 command.
* Commands source usually reside in QCMDSRC.



Code

Source for command DEM601C 
********************************************* 
- Note the usage of DFT keyword 
- The JOBTYP will control the flow of the program 
         I = prompt the user & submit the job 
         B = Go directly to the batch processing part 
         (Very useful if you want to debug the application interactively without 
         using STRSRVJOB) 
        
        
             CMD        PROMPT('Command usage sample') 

             PARM       KWD(JOBTYP) TYPE(*CHAR) LEN(1) RSTD(*YES) + 
                          DFT(I) VALUES(I B) PROMPT('Job type') 

             PARM       KWD(DATE_F) TYPE(*DEC) LEN(8 0) PROMPT('From + 
                          Date') 
             PARM       KWD(DATE_T) TYPE(*DEC) LEN(8 0) PROMPT('To   + 
                          Date') 

             PARM       KWD(PART_C) TYPE(*CHAR) LEN(10) PROMPT('Part + 
                          code') 
             PARM       KWD(TRAN_C) TYPE(*CHAR) LEN(4) DFT(IS02) + 
                          PROMPT('Transaction code') 

Source for display file DEM601C 
********************************************* 

     A                                      DSPSIZ(24 80 *DS3) 
     A                                      INDARA 
     A                                      PRINT 
     A                                      ERRSFL 
     A                                      CF03(03) 
     A                                      CF21(21) 
     A          R REQUSET 
     A            JOBTYP         1A  H      TEXT('Job type') 
     A                                  5  2'Date range.........' 
     A            DATE_F         8Y 0B  5 22EDTWRD('  /  /    ') 
     A                                      DSPATR(CS) 
     A                                  5 33'-' 
     A            DATE_T         8Y 0B  5 35EDTWRD('  /  /    ') 
     A                                      DSPATR(CS) 
     A                                  7  2'Part code..........' 
     A            PART_C        10A  B  7 22 
     A                                  9  2'Transaction code...' 
     A            TRAN_C         4A  B  9 22 
     A                                 23  3'F3=Exit' 
     A                                      COLOR(BLU) 
     A                                 23 16'F21=Print list' 
     A                                      COLOR(BLU) 

Source for CL program DEM601C 
********************************************* 

             PGM        PARM(&JOBTYP &DATE_F &DATE_T &PART_C &TRAN_C) 

             DCLF       FILE(DEM601C) 

             IF         COND(&JOBTYP = B) THEN(DO) /* Jump to Batch */ 
             GOTO       CMDLBL(BATCH) 
             ENDDO 

 REQUEST:    SNDRCVF    RCDFMT(REQUSET) 

             IF         COND(&IN21) THEN(DO) 
             SBMJOB     CMD(DEM601C JOBTYP(B) DATE_F(&DATE_F) + 
                          DATE_T(&DATE_T) PART_C(&PART_C) + 
                          TRAN_C(&TRAN_C)) LOG(4 00 *MSG) 
             ENDDO 

             IF         COND(&IN03) THEN(DO) 
             RETURN 
             ENDDO 

             GOTO       CMDLBL(REQUEST) 

             RETURN 

/*==================================================================*/ 
 BATCH: /* Batch processing part */ 

             ENDPGM 
             
************************************************************

Rate this Tip
To rate tips, you must be a member of Search400.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
iSeries programmer tips
Enhancing RPG with external SQL stored procedures
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
Implementing a browser interface in COBOL: Displaying database fields
Taking advantage of CL advancements, starting with V5R3
TAATOOL: Useful tools for programmers on IBM i
Implementing a browser interface in COBOL: Creating your graphic Web page
Implementing a browser interface in COBOL: Getting started
Making the most of RPG data handling on IBM i
Groovy programming on IBM i

RPG iSeries programming
Enhancing RPG with external SQL stored procedures
Introduction to SQLRPGLE on IBM i: Making a report
Making the most of RPG data handling on IBM i
IBM i shop boosts online sales with RPG-based Web platform
Migrating from RPG to EGL on IBM i
Allow access to data from a stored procedure result set using COBOL or RPG
EGL Rich UI on IBM i: Do you Dojo?
Programming for the Web on the IBM i, what is possible
A taste of COMMON: ILE, IBM releases, Web applications and new products
Documenting nested program structures on the AS/400

iSeries ILE programming
Tracking data changes on IBM i with triggers
Introduction to SQLRPGLE on IBM i: Making a report
How to use an embedded SQL statement and display the result in a subfile
Eight steps for creating program documentation using AS/400 utilities
Searching fields for values
Searching part of a name or address in AS/400
Top 10 programmer tips YTD
How to use the binder language to manage service programs -- Part 3: Examples and pitfalls
Top 10 programmer tips of 2005
Understanding the binder language on AS/400

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Report Program Generator  (Search400.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



iSeries Security - Security Tools, Physical Security and System Security
HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts