Friday, February 29, 2008

Colorized Commands:

These days, virtually everyone knows how to add hex codes in their source code to add color to their source. Examples of hex characters that may be used are x'22' for white or high intensity and x'38' for pink. This same technique works to add color to command prompts.
While creating the source for your command, place a hex character as the first byte of the PROMPT parameter. After compiling the command, you will have colored prompt text within your command. The sample code in shows where to place the hex code (indicated by an x) to colorize your command. Warning: after you enter the hex code in the source, don't prompt on that statement or the entire contents within the prompt parameter will be converted to hex.

CMD PROMPT('x Command Title')
PARM KWD(FLD) TYPE(*CHAR) LEN(10) +
PROMPT('x Input parameter')

Wednesday, February 27, 2008

Secrets of CA and CF indicators:

The CF and CA keywords are used in display files to enable function keys. CF01 and CA01 both enable the F1 key on your keyboard. The difference is that a CF (command function) key updates the fields in your program, while a CA (command attention) key does not.

A CA key also bypasses any field editing. For example, if you enter a bad value into a field that has the VALUES keyword specified in the DDS and then press a CF key, you will get an error, and the screen will not be returned to the program because the field doesn't pass validation. If, on the other hand, you hit a CA key, the editing is bypassed, and the CA key is returned to the program (although the fields are not). The best use for CA keys is keys that exit a screen without updating data--typically, CA03 or CA12 in iSeries applications.

If you define CF01 or CA01 in your DDS, and the user hits the F1 key, then the *INKA indicator is turned on in your program. You can, however, specify an additional indicator to be used, by using a syntax such as CF01(01). With this keyword, F1 will turn on both *INKA and *IN01. There is no hard and fast relationship; if you specified CF01(22), F1 would turn on both *INKA an *IN22.

The indicators (*INKA through *INKY) are turned either off or on with each READ or EXFMT, depending on which function key the user pressed. Thus, there should never be more than one *INKx indicator on, and often none are on (if the user hits Enter or if one of the non-command keys is enabled, such as PageUp or Help).
Finally, any indicators specified in the DDS in the syntax CF01(nn) are set based on the setting of the associated command key.

Business Process Improvement (BPI):

Business Process Improvement (BPI) is a systematic approach to help any organization make significant changes in the way it does business. The organization may be a for-profit business, a non-profit organization, a government agency, or any other ongoing concern.
BPI works by:
• Defining the organization's strategic goals and purposes (Who are we, what do we do, and why do we do it?)
• Determining the organization's customers (or stakeholders) (Who do we serve?)
• Aligning the business processes to realize the organizantion's goals (How do we do it better?)
The goal of BPI is a radical change in the performance of an organization, rather than a series of incremental changes.
The first step in BPI is to define the organization's mission, existing structure and processes (AS-IS).
Then the BPI process owners should determine what outcomes would add value to the organization's mission and objectives (TO-BE).
Once the outcomes are determined, the organization's work force needs to be reshaped to meet the new missions and objectives, and a series of benchmarks, including cost metrics, should be put into place. It is during these latter steps that much of the resistance to BPI becomes apparent.

Monday, February 25, 2008

What characters to Trim:

%TRIM, %TRIMR & %TRIML is enhanced in V5R3 to allow an optional second parameter giving the list of characters to be trimmed.
Example:
Eval trimchars = '*-.'
Eval data = '***a-b-c-.'
result = %trim(data : trimchars)

// now result = 'a-b-c'. All * - and . were trimmed from the ends of the data

Sunday, February 24, 2008

Add color to the messages:

Usually when we send the Program messages from a CL program, the message will be shown in normal white color. We can also add color to the program messages that adds more meaning to the message sent.
If you compile the following short program and call it from a command line, you'll see what I mean.

DCL VAR(&BLUE) TYPE(*CHAR) LEN(1) VALUE(X'3A')
DCL VAR(&WHITE) TYPE(*CHAR) LEN(1) VALUE(X'22')
DCL VAR(&GREEN) TYPE(*CHAR) LEN(1) VALUE(X'20')

SNDPGMMSG MSGID(CPF9897) MSGF(QCPFMSG) MSGDTA(&BLUE +
*CAT 'This is' *CAT &WHITE *CAT 'the' +
*CAT &GREEN *CAT 'msg') MSGTYPE(*ESCAPE)

You may use more than one display attribute in a message. In the following code fragment, written for a color monitor, parts of the message are shown in blue, white, and green.
Similarly we can give the hexa values of the display attributes and add color and more meaning to our message.

Thursday, February 21, 2008

