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

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

896


1. What is bound-by-call and bound-by-reference? 2. Where and why is *Nomain used? 3. What are the difficulties faced by programmers when using service programs? 4. Explain the different ways of parsing and compiling XML in iSeries.

5935


what is file information data structure?

1771


Set on command is used for closed all opened files , initialize var and release resource , return cmd is used for return to calling program but my req. Is dnt close opened files and resource must released while doing transactions , how can i do this...?

1709


what is program status data structure?

1805


How to create a login screen using a command instead of display file.... intention is to get a password field on a command..... how do you achieve this...

1519


How to call one program from another program in RPG? please help me with the code

1482


are there any useful c runtime apis that I can call from rpg iv?

916


what is the necessary keyword needed to scroll subfile records?

918


What is a record lock error?

1499


how do I declare a minor?

904


can anybody help me to solve this problem. the program that i m checking display error message saying "Record format for file AJDSPFFD does not match model file and decimal error. how to solve this problem. The AJDSPFFD is snapshot the AJTLOG that is the audit trail list.

2556


How to select highest score of each subject or how to select highest income of every month?

1508


is this a rpg channel?

898


what was the robotech rpg?

872