Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

%KDS all free form 1

Status
Not open for further replies.

thelearner

Programmer
Jan 10, 2004
153
US
Hi,

I have a file name PRMAST with 3 keys,
PRCUCD 6A
PRPRCD 25A
PRSEQ 1A
Instead of doing this
CHAIN (CUST:pART) PRMAST;
I want to try BIF %KDS with KLIST define in data structure like this.
PRKEY DS
CUST 6
PART 25

CHIAN %KDS(PRKEY:2) PRMAST;

I got the compile error, saying that number of KFLDs in KLIST is greater than number of key fields in file.

Am I missing anything? I want to try everything in free form so please don't suggest a fix format.

Thanks
 
I thought %KDS didn't work under V5R1.

Check your file. Sounds like you only have 1 key field defined.


RedMage1967
IBM Certifed - RPG IV Progammer
 
I checked my file (even though I'm 100% sure about it). My file has 3 key fields and the lenght are the same as mention on my first post.
 
You put them in the same order in the %KDS??



RedMage1967
IBM Certifed - RPG IV Progammer
 
I defined them in the data structure in the same order with what the file has. In the %KDS, I use name of the key like below.

PRKEY DS
CUST 6
PART 25

CHIAN %KDS(PRKEY:2) PRMAST;
 
Here's the example from the manual:
Code:
Figure 194. 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

Hope this helps.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Thank RedMage1967. I just wonder why mine did not work. I follow the sample from RPGIV book from Bryan & Judy.

Another question. Do you know how to use this.
D PRKEY E DS EXTNAME(PRMAST:*KEY)

Thanks.
 
It has been quite a while since the PTF was applied so I was assuming it was back on v5r1 but it probably was v5r2.
We jump on the new releases so quickly that I forget when we had which release.
So my vote is you need the latest RPG PTF's.
According to IBM the workaround is to specify the format name rather than the file name.

Below is a list of RPG PTF's, look at SI08199.

PTF Cover Letters

Search Results

10 documents found

PTF Release Abstract
SI08520 V5R2M0 RPGLE-CMPL-MSGRNF7030 FOR CONSTANT SPECIFIED AFTER
QUALIFIED
SI08368 V5R2M0 RPGLE-RUN-INCORROUT %CHAR(DATE:*JOBRUN) WITH JOB DATFMT
*JUL
SI08363 V5R2M0 RPGLE-RPGLEPRV-INCORROUT SEVERAL PROBLEMS FIXED
SI08199 V5R2M0 RPGLE-CMPL-MSGRNF7071 USING FILE NAME ON CHAIN WITH %KDS
SI07461 V5R2M0 RPGLE-RUN-MSGMCH74A0 RPG CALLING JAVA JVM ENDS OUT OF
MEMORY
SI07183 V5R2M0 RPGLE-CMPL-MSGMCH3601 CHAIN WITH CHAR AND NUMERIC KEY
SI00011 V5R2M0 RPGLE-CMPL-MSGEVF3140 COMPILING IFS SRCSTMF WITH
SI06583 V5R2M0 RPGLE-CMPL-INCORROUT DS SUBFIELD WITHOUT NAME AND FROM/TO

SI05006 V5R2M0 RPGLE-CMPL NULL VALUE SUPPORT EXT-DESC I/O WITH DATA
SF98520 V5R2M0 Current Cumulative PTF Media Documentation


T. Bishop
 
rapeek

I'm still at V5R1, so I can't use the %KDS yet. All I know is what I've read (and posted) from the IBM manual.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Yep! It's work after change to record format name. Thanks.
Now my other question. Does anyone know how to use this?

D PRKEY E DS EXTNAME(PRMAST:*KEY)

In the book it said by using this code, we don't have to key the subfields for the data structure. How can the pgm know which fields I want to associate with the key list PRKEY?
 
By what you defined in LikeRec keyword. Check my example post above.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Hi,

This is what I tried. It did not compile.

F$PRMST IF E K DISK

D PRKEY E DS EXTNAME(#PRMST:*KEY)

D PRKEY DS LIKEREC(#PRMST:*KEY)
D CUST S 6
D PART S 25
*
/free
PRKEY.PRCUCD = CUST;
PRKEY.PRPRCD = PART;
CHAIN %KDS(PRKEY) #PRMST;
*inlr = '1';
/end-free
****************** End of data *****
 
you're defining the data structure twice, you don't need to. try deleting:
Code:
D  PRKEY    E DS  EXTNAME(#PRMST:*KEY)
and see if that will compile.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Hi,

I'm trying to use this line.
D PRKEY E DS EXTNAME(#PRMST:*KEY)
I saw it in the book, just don't know how to use it.
 
I think if you use just the KeyRec data structure, you'll be fine.

RedMage1967
IBM Certifed - RPG IV Progammer
 
Yes, I know that I can do the other way. I just want to learn how to use this one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top