LPAR:

In computing, a logical partition, commonly called an LPAR, is a subset of computer's hardware resources, virtualized as a separate computer. In effect, a physical machine can be partitioned into multiple LPARs, each housing a separate operating system.
The technology was initially developed by IBM for mainframe architecture ESA/390 around 1990, and continued also for zSeries and System z9 architectures. However, IBM later extended the idea to non-mainframe servers, such as pSeries and iSeries, albeit with varying technical specifications. Multiple operating systems are compatible with LPARs, including z/OS, z/VM, z/VSE, z/TPF, AIX, Linux (including Linux on zSeries), and i5/OS.

Through advanced dynamic logical partitioning (LPAR) capabilities, a single partition can act as a completely separate i5/OS, Linux or AIX server. System i platforms can automatically adjust pooled processor resources across multiple operating systems, borrowing processing power from idle partitions to handle high transaction volumes in other partitions.

With LPAR on the System i platform, you have both the power and flexibility to address multiple system requirements in a single machine. LPAR supports up to 10 dynamic logical partitions per processor. So, depending upon the System i model, you can run up to 254 independent servers—each with its own processors and memory resources within a single physical System i system.

Consolidating systems with LPAR can help cut operational costs, improve availability, ease management and improve service levels, while allowing businesses to quickly deploy applications. LPAR technology can even enhance your ability to simplify networks and centralize multiple business operations.

Wednesday, February 20, 2008

Decision Support System:

Decision support systems are a class of computer-based information systems including knowledge based systems that support decision making activities. A DSS can take many different forms. In general, we can say that a DSS is a computerized system for helping make decisions. A decision is a choice between alternatives based on estimates of the values of those alternatives.

The DSS Architecture has three main components.
The Database
The database contains information about internal data and external data that will contribute to the decision making process. This data is in most cases more extensive than traditional relational models. The database must consider the input data to the system and the outputs to the user. Even must have a differentiation between the levels of inputs and check the quality of the data.
The Model Base
This module contains a set of algorithms that makes decisions based on the information in the database. This information is then summarized and displayed as tables or graphs.
The Interface
This is what the user will use to interface with the system. This is complimented with an interactive help and navigation screen.
The Benefits of DSS are,
1. Improving Personal Efficiency
2. Expediting Problem Solving
3. Facilitating Interpersonal Communication
4. Promoting Learning or Training
5. Increasing Organizational Control

Tuesday, February 19, 2008

Open the Borders of accessing data:

We who program on the iSeries tend to be isolationists when it comes to our data. We store what we need for our applications, and nothing more. If there is desired data in the outside world, we usually attempt to replicate it locally, instead of figuring out how to access it remotely. Well, with DB2 UDB on the iSeries, we now have the capability to pull our heads out of the sand and check out the data the rest of the world has to offer.

Local data is not all that DB2 UDB can handle. It can also access external data using a feature called DataLinks. DataLinks are pointers, or logical views, to data that resides on another server or on the Integrated File System (IFS) of the same server.
The pointer to external data is contained within a column of type DataLink and is stored in the form of a URL. The rest of the row is used to store information about the external data. A practical use of datalinks might be a video store database or any database that includes images, such as an item file or employee master file. In either case, the descriptive information can be stored locally, in DB2, where queries, reports, and maintenance can be easily and quickly accomplished, while the video or image data would be stored on a remote server and only retrieved when necessary. The following SQL code fragment demonstrates how you would define a DataLink column in a DB2 table:
Create Table Rental (
Cust_ID Integer,
Name VarChar (50),
Video_ID Integer,
Description VarChar (50),
Length Integer
Clip Datalink (40))

There are three ways in which a DataLink can be linked to, or can "control," external data: no control, file link control with IFS permissions, and file link control with DB2 permissions.

The data link file manager, or DLFM, keeps track of the link statuses for files on a server. It handles the necessary linking, unlinking, and commitment control tasks. In order for the DLFM or DataLinks in general to work, you must have TCP/IP configured on both the server where the DB2 tables containing the datalink exist and the server that contains the linked objects.

Data links is a very powerful feature of DB2 UDB and it can help you organize your enterprise data, even if that data resides on disparate machines.

Code Snippet – Convert between Char and Hexadecimal:

H BNDDIR('QC2LE')

D CvtHex1To2 PR ExtProc('CVTHC')
D LongReceiver * Value
D ShortSource * Value
D ReceiverBytes 10I 0 Value

D CvtHex2To1 PR ExtProc('CVTCH')
D shortReceiver * Value
D longSource * Value
D sourceBytes 10I 0 Value

