RPGLE
RPGLE
RPGLE
1. Advantages of ILE:
Enhancements in RPGIV
Limit changes :
H spec :
Completely free format
Additional functions: Date and Time Format
Enhanced Readability
F-Spec:
Part of F-spec are now keyword based
No of files un limited
File definition checks have been relaxed
File names length increased to 10 characters and record lengths to 5
digits
D-Spec:
Defining the data structures
2
Defining arrays
Defining standalone fields
Indent field names to show structures
Easily define arrays within data structures
Use keywords to make your code more readable and more flexible
C-Spec:
RPGIII RPGIV
BITOF BITOFF
CHEKR CHECKR
COMIT COMMIT
DEFN DEFINE
DELET DELETE
EXCPT EXCEPT
LOKUP LOOKUP
OCCUR OCCUR
REDPE READPE
RETRN RETURN
SELEC SELECT
SETOF SETOFF
UPDAT UPDATE
UNLCK UNLOCK
WHXX WHENXX
O-Spec:
No major changes in the O specification
Names on the O spec have been expanded
Skip Before/After and Space Before/After have also been extended , to
allow 3 positions
New Opcodes:
3
ADDDUR
CALLB
CALLP
DOU
DOW
EVAL
EXTRCT
IF
SUBDUR
TEST
WHEN
RPGIV supports date,time and timestamp data types With date , time and
timestamp fields you can Calculate durations
Extract portions of dates and times
Move data from one field to another
Compare their values
Test for valid values
The internal format can be specified on the H spec for all fields or on
the D spec for specific fields
With the introduction of the ADDDUR & SUBDUR opcodes you can easily add
or subtract duration b/n date,time or timestamp fields.
The MOVE or MOVEL opcode can be used to easily move data to and from
date,time & timestamp fields.
You can compare dates, times& timestamps & test the validity of these
fields using the TEST opcode.
EXPRESSIONS:
RPGIV provides you with many advanced functions that make your code
easier to maintain . It Provides you with powerful built-in functions
that allows you to code more powerful and self-maintaining applications.
TRIM BIF allows you to trim spaces from the beginning or end of a
character variable.
Modules can be bound together and data can be shared across modules
using the IMPORT and EXPORT keywords .
These modules are statistically bound. They are created using CRTxxxMOD
command.
OPM program runs in the default activation group . You can create an
RPGIV program that is OPM compatible by using CRTBNDRPG with
DFTACTGRP(*YES)
There are two ways to create an ILE program.you can create bound RPG
program using CRTBNDRPG Command or create a program binding modules
together.
5
You can create a service program to handle frequently used routines &
for better performance.
Built-in-Functions:
%ADDR
%ELEM
%PADDR
%SIZE
%SUBST
%TRIM
%TRIML
%TRIMR
Activation group:
ILE activation groups have many benefits over the default activation
group:
Resources such as shared open data paths for files, can be shared among
all programs in activation group, while being protected from other
programs running in the same job .
To determine how jobs can proceed (system process) if more than one
jobs present in that jobq
42. OPNQRYF –
It will opens the file with set of database records, which satisfies
the query selection process.
Dynamic query selection
Join records from more than one file
3. Data Structures.
PSDS
o D PGM_LIB 81 90 Program
library
o D EXCP_DATA 91 170
Exception data
o D EXCP_ID 171 174
Exception Id
o D DATE 191 198 Date
(DATE fmt)
o D YEAR 199 200S 0 Year
(YEAR fmt)
o D LAST_FILE 201 208 Last
file used
o D FILE_INFO 209 243 File
error info
o D JOB_NAME 244 253 Job name
o D USER 254 263 User name
o D JOB_NUM 264 269S 0 Job
number
o D JOB_DATE 270 275S 0 Date
(UDATE fmt)
o D RUN_DATE 276 281S 0 Run date
(UDATE)
o D RUN_TIME 282 287S 0 Run time
(UDATE)
o D CRT_DATE 288 293 Create
date
o D CRT_TIME 294 299 Create
time
o D CPL_LEVEL 300 303 Compiler
level
o D SRC_FILE 304 313 Source
file
o D SRC_LIB 314 323 Source
file lib
o D SRC_MBR 324 333 Source
file mbr
o D PROC_PGM 334 343 Pgm Proc
is in
o D PROC_MOD 344 353 Mod Proc
is in
o D CURR_USER 358 367 Mod Proc
is in
INFDS
D OpCode *OPCODE *
Last opcode
D Routinr *ROUTINE *
RPG Routine
D ListNum 30 37 *
Listing line
D SpclStat 38 42S 0 *
SPECIAL status
D RecordFmt *RECORD *
Record name
D MsgID 46 52 *
Error MSGID
D* Disk
D FDBK_SIZE 367 370I 0 * Size
of DB fdbk
D JOIN_BITS 371 374I 0 * JFILE
bits
D LOCK_RCDS 377 378I 0 * Nbr
locked rcds
D POS_BITS 385 385 * File
pos bits
D DLT_BITS 384 384 * Rcd
deleted bits
D NUM_KEYS 387 388I 0 * Num
keys (bin)
D KEY_LEN 393 394I 0 * Key
length
D MBR_NUM 395 396I 0 * Member
number
D DB_RRN 397 400I 0 *
Relative-rcd-num
D KEY 401 2400 * Key
value (max
D* * size
2000)
D* ICF
D ICF_AID 369 369 * AID
byte
D ICF_LEN 372 375I 0 * Actual
data len
D ICF_MAJOR 401 402 * Major
ret code
D ICF_MINOR 403 404 * Minor
ret code
D SNA_SENSE 405 412 * SNA
sense rc
D SAFE_IND 413 413 * Safe
indicator
D RQSWRT 415 415 *
Request write
D RMT_FMT 416 425 * Remote
rcd fmt
D ICF_MODE 430 437 * Mode
name
D* Display
D DSP_FLAG1 367 368 *
Display flags
18
5. SDLC
Another problem is that the waterfall model assumes that the only role
for users is in specifying requirements, and that all requirements can
be specified in advance. Unfortunately, requirements grow and change
throughout the process and beyond, calling for considerable feedback
and iterative consultation. Thus many other SDLC models have been
developed.
The fountain model recognizes that although some activities can't start
before others -- such as you need a design before you can start coding
-- there's a considerable overlap of activities throughout the
development cycle.
The spiral model emphasizes the need to go back and reiterate earlier
stages a number of times as the project progresses. It's actually a
series of short waterfall cycles, each producing an early prototype
representing a part of the entire project. This approach helps
demonstrate a proof of concept early in the cycle, and it more
accurately reflects the disorderly, even chaotic evolution of
technology.
20
Build and fix is the crudest of the methods. Write some code, then keep
modifying it until the customer is happy. Without planning, this is
very open-ended and can by risky.
In the rapid prototyping (sometimes called rapid application
development) model, initial emphasis is on creating a prototype that
looks and acts like the desired product in order to test its
usefulness. The prototype is an essential part of the requirements
determination phase, and may be created using tools different from
those used for the final product. Once the prototype is approved, it is
discarded and the "real" software is written.
The incremental model divides the product into builds, where sections
of the project are created and tested separately. This approach will
likely find errors in user requirements quickly, since user feedback is
solicited for each stage and because code is tested sooner after it's
written.
Detailed Description :
Filename: FILE1
Fields Type Length
FIELD1 Alpha 5 (File key)
21
FIELD2 Alpha 5
Filename: FILE2
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD3 Alpha 5
Filename: FILE3
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD4 Alpha 5
Filename: JOINFILE
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD2 Alpha 5
FIELD3 Alpha 5
FIELD4 Alpha 5
• When defining this file to LANSA, use the data base attributes
screen to define the file as SHARE..YES. Also put "SHARE(*YES)"
at the bottom of the screen in the CRTPF parameters section.
• Make sure JOINFILE has been defined as having at least one key.
The key does not have to match the keys of the result file
produced by OPNQRYF.
• All of the above files were created using LANSA so they all will
have the field @@UPID automatically added to the record formats.
Once the above files are compiled, a function can be written to
execute the OPNQRYF and read the file.
1. Create a physical file with the same name and record format as
the join logical. This will have to be created in a different
library from the join logical.
2. Load this file as an 'OTHER' file into LANSA.
3. Compile the file.
4. Rename the physical file created outside of LANSA or delete the
file. It is probably best to rename it as it may be necessary to
make changes and reload it at a later stage.
5. Do a CHGLF on the join file LVLVHK(*NO).
6. Make sure that the join logical file is in the library list.
7. It is now possible to do reads of the join logical file via the
LANSA I/O module.
CL-PROGRAM
PGM
ADDLIBLE LIB(JPHLIB)
MONMSG MSGID(CPF2103) EXEC(CHGVAR VAR(&X) VALUE('X'))
/*****************************************************************/
/* SAMPLE ONE: CHAR CONSTANT AND NUM CONSTANT */
/*****************************************************************/
ONE:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''JPH'') +
*AND +
(UPUID *EQ 338) +
') +
OPNID(BRUG)
GOTO CMDLBL(OUT)
/*****************************************************************/
/* SAMPLE TWO: CHAR VARIABLE AND NUM CONSTANT */
/*****************************************************************/
TWO:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''' *CAT &USER *CAT ''') +
*AND +
(UPUID *EQ 338) +
') +
OPNID(BRUG)
GOTO CMDLBL(OUT)
/*****************************************************************/
/* SAMPLE THREE: CHAR VARIABLE OG NUM VARIABLE. */
/* DIGITS IS A OPNQRYF KEYWORD THAT CONVERTS */
/* A FIELD FROM NUMERIC TO ALFA (CHAR.) */
/*****************************************************************/
THREE:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''' *CAT &USER *CAT ''') +
*AND +
(%DIGITS(UPUID) *EQ ''' *CAT &NRALF *CAT ''') +
') +
OPNID(BRUG)
25
GOTO CMDLBL(OUT)
/*****************************************************************/
/* MAKE A COPY OF THE OPNQRY OUTPUTFILE TO THE PF BRUG */
/*****************************************************************/
CLOF OPNID(BRUG)
DLTOVR FILE(*ALL)
GOTO CMDLBL(CHOISE)
/* LIBRARY-LIST IS RESTORED */
RCLRSC
RETURN
ENDPGM
Hey, Ted:
-- Nonna
The other way to do this is to use two single quote marks ( ' ) to
delimit the literal, like this:
That's single quote single quote the numeral four a double quote single
quote single quote.
26
Here's some CL code that illustrates this concept. &DESC is the field
holding the user input. &DWORK holds the user input with doubled quote
marks.
CHGVAR &INX 1
CHGVAR &OUTX 1
NextChar:
CHGVAR %SST(&DWORK &OUTX 1) %SST(&DESC &INX 1)
-- Ted
OAGRPG1 :
**************************************************************
H/TITLE OAG TEST PROGRAM.
*
FOAGPF1 O E DISK
*
C Z-ADD1 COUNT 50
C COUNT DOWLE3
C MOVE COUNT SLNO
C WRITEREC1
C ADD 1 COUNT
27
C ENDDO
*
C SETON LR
***************************************************************
H/TITLE OAG TEST PROGRAM
*
F*OAGPF1 IF E DISK
F* OAGPF1 KRENAMEREC1
*
C* READ REC1 90
C* MOVELSLNO SN 5
*
C* RETRN
************************************************************
FRSEDSP CF E WORKSTN
F #RRN KSFILE SFLREC
FOAGLF1 IF E K DISK
F OAGPF1 KRENAMEREC1
*
C Z-ADD*ZEROS #RRN 40
C Z-ADD*ZEROS COUNT 40
C MOVEL*BLANKS WRK 5
*
C EXSR CLEAR
C EXSR BUILD
*
C *IN03 DOWEQ*OFF
C EXFMTSFLCTL
C 03 LEAVE
C LEAVE
C ENDIF
C ENDDO
C Z-ADD*ZERO #RRN
C EXSR CLEAR
C EXSR BUILD
C ITER
C ENDIF
*
C POS IFNE WRK
C POS ANDEQ*BLANKS
C EXSR CLEAR
C Z-ADD*ZEROS #RRN
C *LOVAL SETLLREC1
C EXSR BUILD
C ELSE
C MOVELPOS WRK
C EXSR CLEAR
C Z-ADD*ZEROS #RRN
C POS SETLLREC1
C EXSR BUILD
C ENDIF
*
C ENDDO
*
C SETON LR
***************************************************************
C CLEAR BEGSR
C SETON 28 C
WRITESFLCTL C SETOF
28
C ENDSR
***************************************************************
C BUILD BEGSR
C DO 5
C READ REC1 90
C 90 LEAVE
C ADD 1 #RRN C
MOVELSLNO #SLNO
C MOVELNAME #NAME
C MOVELDESC #DESC
C WRITESFLREC
C ENDDO
*
C #RRN IFGT *ZERO
C SETON 26
C ELSE
C SETOF 26
C ENDIF
C SETON 27
C ENDSR
****************************************************************
C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM TEXT
C PARM TBLNAM
C PARM LIBNAM
This code frag was in 3 places in the program: a perfect candidate for
a subroutine. There were 3 different fields being translated to upper
case: TEXT, DESC and TITLE. This meant inline code that looked like
this:
C MOVELTEXT XFIELD
C EXSR UCASE
C MOVELDESC XFIELD
C EXSR UCASE
C MOVELTITLE XFIELD
C EXSR UCASE
C UCASE BEGSR
C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM XFIELD
C PARM TBLNAM
C PARM LIBNAM
C ENDSR
C CallP UCASE(Text)
C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM WorkString
C PARM TBLNAM
C PARM LIBNAM
C Return
P UCASE E
C CallP UCASE(Text:'QSYSTRNTBL':'QSYS')
D WorkStringLen S 5p 0
C CALL 'QDCXLATE'
C PARM WorkStringLen
C PARM WorkString
C PARM XlateTableNam
C PARM XlateTableLib
C Return
P UCASE E
C CallP UCASE(Text)
C CallP Translate(WorkString:'QSYSTRNTBL':'QSYS')
C Return
P UCASE E
D WorkStringLen S 5p 0
C CALL 'QDCXLATE'
C PARM WorkStringLen
C PARM WorkString
C PARM XlateTableNam
31
C PARM XlateTableLib
C Return
P Translate E
That is, a procedure can see variables that it defines, but not
variables that the main program defines. This makes it a lot easier to
determine what a procedure is actually doing and where it's getting
it's return value(s).
This makes a procedure "stand alone", and can be used in other programs
with little modification (modification required for any File I/O
may be required)
1. How can u send Parameters through LDA to another program and how
do you receive?
CHGDTAARA-CL
RCVDTARA-CL
IN and OUT in RPG
2. In P.F you are having no records and you write SFL Program. Then
how can you know that there are no records in P.F? Which make you
to show there are no records?
If the first Read returns End of file then there is no records in
the PF
3. How can u send data’s of P.F to data Queue and how to receive the
data Queue and how to copy it to your file?
Read PF
QSNDTAQ
QSYS
12.How to lock a particular record and how to open the lock in RPG?
READ, CHAIN –To lock the record
UPDATE and DELETE for Unlock
OPM ILE
Program Program Service program
Compilation results in a runnable Compilation results in a
program nonrunnable module object
Compile, run Compile, bind, run
Run units simulated for each Activation groups
language
Dynamic program call Dynamic program call Static
procedure call
Single-language focus Mixed-language focus
Language-specific error handling Common error handling Language-
specific error handling
OPM debuggers Source-level debugger
20.How do you retrieve the job name from batch job currently running
in the system and the library of that job from the group data
area?
21.How will you change the printer files to different language with
out changing the code or without using additional parameters?
The Design Report display is the main screen from which you edit the
report. From this display you can use function keys to go to other
displays where you can add information at the file, record and field
levels. You can also go to the Change Session Defaults display
where you can control the characteristics of your edit session.
There are two ways to print your prototype report. When you start
RLU you can specify option 6 to print from the STRRLU display. From
within the session you can specify that you want to print from the
Exit RLU display. On the Exit display choose Y=Yes for the
Prototype report prompt and the report will be printed.
There are a few things you should keep in mind during your RLU
session:
34
o Once the DDS source has been coded for your report you can edit
the image using the field line, the mark function keys that allow
you to move and copy fields and data, and the other function keys
that bring up displays that will help you edit your report.
o Ensure that all fields for a record are defined. You can use the
DF (define field) command to do this or you can define fields on the
Define Field Information display. To get to the Define Field
Information display press F11 when your cursor is not on an existing
field.
o There are two sets of function keys in RLU. There is a base set
and an alternate set. You can toggle between the two sets using
F22. The base function keys are RLU specific. You use them to edit
the report you are working on, and to access the other RLU displays.
The alternate function keys are more general than the base set. They
are based on the function keys for the Edit display in SEU. When the
base function keys are active, you see BASE to the left of the format
line. This is the third line from the top of the display that marks
the columns across the display. When the alternate function keys
are active, you see ALT.
o You should not move fields to filler lines. If you do, everything
you have defined for the field will be lost.
Columns
Library/Source file
The name of the library and the source file containing the report
you are editing.
Command line
without leaving the work screen. RLU commands are free format
commands. The command parameters are either required and
positional, or optional, and they can be entered in any order.
Some commands have abbreviations: for example, you can enter F or FIND
to run the FIND command. To retrieve the last command you entered,
type F9=Retrieve. If the cursor is in the data area, you can use
F10=Cursor to move the cursor back and forth between the data area
and the command line. RLU remembers up to 50 commands.
To see help for an RLU command, type the command on the command line
and press the Help key.
Note: You cannot enter system commands on the command line, but you
can enter a system command on the work screen by pressing F21=System
command. A window appears where you can enter a system command.
You can enter the following RLU commands on any command line on the
work screen (Edit, Browse or Split displays):
o FIND or F
o CHANGE or C
o SAVE
o CANCEL or CAN
o FILE
o TOP
o BOTTOM
o SET or S
o HIDE or H
Note: FILE, SAVE, and CHANGE commands can only be used in an Edit
session or in the top session of a Split Edit/Browse display.
o MATCH
o CAPS
o TABS
o ROLL
o EXPERT
o SHIFT
Note: The SHIFT and TABS options can only be used in an Edit session
or in the top session of a Split dit/Browse display.
Report
Active keys
BASE indicates that the base function keys are active. ALT indicates
that the alternate keys are active.
Format line
36
The area on the display consisting of line numbers and record format
names. You can enter line commands in this area.
Work area
The work area for the report you are designing or editing. This
area consists of the following three types of lines:
Report line
A report line is any line of the report that is part of a record
format. Report lines are involved in DDS source generation.
The first report line in a record format is indicated by an R in the
line number area. Subsequent report lines, which are called
continuation lines, are indicated with a + in the line number area.
Sample line
A sample line is a line used to make the report you are editing look
more like the final report. Sample lines contain sample data that
is associated with the preceding record format. The first sample
line in a group of sample lines is indicated by an S in the line
number area. Subsequent sample lines, which are called continuation
lines, are indicated by a + sign in the line number area. These lines
are not involved in DDS source generation.
Filler line
Filler lines are lines that separate one record format from
another. They are indicated by a . (period) in the line number area.
Filler lines are involved in DDS source generation.
Field Line
A field line is a temporary record that may be displayed above the
report line and is denoted by FLDn in the sequence number area,
where n=1, 2, or 3. The field line indicates field boundaries
within the record, allows editing of fields in the record, and
accepts certain commands to facilitate field generation.
F1=Help
Press F1 for additional help about using the display.
F3=Exit
37
F4=Fields
Press F4 to work with a list of the fields within a DDS record format.
F5=Refresh
Press F5 to restore all entries to what they were initially.
F6=Condition display
Press F6 to go to the Condition Design Report display to set
indicators on or off to condition the fields and keywords and how
they are displayed on the work screen.
F9=Retrieve
Press F9 to retrieve the last command entered.
F10=Database fields
Press F10 to go to the Work with Database Fields display where you
can build a list of database fields to display at the bottom of the
work display for inclusion in the report.
F11=Define field
Press F11 when the cursor is not on an existing field and the Define
Field Information display appears where you can create a new field.
F12=Cancel
Press F12 to cancel the Split Edit/Browse or Split Edit/Prompt
session. You will return to a single Design Report session.
F13=Mark/Unmark data
Press F13 to mark a character, field, or block of text to be
copied or moved. If something has been marked, and you move the
cursor to another area and press F13 again, the new area will be
highlighted along with the first area you highlighted. Now you
can use F14 to copy the data to the new marked area, or F15 to move
the data to the new marked area. If you press F13 again with your
cursor on the marked area the marked text will be unmarked. You
can change the way a move or copy is performed by going to the Change
Session Defaults display.
F16=Delete field
Press F16 on a field line, report line, or sample line to delete the
field's text and the associated sample data, as well as all
associated field level information from the Design Report display.
F17=File keywords
38
Press F17 to go to the Work with File Keywords display, where you
can change the file level definition. If you used the Input Keywords
display the last time you worked with keywords then the Input File
Keywords display will appear when you press F17.
F18=Record keywords
Press F18 on a report line or sample line to go to the Work with
Record Keywords display. If you used the Input Keywords display the
last time you worked with keywords then the Input Record Keywords
display will appear when you press F18.
F19=Left
Press F19 to move the record area to the left on the display.
F20=Right
Press F20 to move the record area to the right on the display.
F21=System command
Press F21 to display an entry window where you can input system
commands.
F22=Alternative keys
Press F22 to display the alternative set of function keys.
F23=Field keywords
Press F23 with the cursor on an existing field and the Work with
Field Keywords display appears where you can change field
definitions. If you used the Input Keywords display the last time
you worked with keywords then the Input Field Keywords display
will appear when you press F23.
F24=More keys
Press F24 to view the other function keys available.
This is also known as Classic Life Cycle Model (or) Linear Sequential
Model (or) Waterfall Method. This has the following activities.
1. System/Information Engineering and Modeling
2. Software Requirements Analysis
3. Systems Analysis and Design
4. Code Generation
5. Testing
6. Maintenance
System/Information Engineering and Modeling
As software is always of a large system (or business), work begins by
establishing requirements for all system elements and then allocating
some subset of these requirements to software. This system view is
essential when software must interface with other elements such as
hardware, people and other resources. System is the basic and very
critical requirement for the existence of software in any entity. So if
39
the system is not in place, the system should be engineered and put in
place. In some cases to extract the maximum output, system should be
re-engineered and spiced up. Once the ideal system is engineered or
tuned up, the development team studies the software requirement for the
system.
Software Requirements Analysis
This is also known as feasibility study. In this phase, the development
team visits the customer and studies their system. They investigate the
need for possible software automation in the given system. By the end
of the feasibility study, the team furnishes a document that holds the
different specific recommendations for the candidate system. It also
includes the personnel assignments, costs, project schedule, and target
dates. The requirements gathering process is intensified and focussed
specially on software. To understand the nature of the program(s) to be
built, the system engineer ("analyst") must understand the information
domain for the software, as well as required function, behavior,
performance and interfacing. The essential purpose of this phase is to
find the need and to define the problem that needs to be solved .
System Analysis and Design
In this phase, the software's overall structure and its nuances are
defined. In terms of the client/server technology, the number of tiers
needed for the package architecture, the database design, the data
structure design etc are all defined in this phase. Analysis and Design
are very crucial in the whole development cycle. Any glitch in the
design phase could be very expensive to solve in the later stage of the
software development. Much care is taken during this phase. The logical
system of the product is developed in this phase.
Outsource your Software and Web Development Projects to Stylus
We've been in the business of Internet applications for the
past four years and our services include Internet solutions,
custom software development, web design and web application
development, web enabling legacy systems, technical support
and maintenance of web applications.
Our Value Proposition - our development methodology, our
project management skills and adherence to high- quality and
low risk solutions. Contact us here if you are interested in
outsourcing projects to Stylus.
Code Generation
The design must be translated into a machine-readable form. The code
generation step performs this task. If design is performed in a
detailed manner, code generation can be accomplished with out much
complication. Programming tools like Compilers, Interpreters, Debuggers
are used to generate the code. Different high level programming
languages like C, C++, Pascal, Java are used for coding. With respect
to the type of application, the right programming language is chosen.
Testing
Once the code is generated, the program testing begins. Different
testing methodologies are available to unravel the bugs that were
committed during the previous phases. Different testing tools and
methodologies are already available. Some companies build there own
40
testing tools that are tailor made for there own development
operations.
Maintenance
Software will definitely undergo change once it is delivered to the
customer. There are many reasons for the change. Change could happen
because of some unexpected input values into the system. In addition,
the changes in the system could directly affect the software
operations. The software should be developed to accommodate changes
that could happen during the post implementation period.
The Open Query File (OPNQRYF) command is a CL command that allows you
to perform many data processing functions on database files.
Essentially, the OPNQRYF command acts as a filter between the
processing program and the database records. The database file can be a
physical or logical file.
Unlike a database file created with the Create Physical File (CRTPF)
command or the Create Logical File (CRTLF) command, the OPNQRYF command
creates only a temporary file for processing the data, it does not
create a permanent file.
The OPNQRYF command has functions similar to those in DDS, and the
CRTPF and CRTLF commands. DDS requires source statements and a separate
step to create the file. OPNQRYF allows a dynamic definition without
using DDS. The OPNQRYF command does not support all of the DDS
functions, but it supports significant functions that go beyond the
capabilities of DDS.
The OPNQRYF command parameters also have many functions similar to the
SQL SELECT statements. For example, the FILE parameter is similar to
the SQL FROM statement, the QRYSLT parameter is similar to the SQL
WHERE statement, the GRPFLD parameter is similar to the SQL GROUP BY
statement, and the GRPSLT parameter is similar to the SQL HAVING
statement. For more information about SQL, see DB2 UDB for AS/400 SQL
Programming Concepts .
To understand the OPNQRYF command, you must be familiar with its two
processing approaches: using a format in the file, and using a file
with a different format. The typical use of the OPNQRYF command is to
select, arrange, and format the data so it can be read sequentially by
your high-level language program.
http://mcpressonline.com/mc?224@164.jLqjbD6xxde.0@b4a97@.214a2c4d
*
C eval LenStr = ((%len(TmpComNam) -
C %len(%trim(TmpComNam))) / 2) + 1
C eval %subst(ComNam:LenStr) =
%trim(TmpComNam)
*
C return ComNam
*
P$GetComNam e
c CALL 'QUSCRTUS'
c PARM UserSpace
c PARM *BLANKS SpaceAttr 10
c PARM 4096 SpaceLen
c PARM *BLANKS SpaceVal 1
c PARM '*CHANGE' SpaceAuth 10
c PARM *BLANKS SpaceText 50
c PARM '*YES' SpaceRepl 10
c PARM ErrorDs
Select
When i_cmd ='SAVE'
Eval SaveLin#=LinPos#/256
Eval SavePos#=LinPos#-(SaveLin#*256)
When i_cmd ='SET '
Eval S0Lin#= SaveLin#
Eval S0Pos#= SavePos#
When i_cmd ='CLEAR'
Eval S0Lin#= *zero
Eval S0Pos#= *zero
43
Other
AS/400 SYSTEM
QS30008 What are the different AS/400 rack models supplied by IBM?
AS30008 9402, 9404 and 9406.
44
Q1S2001 What are all the IBM Mid range machines prior to AS/400?
A1S2001 S/38, S/36, S/34, S/32 &S/3.
QO20034 What are the two main attributes which govern the execution
of a job?
AO20034 Run time priority and Time slice.
QS10049 What are the different ways to input data into a data area?
AS10049 CHGDTAARA (using CL)
Using OUT opcode in RPG
QS10051 What are the valid user defined data area types?
AS10051 CHAR, NUMARIC and LOGICAL.
QS20052 How can a data area are locked after being updated?
AS20052 Using OUT *LOCK.
QS10055 What are the valid data types for a data queue?
AS10055 Char, Numeric, and Logical.
QS20056 What are the two types of read performed on data queues ?
AS20056 Read with lock, and read without lock.
48
QO30064 How do you change file attributes such as size, file wait
time, record wait time etc., permanently ?
AO30064 Using CHGPF command.
DATABASE FILES
QS30080 How many record formats can you have in a Physical file and
in a Logical file ?
AS30080 Physical file can contain only one record format, Logical
file can contain more than one record format.
QO20082 What is the default value for the number of increments for
the physicalfile ?
AO20082 Three.
QL30090 How many files can be joined at a time, What is the max.
no. of files ?
AL30090 At a time you can join two files. The max. no. of files is
32.Only one primary
file and the remaining are secondary files, The primary file and
at least one secondary file must be physical files.
DISPLAY FILES
QS40099 How can a screen field that has changed since the last
output operation be detected ?
AS40099 Attach the MDT attribute to the field, to detect whether
field has been changed as a result of user input.
QS50100 What would be the effect on the field where reverse image,
underline and highlight display attributes are active ?
AS50100 The result is same as if you had specified ND.
QS30106In conjunction with what other keyword must OVRDTA and OVRATA be
used ?
AS30106 PUTOVR keyword must be used.
QS50107 How can a field that is larger than what could fit onto one
line be truncated from the last blank rather than from the
last character position?
AS50107 Using BLKFOLD keyword.
QS50114Under what conditions would a field where the ERRMSG keyword was
active would
not be displayed in reverse image ?
AS50114 If it is an output-only field or input capable field with
display attributes UL, HI are active.
QS50115 When will the message for field that has the ERRMSG keyword
active not be displayed ?
AS50115 If more than one ERRMSG keywords are active then the first
will be active, because only one error message will be
displayed at a time.
SUBFILES :
QS20120 What are the two record formats that a subfile contains ?
AS20120Subfile record format(SFL), and subfile control record
format(SFLCTL).
QL20125 What are the different opcodes used for file operation on a
subfile in a RPG Program ?
AL20125READ, READC, CHAIN,UPDAT and WRITE
QS30126 Can more than one subfile record be displayed on one line ?
AS30126 Yes, by using SFLLIN keyword.
QO30133 Can a single screen format occupy a screen area above and
below a subfile format ?
AO30133 Not possible.
QS50134 How can a program be prevented from failing over when READC
is performed on an empty subfile ?
AS50134 Check indicator placed in position LO, which will be seton
if EOF if reached.
RPG/400
START
Read a record
Move data from selected Set ON LR if EOF
record into processing area If change in control field, set
ON control level indicators.
QS20152 Can you call a program in your RPG program, which is coded
in some other language?
AS20152 Yes, Any program object available on AS/400.
57
SETLL operation position a file at the next record that has a key
or relative
record number that is greater than or equal to the search
argument specified. The
file must be fully procedural for all three opcodes.
QO30205 Can you have multiple key lists for a single file ?
AO30205 Yes.
Table name does not refer to the entire set of table elements.
Elements in a table can not be accessed by their position
relative to the other elements.
QS30219 How can the user implicitly open and close the files in RPG
program ?
AS30219 Enter UC in position 71-72 of F specs.Use OPEN and CLOSE
opcodes in RPG program to open and close files.
QS20222 What are different ways by which you define working storage
field ?
AS20222 Explicitly define or use *Like DEFN.
QL40225 Specify different ways by which RPG program can give error
message to user?
AL40225 By calling the SUBR23R3 program as passing message id. By
defining the error message in DSPF.
QS40236 How can the CPF error-id be retrieved when a program error
occurs ?
AS40236 CPF error codes are placed in the subfield location *STATUS
for the program status DS.
Q6L4002 Name the different ways by which RPG source program can be
entered ?
65
MISCELLANEOUS
QS30245 To which member type does help text for panel belong ?
AS30245 PNLGRP
QS20247 What are the valid file operation codes for a PRINTER file ?
AS20247 WRITE, OPEN, CLOSE, FEDO.
APPENDIX - A
Q - Question.
A - Answer.
1 - AS/400 SYSTEM.
2 - OS/400
3 - DATABASE FILES
4 - DISPLAY FILES
5 - CL/400
6 - RPG/400
7 - COBOL/400
8 - MISCELLANEOUS
O - Objective type.
S - Short answers.
L - Long answers.
68
SQLRPG Statements:
C+ SELECT MIN(G4EDAM) INTO :WUAMT1 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
*
C/EXEC SQL
C+ SELECT MAX(G4EDAM) INTO :WUAMT2 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
C/EXEC SQL
C+ SELECT AVG(G4EDAM) INTO :WUAMT3 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
C/EXEC SQL
C+ SELECT MIN(G4EDAM) INTO :WUAMT4 FROM G4AGEDP WHERE G4EDCD =
Example :-
D String S 8A
inz(‘04/05/96)
D Fld1 S 6P 0
inz(112001)
D Date S D
datfmt(*ISO)
69
D TimeStam S Z
/free
Date = %DATE(String
:*MDY);
// Date now contains
1996-04-05
Date = %DATE(Fld1
:*MDY);
// Date now contains
2001-11-20
Clear TimeStam;
Date = %DATE(TimeStam);
// Date now contains
0001-01-01
/end-free
%DAYS number of days number of days as a Syntax :- %DAYS(Number)
duration
Description: - This built in
function converts a number into a
duration that can be added to a
date or time Stamp
Example :-
D Date1 S D
inz(D’2001-11-20’)
D Result S D
/free
Result = Date1 +
%DAYS(15);
// Result is now 2001-
12-05
Result = Date1 -
%DAYS(10);
// Result is now 2001-
11-10
/end-free
Example :-
D Fld1 S 9s 5
inz(73.73642)
70
D Result S 15p 5
/free
Result = %DECH(Fld1 :5
:2);
// Result is now
73.74000
/end-free
%DIFF date or time expression: date or time Syntax :- %DIFF(Op1 :Op2 :*MS| *s|
expression: unit *MN| *H| *D| *M| *Y)
difference between the two dates, times, or
timestamp Description: - This Built in
in the specified unit function calculates difference
(Duration) between two date or
time values.
The first and second parameter
must have the same or compatible
type.
Example :-
D Date1 S D inz(D’2001-11-
20’)
D Date2 S D inz(D’2001-10-
15’)
D Time1 S T
inz(T’12.30.54’)
D Time2 S T
inz(T’01.30.54’)
D Result S 15p 0
/free
Result = %DIFF(Date1
:Date2 :*D);
// No. of Days difference
between two Dates 36
Result = %DIFF(Date1
:Date2 :*M);
// no. of month Difference between
two Dates 1
Result = %DIFF(Time1
:Time2 :*H);
// No. of Hour difference between
two times 11
Result = %DIFF(Time1
:Time2 :*MN);
// No. of minutes difference
between two times 660
/end-free
71
Example :-
D Fld1 S 8p 0 inz(123)
D Fld2 S 8p 0 inz(23)
D Result S 15p 0
/free
Result = %DIV(Fld1
:Fld2);
// Result is now 5
/end-free
%ELEM array, table, or multiple occurrence Syntax :- %ELEM(Array Name)
data structure name
number of elements or occurrences Description: - This Built in
function returns number of
elements in the specified array,
table or multiple occurrence data
structure.
Example :-
D Arr1 S 5A dim(10)
varying
D Result S 2p 0
/free
Arr1(1) = ‘Se’;
Arr1(2) = ‘En’;
Result = %ELEM(Arr1);
// Result is now 10
/end-free
%EOF {file name} ’1’ if the most recent Syntax :- %EOF(File Name)
file input operation or write to a
subfile (for a particular file, if Description: - This built in
specified) ended in an function returns ‘1’, if the most
end-of-file or beginning-of-file condition recent read operation or write to
’0’ otherwise subfile ended in an end of file or
beginning of the file condition,
otherwise it return ‘0’.
Example :-
F Infile IF E K Disk
/free
Read Infile;
Dow not %EOF(Infile);
72
Read Infile;
Enddo;
%FOUND {file name} ’1’ if the most recent Syntax :- %FOUND(File Name)
relevant operation (for a particular
file, if specified) found a record (CHAIN, Description: - This Built in
DELETE, function returns ‘1’, if the most
SETGT, SETLL), an element (LOOKUP), or a recent relevant file operation
match found a record, a string operation
(CHECK, CHECKR, SCAN) found a match, or a Search
’0’ otherwise operation found an element.
Example :-
F CustFile IF E K Disk
/free
// Check if the customer
is in the file
Chain Cust CustFile
If %FOUND(CustFile);
Exsr Handle;
Endif;
/end-free
%HOURS number of hours number of hours as a Syntax :- %HOUR(number)
duration
Description: - This Built in
function converts a number into a
duration that can be added to a
Time or Time Stamp value.
Example :-
D Time1 S T inz(T’11.12.10’)
D Time2 S T
/free
Time2 = Time1 +
%HOURS(1);
// Time2 is now 12.12.10
/end-free
%LOOKUPxx argument: array{:start index Syntax :- %LOOKUP(arg :array
{:number {:Starting Index {:number of
of elements}} elements }})
array index of the matching element
Description: - This Built in
functions returns the array index
of the item in array.
Example :-
D Array1 S 2A dim(5)
ascend
D Index S 2p 0
/free
Array(1) = ‘A’;
Array(2) = ‘C’;
73
Array(3) = ‘E’;
Array(4) = ‘G’;
Array(5) = ‘I’;
Index = %LOOKUP(‘C’
:Array1);
// Index is now 2
Index = %LOOKUPLT(‘F’
:Array1);
//Index is now 3
Index = %LOOKUPGT(‘H’
:Array1);
// Index is now 5
/end-free
%MINUTES number of minutes number of Syntax :- %MINUTES(number)
minutes as a duration
Description: - This built in
function converts a number into a
duration that can be added to a
time or time stamp value.
Example :-
D Time1 S T
inz(T’11.12.10’)
D Time2 S T
/free
Time2 = Time1 +
%MINUTES(10);
// Time2 is now
11.22.10
/end-free
%MONTHS number of months number of months Syntax :- %MONTHS(Number)
as a duration
Description: - This built in
function converts a number into a
duration that can be added to a
date or time Stamp
Example :-
D Date1 S D
inz(D’2001-11-20’)
D Result S D
/free
Result = Date1 +
%MONTHS(2);
// Result is now 2002-
01-20
Result = Date1 -
%MONTHS(2);
// Result is now 2001-
09-20
/end-free
%PARMS
Description
%PARMS returns the number of
parameters that were to the
procedure in which %PARMS is used.
Example
C *ENTRY PLIST
C PARMS COUNT
2 0
C IF %PARMS<1
C ‘No Parms’ DSPLY
C ENDIF
Description
%REM returns the remainder that
results from dividing operand n by
m. The two operands must be
numeric values with zero decimal
positions.
Example
D A S 10I 0 INZ(123)
D B S 10I 0 INZ(27)
D DIV S 10I 0 INZ
D REM S 10I 0 INZ
/free
DIV = %DIV(A:B) // DIV is now
4
REM = %REM(A:B) // REM is now
15
/end-free
In the above example the variable
REM has a value 15 that is arrived
using built-in-function %REM.
%REPLACE replacement string: source string
{:start position {:source length to Syntax
replace}} %REPLACE(replacement string:
string produced by inserting replacement source string {:start position
string into {:source length to replace}})
source string, starting at start position
75
Example
D VAR1 S 10I 0
INZ(‘Windsor’)
VARYING
D RESULT S 10I 0
VARYING
/free
result = var1 + ‘,’ + ‘ON’
// result = ‘Windsor, ON’
//%Replace with 2 parameters to
replace text at beginning of
string.
Result = %replace(‘Toronto’;
result);
//result = ‘Toronto, ON)
/end-free
In the above example the variable
RESULT is replace with ‘Toronto’
of first string var1.
%SQRT numeric value square root of the
numeric value Syntax
%SQRT (numeric expression)
Description
%SQRT returns the square root of
the specified numeric expression.
Example
D P S 5P0
/free
P = %SQRT (81);
/end-free
In the above example the variable
P has value of 9 since square root
of 81 is 9.
%TIME {value {: time format}} the time that
corresponds to the specified value,or the Syntax
current system time if none is specified %TIME {(expression {:time-
format})}
Description
%TIME converts the value of the
76
Example
/free
time = %time(string:*USA);
Description
%TRIM returns the given string
less any leading and trailing
blanks.
Example
D Location S 16A
/free
Location = %trim(‘ Toronto,
Ontario ‘);
Description
%TRIML returns the given string
less any leading blanks.
Example
77
D Location S 16A
/free
Location = %triml(‘ Toronto,
Ontario ‘);
Description
%TRIMR returns the given string
less any trailing blanks.
Example
D Location S 16A
varying
/free
Location = %trimr(‘ Toronto,
Ontario ‘);
Description
%XFOOT results in the sum of all
elements of the specified numeric
array expression.
Example
D result S 15P5
/free
result = %xfoot(ARR);
// result will have the sum of all
78
Description
%XLATE translates string according
to the values of from, to, and
startpos. The first parameter
contains a list of characters that
should be replaced, and the second
parameter contains their
replacements.
Example
D up C
‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’
D lo C
‘abcdefghijklmnopqrstuvwxyz’
D String S 10A
/free
/end-free
In the above example the function
%XLATE translates the string from
lower to upper case.
%YEARS number of years number of years as a
duration Syntax
%YEARS(number)
Description
%YEARS converts a number into a
duration that can be added to a
date or time-stamp value.
Example
/free
/end-free
In the above example the function
%YEARS will add 3 years to date
variable which is of type date.
CL Program to find the number of lines of code for all the source that
is available in the input library.
PGM PARM(&LIB)
/* Gets all file objects in the library. This is done to get all */
/* source physical files in the library and stores them in OUTSPF */
DSPFD FILE(&LIB/*ALL) TYPE(*BASATR) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/OUT1)
CPYF FROMFILE(QTEMP/OUT1) TOFILE(QTEMP/OUTSPF) +
CRTFILE(*YES) INCREL((*IF ATDTAT *EQ 'S'))
/* Reads the source physical file and gets all the source */
/* available in the source PF and the inout library. */
READ: RCVF RCDFMT(QWHFDBAS)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
GOTO CMDLBL(READ)
/* Query reads the file OUTMBR and groups them according to the */
/* source type and the number of line of code. */
END: RUNQRY QRY(RTVMBRQ)
MONMSG MSGID(CPA0701)
ENDPGM
****************** End of data ****************************************
Note : Code the above program without the query(RTVMBRQ). Compile the
program and execute the program once. The outfile OUTMBR will be
created in QTEMP. Then create the below query. Code this query in the
above CL program. Complie and execute.
Sort
Prty A/D Field Text
Len Dec
10 A MLSEU Source type for S/38 View as it appeared
4
MLNAME Member
10
MLNRCD Current number of records
10 0
MLMTXT Text 'description'
50
MLFILE File
10
MLLIB Library
10
82
Break Sort
Level Prty Field Text
Len Dec
MLNAME Member
10
1 10 MLSEU Source type for S/38 View as it app
4
MLNRCD Current number of records
10 0
MLMTXT Text 'description'
50
MLFILE File
10
MLLIB Library
10
SQL Example:
83
DSTMT s 200A
C *entry plist
c parm lib 10
c parm fil 10
c parm fld 10
c parm val 2
C*
c Eval stmt = 'delete from '+%trim(lib)+'/'
c + %trim(fil) + ' where '
c + %trim(fld) + ' = '
c + '?'
C*
C/Exec Sql
C+ whenever sqlerror goto Errortrap
C/End-Exec
*
C/Exec Sql
C+ PREPARE S1 FROM :stmt
C/End-Exec
C*
C/Exec Sql
C+ EXECUTE S1 using :val
C/End-Exec
c Goto End
c Errortrap Tag
c 'Error' Dsply
c sqlcod Dsply
c sqlerrd(3) dsply
c End Tag
C Eval *INLR=*On
Yes, you can programmatically determine whether a compile was successful for both
RPG and ILE RPG members. The compiler generates data area RETURNCODE in
library QTEMP. This is a 400-byte character data area containing information about
the compile. The short answer to your question is that the first byte of this data area
will contain '1' for a successful compile or '0' for an unsuccessful compile. Your CL
program containing the compile commands can retrieve the data area and check this
value.
SNDDST TYPE(*LMSG)
TOINTNET(('johnsonhenry.kulandaisamy@scandent.com'))
DSTD('Henry from AS/400 Dev Box')
LONGMSG('Hai from henry , Now i am into the DEV Box.He he he....')
IMPORTANCE(*HIGH) PTY(*HIGH)
Step1
CRTJRNRCV JRNRCV(MYJRNRCLIB/MYJRNRCV)
Step2
Next, create the journal specifying the journal receiver created above:
Step3
CRTJRNRCV
1. Be sure to:
o Place the journal receiver in a library that is saved regularly.
o Choose a journal receiver name that can be used to create a naming
convention for future journal receivers, such as RCV0001. You can use
the *GEN option to continue the naming convention when you change
journal receivers. This type of naming convention is also useful if you
choose to let the system manage the changing of your journal
receivers
CRTJRN
1. Be sure to:
o Specify the name of the journal receiver that you created in the first
step.
o Use the Manage receiver (MNGRCV) parameter to have the system
change the journal receiver and attach a new one when the attached
receiver becomes too large. If you choose this option, you do not need
to use the CRTJRN command to detach receivers and create and attach
new receivers manually.
o Specify DLTRCV(*NO) only if you have overriding reasons to do so (for
example, if you need to save these journal receivers for recovery
reasons). If you specify DLTRCV(*YES), these receivers might be
deleted before you have a chance to save them.
You can use two values on the RCVSIZOPT parameter of the CRTJRN command
(*RMVINTENT and *MINFIXLEN) to optimize your storage availability and
system performance. See the AS/400 Programming: Performance Tools Guide
for more information.
STRJRNPF
1. Start journaling the source table using the Start Journal Physical File
(STRJRNPF) command, as in the following example:
2. STRJRNPF FILE(library/file)
3. JRN(JRNLIB/DJRN1)
4. OMTJRNE(*OPNCLO)
5. IMAGES(*BOTH)
6.
86
Specify the name of the journal that you created in step 2. The Capture
program requires a value of *BOTH for the IMAGES parameter.
STRCMTCTL LCKLVL(*CHG)
CALL PGM(*LIBL/CCTEST2)
COMMIT
CALL PGM(*LIBL/CCTEST2)
ROLLBACK
ENDCMTCTL
RETURN
ENDPGM
1. If any ILE or RPG program is performing any file operation such as Update,
add or delete, then Fspec has to be continued for the particular file to
incorporate KCOMIT.
2. Study has to be done if to COMIT the changes individually after every file
operation or collectively after processing all records.
3. Study has to be done if to call the program STRCMTCTL as an IPL or invoke
the program that implements commitment control before a particular
maintenance program is called.
4. A decision has to be made if to journal the files in all environments or to
journal only the files in development box. If we journal the files only in
development box, then the changed programs may not produce consistent
results during testing.
5. If a decision has been made to journal all the files then space might be a
constaint
6. Till the completion of bastion code consolidation , JHL environment and
BASTION objects must be attached to to different journals.
Commitment control lets you define and process a number of changes to database
files in a single unit (transaction). Commitment control can ensure that complex
application transactions are logically synchronized, even if the job or system ends.
Two-phase commitment control ensures that committable resources, such as
database files on multiple systems, remain synchronized.
Transactions
87
Revisions made to files during transaction processing are journalled when using
commitment control.
If the system or job ends abnormally, journaling alone can ensure that, at most, only
the very last record change is lost. However, if the system or job ends abnormally
during a complex transaction, the files reflect an incomplete logical transaction. For
example, the job may have updated a record in file A, but before it updated a
corresponding record in file B, the job ended abnormally. In this case, the logical
transaction consisted of two updates, but only one update completed before the job
ended abnormally.
Commitment control helps solve these problems. Commitment control locks records
from other users during a complex transaction. This ensures that other users do not
use the records until the transaction is complete. At the end of the transaction, the
program issues the commit operation, freeing the records. However, should the
system end abnormally before performing the commit operation, all record changes
for that job since the last time a commit operation occurred are rolled back. Any
affected records that are still locked are then unlocked. In other words, database
changes roll back to a clean transaction boundary.