HI,
1: WHAT IS THE FUNCTION OF %KDS?WITH PROGRAMMING CODES
EXAMPLE
2: WHAT IS THE FUNCTION OF Z-ADD AND Z-SUB ? WITH
PROGRAMMING CODES EXAMPLE

Answer Posted / rakesh

1:
%KDS is allowed as the search argument for any keyed
Input/Output operation (CHAIN, DELETE, READE, READPE, SETGT,
SETLL) coded in a free-form group. The search argument is
specified by the subfields of the data structure name coded
as the first argument of the built-in function. The key data
structure may be (but is not limited to), an externally
described data structure with keyword EXTNAME(...:*KEY) or
LIKEREC(...:*KEY)..
Notes:

The first argument must be the name of a data structure.
This includes any subfield defined with keyword LIKEDS or
LIKEREC.
The second argument specifies how many of the subfields
to use as the search argument.
The individual key values in the compound key are taken
from the top level subfields of the data structure.
Subfields defined with LIKEDS are considered character data.
Subfields used to form the compound key must not be arrays.
The types of all subfields (up to the number specified
by "num-keys") must match the types of the actual keys.
Where lengths and formats differ, the value is converted to
the proper length and format.
If the data structure is defined as an array data
structure (using keyword DIM), an index must be supplied for
the data structure.
Opcode extenders H, M, or R specified on the keyed
Input/Output operations code affect the moving of the search
argument to the corresponding position in the key build area.

Example:
Figure 205. Example of Search on Keyed Input/Output Operations

A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++
A R CUSTR
A NAME 100A
A ZIP 10A
A ADDR 100A
A K NAME
A K ZIP
FFilename++IPEASF.....L.....A.Device+.Keywords+++++++++++++++++++++++++
Fcustfile if e k disk rename(CUSTR:custRec)
DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
D custRecKeys ds likerec(custRec : *key)
...
/free
// custRecKeys is a qualified data structure
custRecKeys.name = customer;
custRecKeys.zip = zipcode;
// the *KEY data structure is used as the search
argument for CHAIN
chain %kds(custRecKeys) custRec;
/end-free

Googled/ref :-
http://publib.boulder.ibm.com/infocenter/iadthelp/v7r0/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/c0925086640.htm


2: Z-ADD and Z-SUB does the ADD/SUB resp. to a field of Zero.

Z-ADD 5 VAR
** (VAR now has 5)
ADD 10 VAR
** (Var now has 15)
Z-ADD 20 VAR
** (Var now has 20 and not 35)

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++*
C* Before the operations are processed, the field values are:
C* A = 1.00 G = 2.77
C* B = 10.0 H = 70
C* C = 32 J = .6
C* D = -20 K = 25
C* E = 6. L = 1.0, 1.7, -1.1 RESULTS
C* F = 10.0 -------
C ADD 1 A 30 002
C B ADD C V 52 042.00
C B ADD D V -10.00
C*
C Z-ADDC V 032.00
C*
C SUB 1 E 30 005
C C SUB B W 51 0022.0
C C SUB D W 0052.0
C*
C Z-SUBC W -0032.0
C*
C MULT E F 30 060
C B MULT G X 84
0027.7000
C B MULT D X
-200.0000
C*
C DIV B H 30 007
C C DIV J Y 62 0053.33
C*
C MVR Z 53 00.020
C*
C SQRT K Z 05.000
C*
C XFOOTL Z 01.600

Ref:-
http://publib.boulder.ibm.com/infocenter/iadthelp/v7r5/index.jsp?topic=/com.ibm.etools.iseries.langref.doc/evferlsh239.htm

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how do I declare a minor?

707


how can I tell when to replace the array?

692


How would display prime numbers using CL program?

5666


RETRIVING DELETED RECORDS :- I'm frequently asked how to retrieve deleted records from an unjournaled physical file when the deleted records have not yet been removed from the file. Utility UNDEL lets you undelete records in a physical file. This public domain program is available in CISC and RISC versions, and the complete source code is available for download at: UNDEL for AS/400 Save File (RISC): http://www.as400network.com/sharewarefiles/undelris.zip UNDEL for AS/400 Save File (CISC): http://www.as400network.com/sharewarefiles/undel.zip UNDEL for AS/400 Save File (Source code): http://www.as400network.com/sharewarefiles/undelsrc.zip The utility takes advantage of the fact that deleted records in physical files are only flagged as deleted, and the record data still exists until it is overwritten or the file is reorganized with a utility such as RGZPFM. UNDEL simply reads the deleted record, then reuses the record by writing over it with the new record (thus eliminating the flag for the deleted record). Some homegrown and commercial utilities copy the file containing undeleted records to a save file, then use a program to read the save file, which contains live and undeleted records, to a file to undelete the records. The UNDEL utility is superior to the SAVF technique because there's no need to copy the file to a save file, which is especially important for really large files. When run, UNDEL displays the physical file records in their unformatted, raw text form. You can either position the display to a given relative record number or use F19 or F20 to find the previous and next deleted record, respectively. The utility also includes online help, which is almost unheard of for free utilities. Other utilities include the ability to undelete records. You can use the RTVDLTRCD command in the old QUSRTOOL (no longer supported by IBM). QUSRTOOL is now a commercial product called TAA Productivity Tools ( http://www.taatool.com ). The free file editor WRKDBF has a built-in undelete capability ( http://www.wrkdbf.com ), and several commercial file editors can undelete records. For a complete list of file editors, go to http://www.sourcebook400.com, select "Programmer Tools" under "Product Category," then select "File Editors."

14114


how do I declare a table or array in rpg iv?

728






How to write record if no field or the field are different in physical file in rpgle ?

476


When we have a file with Duplicate records and I want to read the unique record from the file. For example a file containing Emp Name as 'Ram' and there are 3 entries of it. So how to read a unique record from File?

494


thanks mr.Harshad R Suryawaunshi,i'm new to as400 i think you are telling in rpgile i know only rpg400 if possible can you tell in rpg400

1881


what is the necessary keyword needed to scroll subfile records?

695


Suppose we have one database file and it is used by 5 programs and in 3 program we have to add some records in datbase file s what is the impact on other program?

1443


what is kids-rpg?

659


what are the key words you must use when using a subfile?

684


How many program bind in one module....

2109


How to handle duplicate error handling in RPG?

1666


How can we know running job is batch or interactive?

643