D charval S 4A Inz('1F3D')
D hexval S 5A Inz(X'C1C2C3C4C5')

D charResult S 10A
D intResult S 5I 0

* convert from a character value to an integer

C CallP CvtHex1To2 (%addr(intResult)
C : %addr(charval)
C : %size(intResult) * 2)

* convert from a hex value to an character

C CallP CvtHex2To1 (%addr(charResult)
C : %addr(hexval)
C : %size(charResult))

Sunday, February 17, 2008

Surface Computer from Microsoft:

At the D: All Things Digital conference, Microsoft CEO Steve Ballmer will unveil Microsoft Surface, the first in a new category of surface computing products from Microsoft that will “break down traditional barriers between people and technology”.
A Surface computer is able to recognize physical objects from a paintbrush to a cell phone and allows hands-on, direct control of content such as photos, music and maps. Surface turns an ordinary tabletop into a dynamic surface that provides interaction with all forms of digital content through natural gestures, touch and physical objects.
The new product is aimed directly at hotels, retail establishments, restaurants and public entertainment venues and should be commercially available towards the end of the year.
It’s an interesting product in that it’s completely out of left field. Microsoft gives examples of ordering a beverage during a meal with just the tap of a finger and quickly browsing through music and dragging favorite songs onto a personal playlist by moving a finger across the screen. Build this into a bar and you’d get one-touch beer service although I’m not sure if they’ve found a way to work out when your beer glass is empty so replenishment becomes automatic, maybe in a later version.
The practical uses for Surface at the point of sale are broad. This is touch screen point of sale technology at a new level.
Initial launch partners include Harrah’s Entertainment, Starwood Hotels and T-Mobile.

Thursday, February 14, 2008

QTMMSENDMAIL API:

The Send MIME Mail (QtmmSendMail) API allows you to send e-mail from an iSeries program. This API supports sending multiple mail attachments at one time, but the Send Distribution (SNDDST) command does not. The QtmmSendMail API is in the service program QTCP/QTMMSNDM. Application programs must bind to this service program.
The QtmmSendMail API works in the following way:
1. You create an ASCII file with an entire MIME note. The headers are all in US-ASCII coded character set identifier (CCSID) 367.
2. The application calls the QtmmSendMail API and gives it both the name of the file and the addresses that the framework and SMTP must use to forward the e-mail.
The parameter details for this API can be found in the following link.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzair/rzairsendmime.htm

Wednesday, February 13, 2008

Trick with RTNDTA:

In most of our RPG program we would perform the following steps:
1. CHAIN and release the database record without lock.
2. Move the appropriate database fields to the screen fields.
3. Display the screen.
4. Read the screen looking for changes and, if changes had been made, then we would CHAIN again to the database record.
5. Move the appropriate screen fields to the database fields.
6. Finally, update the record.

This process can be made easier with the DDS keyword Return Data (RTNDTA). This keyword can eliminate the need to create separate variable names in display files used for database file updates. The display file can reference the database fields instead. No need to worry about field attributes matching between the database file and the display file. We don't have to code any MOVEs or Z-ADDs, and the program size is smaller as there are not as many variables.
Here's how it's done.
DDS coding:
Place the RTNDTA keyword at the record level on the appropriate record of the display file. Use the database field names and reference the database file. This will bring the database fields into the display file automatically when you retrieve the database record.
RPG coding:
1. CHAIN and release the database record.
2. Display the screen.
3. Read the screen looking for changes and, if changes have been made, CHAIN again to the database record.
4. Reread the display format using the READ operation. This is what makes this technique work. Since we CHAINed again to the database record, the internal representation of the display file record is overlaid and any changes to the display record are lost. But by reading the display record again (with the RTNDTA keyword), you can retrieve the original values of the screen.
5. Update the database record.
Although this is not a mind-boggling, high-glam tip, I found it to be quite helpful.

Tuesday, February 12, 2008

SOS:

SOS is the commonly used description for the International Morse code distress signal (• • • — — — • • •). This distress signal was first adopted by the German government in radio regulations effective April 1, 1905.

From the beginning, the SOS distress signal has actually consisted of a continuous sequence of three-dits/three-dahs/three-dits, all run together without letter spacing. In International Morse Code, three dits form the letter S, and three dahs make the letter O, so "SOS" became an easy way to remember the correct order of the dits and dahs. In modern terminology, SOS is a "procedural signal" or "prosign", and the formal way to write it is with a bar above the letters, i.e. SOS.
In popular usage, SOS became associated with phrases such as "Save Our Souls," "Save our Ship" "Save Our Shelby," "Shoot Our Ship", "Sinking Our Ship", "Survivors On Shore", and "Save Our Seamen". It is mostly known by "Save Our Souls". However, these phrases were a later development, most likely used to help remember the correct letters—something known as a backronym.

