Tuesday, February 12, 2008

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.