AS/400 Common Commands and Programming Languages
Introduction
IBM i (AS/400) is a robust platform that utilizes various commands and programming languages to manage system operations and application development efficiently.
1. Common AS/400 Commands
System Management Commands
WRKSYSSTS
- View system statusWRKACTJOB
- Monitor active jobsWRKUSRPRF
- Manage user profilesENDJOB
- End a running jobCHGSYSVAL
- Change system values
File and Database Commands
DSPFD
- Display file descriptionWRKDBF
- Work with database filesRGZPFM
- Reorganize physical file membersSAVLIB
- Save a libraryRSTLIB
- Restore a library
Backup and Recovery Commands
SAVLIB
- Save librariesRSTOBJ
- Restore objectsDSPTAP
- Display tape informationCHKOBJ
- Check object existence
2. AS/400 Programming Languages
RPG (Report Program Generator)
RPG is the primary language for business applications on AS/400.
**Free DCL-S CustName CHAR(50); EXEC SQL SELECT NAME INTO :CustName FROM CUSTOMERS WHERE ID = 1001; DSPLY CustName; *INLR = *ON;
CL (Control Language)
CL is used for system automation and job control.
PGM DCL VAR(&USER) TYPE(*CHAR) LEN(10) RTVJOBA USER(&USER) SNDPGMMSG MSG('Current user: ' *CAT &USER) ENDPGM
COBOL
COBOL is used for legacy business applications.
IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE. DATA DIVISION. WORKING-STORAGE SECTION. 01 CUSTOMER-NAME PIC X(50). PROCEDURE DIVISION. DISPLAY "Enter Customer Name: ". ACCEPT CUSTOMER-NAME. DISPLAY "Customer: " CUSTOMER-NAME. STOP RUN.
SQL (Structured Query Language)
SQL is used to interact with DB2 databases.
SELECT CUST_ID, NAME FROM CUSTOMERS WHERE STATUS = 'ACTIVE';
Java on AS/400
Java can be run using the IBM i Java Virtual Machine.
import java.sql.*; public class AS400DBTest { public static void main(String[] args) throws Exception { Connection conn = DriverManager.getConnection("jdbc:as400://myserver", "user", "password"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM CUSTOMERS"); while (rs.next()) { System.out.println(rs.getString("NAME")); } conn.close(); } }
Conclusion
AS/400 supports multiple programming languages and commands, allowing flexibility in system administration and application development.