Display of COPY modules in RPGLE Debug:

Below procedure explains how to display the copy books in the SEU while debugging the RPGLE source.
1. Now while compiling the RPGLE program compile it with DBGVIEW(*COPY).
2. In the debugger, use F15 and select the copy view.
3. This will expand the copy book in the debugging program.

Sunday, February 10, 2008

Check if Recompilation required:

You've just made a minor change to your display file. Now you must recompile all the programs that use it to avoid getting level check errors, right? Or do you?
The system assigns a unique level identifier to each record format when the display file is created. When you compile a program that uses the file, the compiler includes the format level identifiers in the compiled program.
Use the Display File Description (DSPFD) command to display the record format level identifiers for the file. Use the Display Program References (DSPPGMREF) command to display the record format level identifiers that were used when the program was created. If they are the same, you do not need to recompile the program to avoid a level check error.
Only changes to the following will affect the record format level identifier:
• Record format name
• Field names
• Length of the record format
• Number of fields in the record format
• Field attributes such as length and decimal positions
• The order of the fields in the record format
You can change field attributes such as highlight, underline, reverse image and colors without recompiling programs. Constants such as headings or labels can be added, changed or deleted. The screen locations of fields and constants can be changed as long as the order of the fields or length of the record format is not changed. This means that you can actually change the location and order of fields on the screen as long as you don't change their order in the DDS source member for the display file.

Thursday, February 7, 2008

Multi tier Architecture:


In software engineering, multi-tier architecture (often referred to as n-tier architecture) is a client-server architecture in which an application is executed by more than one distinct software agent. For example, an application that uses middleware to service data requests between a user and a database employs multi-tier architecture. The most widespread use of "multi-tier architecture" refers to three-tier architecture.
The 3-Tier architecture has the following 3-tiers:
1. Presentation Tier

This is the top most level of the application. The presentation tier displays information related to such services as browsing merchandise, purchasing, and shopping cart contents. It communicates with other tiers by outputting results to the browser/client tier and all other tiers in the network.
2. Application Tier/Logic Tier/Business Logic Tier

The logic tier is pulled out from the presentation tier and, as its own layer, it controls an application’s functionality by performing detailed processing
3. Data Tier

This tier consists of Database Servers. Here information is stored and retrieved. This tier keeps data neutral and independent from application servers or business logic. Giving data its own tier also improves scalability and performance.

In the Web development field, three-tier is often used to refer to Websites, commonly electronic commerce websites, which are built using three tiers:
1. A front end Web server serving static content
2. A middle dynamic content processing and generation level Application server, for example Java EE platform.
3. A back end Database, comprising both data sets and the Database management system or RDBMS software that manages and provides access to the data.

Controlling Spool file Names:

Suppose you want to write an RPG program which will create print files with varying spool file names. Normally, the spool file name which is created is the same as the file name in the RPG program. You can give the spooled file any name you wish by specifying the spooled file name in the SPLFNAME parameter of the Override Print File (OVRPRTF) command. If you want to do it all in RPG, code UC in columns 71-72 of the F-spec for the printer file. Then run the OVRPRTF command using QCMDEXC before you open the printer file manually in the RPG program.

... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 .
FQPRINT O F 132 OF PRINTER UC
I 'OVRPRTF QPRINT - C CMD
I 'SPLFNAME(INVOICE)'
C CALL 'QCMDEXC'
C PARM CMD COMAND 50
C PARM 32 LENGTH 155
C OPEN QPRINT
... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 .

Tuesday, February 5, 2008

Create your own Edit Codes:

One of the better features of OS/400 is the ability to create your own edit codes. Three that are commonly used are, a modified "Y" edit code, a social security edit code and a telephone number edit code. User defined edit codes can be of any number between 5 to 9. The edit code commands are Create Edit Description (CRTEDTD), Delete Edit Description (DLTEDTD), and Display Edit Description (DSPEDTD). There is no command to change an edit code description.
To create an edit code of your own, you must first delete one of the edit codes numbered 5-9 that IBM provides as samples (e.g., DLTEDTD 5). Then you can replace that code with one of your own. The below sample will use a lowercase "x" for the edit code. We can choose your own. The character "b" in the following commands represents a blank.

CRTEDTD EDTD(x) INTMASK('b0/bb/bb') +
DECPNT(*NONE) ZEROBAL(*NO) +
TEXT('Similar to Y, but no print if date = 000000')

