Astradyne (UK) Ltd


 

Instructions

The following is a list of source members for techniques, examples and tools that we hope you may find useful. Please note, that whilst the program and related source have been made available for public use, all copyright is retained by Astradyne (UK) Limited and permission is granted for the use of source for non-profit, non-commercial use only. For all other usage, please contact us directly.

Additional source members will be added over time. Please check back regularly.

To view any source, position your mouse over the appropriate title and click.


Source Code

API Example: QLICOBJD - Change Object Description
Example of using this API to change the user attribute for an object. We use this attribute internally to store a version/build reference that is updated every time an object is promoted from the development environment.

API Example: QLICOBJD - Change Object Description - Modify the Source File & Member Fields for an Object
This is a CL example of using the QLICOBJD API to modify which source file and member an object was created from. This is particularly useful for modules created with embedded SQL as the SQL precompiler generates a temporary source member in QTEMP for compilation to the finished module.

API Example: QSPOLJBQ - Open List of Job Queues
An RPG ILE program that demonstrates the use of the QSPOLJBQ system API by displaying a list of all jobq queues in QGPL

ILE Toolkit: Remove Trailing Zeros from Numeric Value for Printing/Display
Sub-procedure to remove trailing zeros from the decimal portion of a value, for example 123.4560000 is formatted as 123.456.

ILE Toolkit: Retrieve Data Area (RtvDtaAra) Sub-Procedure
Sub-procedure to retrieve the contents of a data area.

ILE Toolkit: Retrieve Message Description (RtvMsg) Sub-procedure
A simple sub-procedure that calls the QMHRTVM system API to retrieve a message description from a message file, populating any message data fields as required.

ILE Toolkit: Retrieve OS/400 Version
Sub-procedure to retrieve the OS/400 version using the Retrieve Product Information (QSZRTVPR) system API.

ILE Toolkit: Retrieve System Value (RtvSysVal) Sub-Procedure
A sub-procedure that can be used to retrieve system values into an ILE program.

Programming: Converting Dates in ILE RPG
Various techniques for converting dates between formats and data types in RPG.

SQL: Using Embedded SQL to Perform Dynamic Calculations
If you have a need to evaluate dynamic calculations in RPG, you can use embedded SQL to make this easier. The example source below provides two sub-procedures; Calculate and SubValue, that can be used to replace variables within a formula with their values and to perform the actual calculation.

SQL: Using SQL PREPARE and VALUES INTO to Dynamically Summarise Records in a Table
This is an example of using the VALUES INTO statement within embedded dynamic SQL to select the total amount of orders for a specified account.

SQL: Using SQL PREPARE to read from different files
An example showing how to use the SQL PREPARE statement to allow the selection of data from a user defined file within an ILE RPG program.

Technique: Passing Variable Number of Parameters Between Programs
You can call a program without passing the expected number of parameters by using the %PARMS built-in function in the called program and using it to determine which parameters (if any) were passed. The trick is to only refer to the parameter variable if it was passed otherwise you will get a pointer/resolve error. To do this, define work variables that will be populated with the parameter values by your program and refer to these in the rest of your code.

Technique: Using Date Type Fields Instead of Numeric Fields for Date Handling
Example of how using date type fields for date handling can make life so much easier.

Technique: Using INDARA Instead of Indicators to Condition Display Files
Each display file and printer file can have it's own set of indicators assigned by specifying the INDARA keyword within the DDS. This can help to get around the 99 indicator limitation imposed by the RPG language. The sample code below shows an example display file and associated RPG IV program that demonstrate the use of the INDARA indicators and how they differ to the standard RPG conditioning indicators.

Technique: Using Named Indicators in ILE RPG IV
This technique shows an example of assigning names to the standard *INxx conditioning indicators available within an ILE RPG IV program. Naming indicators allows for easier understanding and readability of your programs.

Technique: Using P-Fields to Control Display File Attributes
Traditionally most programmers tend to use conditioning indicators within their display file DDS to control the use of attributes such as colour, reverse image, blink, position cursor, etc. While this is straightforward, it can be cumbersome and cause confusion when debugging your program and there is another way. <BR><BR> By using what are known as P-Fields, you can assign a single character field to an input or output field on your display file and then assign the P-field the hexadecimal attribute value that you want to assign the field. The example code below shows how to assign and use P-fields.

Toolkit: Check if Spool File Exists (CHKSPLF)
This is a simple CL program that calls the Retrieve Spool File Attributes API (QUSRSPLA) to determine if a a spool file exists within a given job. The program returns a value of '1' if the spool file exists, and a value of '0' if it doesn't.

Tools: Bounce System (BNCSYS) - Automated Full System Save and Reboot
CL program and command to automate and schedule a full system save that we have been using since V4R5. The command must be run from the system console. There are a couple of things to note:

a) The program makes reference to a LOCKOUT command which we use in-house as part of our initial programs for users to lock them out of the system when required,
b) a log of messages is sent to message queue SYSLOG in library AUKSYS, change this to suit your environment,
c) status messages are listed at the end of the source from message file AUKMSG, add or change these as needed.

Tools: Command to open a Web Page Using Installed Browser (LOADWEB)
Following a thread on the Midrange.Com website the following command and CL program provides the ability to launch a website in a browser from the AS/400, iSeries or System i. The command can also be run from RPG by placing a call to an execution routine such as QCMDEXEC, QCAPCMD, System(), etc.

Tools: Copying multiple spool files to one TXT file and emailing with DST
An example CL program that will copy all spool files with a USRDTA attribute of "COPY_ME" on a specified output queue to a single TXT file and email the TXT file to a hard coded email address.

Tools: Email Spool File (EMAILSPLF) Command
A command and CL program that can be used to email a spool file to a specified email address. This command uses SMTP by way of the SNDDST command to perform the actual send. The command requires that a folder is available within the IFS to store temporary emails. The default name used is EMAIL and this can be created using the CRTFLR FLR(EMAIL) command. If a different folder is used then change the variable &amp;FLR within the CPP.

Tools: UPS Monitor - UPSCLNUP (UPS Clean Up)
Cleanup routine for UPS Power Management suite. This routine restarts processes after they were closed down by the UPSPWRMGR routine. The routine uses ROBOT/Alert to send an SMS text message to IT personnel.

Tools: UPS Monitor - UPSCONTROL (UPS Controller)
Contolling CL routine for a UPS handling suite. The programs are written in CLP and could form a basis for the development of your own in-house power management routines. UPSPREPARE, UPSCLNUP and UPSRESET also form a part of this suite.

Tools: UPS Monitor - UPSPREPARE (UPS Preparation Routine)
UPS Preparation routine for UPS Power Management suite. This routine prepares the UPS Power Management process for use.

Tools: UPS Monitor - UPSRESET (UPS Reset)
Reset routine for UPS Power Management suite. This routine resets the UPS Power Management process once power has been restored.

SITE NAVIGATION
     » Home
     » Services
     » Links
     » Support
     » Hints & Tips
     » Downloads
     » Source Code
     » Manuals
     » Contact Us
© www.astradyne.net