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



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

Answer / 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

More RPG400 Interview Questions

How to print output from openquery in as400 ?

1 Answers   Four soft,


Hi guys, anybody know How RPG/400 code can be converted to RPG IV code with a single command?

1 Answers  


Why we cannot call a service program? If I add a PEP can i call the service program?

1 Answers   DELL,


What is the difference between ITER and DO ? I know both are used to execute set of statements repeatedly, but what is the main difference?

2 Answers   CGI, Wipro,


How to sort an array in descending in RPG

3 Answers   Google, TCS,






When PGMA calls PGMB for the first time PGMB executes the *INZSR. PGMB uses the RETRN operation to return to PGMA. When PGMA call PGMB the second time is the *INZSR executed?

5 Answers   Mphasis,


Write the subfile logic program for the given concept. Load the data to the subfile depends upon the designation where designation is not a key field?

2 Answers   TCS,


Thanks gagan for your answer,i'm new to as400,i don't know embedded sql in rpg.can you send me the coding for the below mentioned question in embedded sql rpg. how to retrieve particular field records from a physical file,say i have a physical file called 'employee' in it i have to retrieve the records of a field 'admin' present in pf 'employee' using rpg,but i should not use logical file or openquery file.

2 Answers   iGate,


how to retrieve particular field records from a physical file,say i have a physical file called 'employee' in it i have to retrieve the records of a field 'admin' present in pf 'employee' using rpg,but i should not use logical file or openquery file.

3 Answers   iGate, Wipro,


How to get only unique records from a file which contains duplicate data using CPYF command ? Example : FILEA has duplicate records and FILEB is a UNIQUE defined.... and I want to get the data from FILEA to FILEB by eliminating all the duplicate records...

1 Answers  


what is meant by record lock.how records are locked.what is the purpose of record lock.if records are locked what happens.how to find out which record is locked.

4 Answers   HCL,


As Packed veriable store 2 digits in 1 byte and ZONE variable store 1 digit in 1 byte... Please tell me when we have to use Packed and Zone variable...?

1 Answers  


Categories