CRTEDTD EDTD(x) INTMASK('bbb-bb-bbbb') DECPNT(*NONE) +
FILLCHAR(0) ZEROBAL(*YES) +
TEXT('Social Security Edit Code')

CRTEDTD EDTD(x) INTMASK('(bbb)&bbb-bbbb') DECPNT(*NONE) +
ZEROBAL(*NO) LFTCNS('(') TEXT('Telephone edit code')

Monday, February 4, 2008

Check your file in IFS:

Many people are using the Integrated File System (IFS) to store source code and HTML pages and to stage converted database files that are being sent or received between heterogeneous systems. One question that is frequently asked is how to determine if a file exists on the IFS. There are several methods to accomplish this, but probably the easiest and safest way is to call the access() procedure. The C runtime function name access() allows to test a file on the IFS for read/write access or existence.
The IFS API manual tells us that the access() procedure is prototyped, in C, as follows:
int access(const char *path, int amode);
This C prototype doesn't do us much good in RPG. We need to convert it to an RPG IV prototype. Illustrated below is the RPG IV prototype for the access() procedure.
D access PR 10I 0 ExtProc('access')
D szIFSFile * Value OPTIONS(*STRING)
D nAccessMode 10I 0 VALUE
The access() procedure returns 0 if the test succeeds. For example, if you check for file existence and the file exists, 0 is returned.
Of course, to check for the existence of a file, you have to tell the access() procedure what you want to do. To do that, you must specify on the second parameter the type of file access you want. The options for the second parameter are as follows:
D R_OK C Const(4)
D W_OK C Const(2)
D F_OK C Const(0)
It is always better programming to use named constants rather than hard-coded numbers, hence the R_OK, W_OK, and F_OK named constants. If you read the access() documentation, you see that the C language predefines these constants for you (in C language, of course).
Using access()
As mentioned, most people simply want to check to see if a file already exists on the IFS. To do this, you call the access() procedure with the F_OK value specified for its second parameter.
For example, to check to see if the file CUSTMAST.TXT exists in the /MYFILES directory, you could use the following:
D szIFSfile C '/myfiles/customers.txt'
C if access(szIFSFile : F_OK) = 0
// The file exists!!
C endif
In this example, the IFS file name is stored as a named constant (line 1), and on line 2, the access() procedure is called to test for its existence. If it is found, a 0 is returned and processing continues.
As is always the case, to use any of the C runtime library functions, we must include the QC2LE binding directory. As a matter of practice, it is always better to include it in the H-spec for the source code. Here's a typical Header specification from one of the source members:
H BNDDIR('QC2LE') OPTIONS(*SRCSTMT:*NODEBUGIO)
/IF DEFINED(*CRTBNDRPG)
H DFTACTGRP(*NO)
/ENDIF

Sunday, February 3, 2008

Software Design:

Software design is a process of problem-solving and planning for a software solution. After the purpose and specifications of software is determined, software developers will design or employ designers to develop a plan for a solution. It includes low-level component and algorithm implementation issues as well as the architectural view.
A software design may be platform-independent or platform-specific, depending on the availability of the technology called for by the design.
There are many aspects to consider in the design of a piece of software. The importance of each should reflect the goals the software is trying to achieve. Some of these aspects are:
• Extensibility - New capabilities can be added to the software without major changes to the underlying architecture.
• Robustness - The software is able to operate under stress or tolerate unpredictable or invalid input. For example, it can be designed with resilience to low memory conditions.
• Reliability - The software is able to perform a required function under stated conditions for a specified period of time.
• Fault-tolerance - The software is resistant to and able to recover from component failure.
• Security - The software is able to withstand hostile acts and influences.
• Maintainability - The software can be restored to a specified condition within a specified period of time. For example, antivirus software may include the ability to periodically receive virus definition updates in order to maintain the software's effectiveness.
• Compatibility - The software is able to operate with other products that are designed for interoperability with another product. For example, a piece of software may be backward-compatible with an older version of itself.
• Modularity - the resulting software comprises well defined, independent components. That leads to better maintainability. The components could be then implemented and tested in isolation before being integrated to form a desired software system. This allows division of work in a software development project.
• Reuse - the modular components designed should capture the essence of the functionality expected out of them and no more or less. This single-minded purpose renders the components reusable wherever there are similar needs in other designs.
A software designer or architect may identify a design problem which has been solved by others before. A template or pattern describing a solution to a common problem is known as a design pattern. The reuse of such patterns can speed up the software development process, having been tested and proved in the past.