View Full Version : Listing File members
11-05-2003, 08:48 AM
Substitute your file name into variable "File":<pre>File = 'BILL *LIBL ' Data = Copies( '00'x, 192 ) "CALL QUSDLTUS ( 'LIST QTEMP' X'0000000800000000' ) " "CALL QUSCRTUS ( 'LIST QTEMP' ' ' X'00010000' X'00' '*ALL' ' ' ) " "CALL QUSLMBR ( 'LIST QTEMP' MBRL0100 &File '*ALL' '0' ) " "CALL QUSRTVUS ( 'LIST QTEMP' X'00000001' X'000000C0' &Data ) " Do X = Int( 125 ) + 1 For Int( 133 ) By Int( 137 ) "CALL QUSRTVUS ( 'LIST QTEMP' X'"D2X(X,8)"' X'0000001E' &Data) " Member = Left( Data, 10 ) Say Member End X Return Int: Return C2D( Substr( Data, Arg( 1 ), 4 ), 4 ) </pre>
11-05-2003, 10:39 AM
Nice, Gene! Colin needs to understand that all the offsets and lengths are hard-coded and might change with OS release changes. Although it doesn't perform as well as the API method, one could do a DSPFFD and read the results in ReXX. My hac at this was DSPFD but that requires hard coding as well. /* Read a file description */ /* To use, put in QREXSRC, member DSPFD and run the following CL: */ /* STRREXPRC SRCMBR(DSPFD) PARM('QREXSRC *LIBL') */ /* Input arguments */ PARSE ARG FF FL rcdCount = 0 rcdLimit = 50 /* Get the file description */ 'DSPFD &FL/&FF TYPE(*MBRLIST) OUTPUT(*OUTFILE) OUTFILE(QTEMP/MBR)' /* Override STDIN to the DB2 file */ 'OVRDBF FILE(STDIN) TOFILE(QTEMP/MBR)' /* Read a line from the file */ Read: PARSE PULL dtaInput rcdCount = rcdCount + 1 /* Record limit */ IF rcdCount > rcdLimit THEN DO SAY 'Record limit ('rcdLimit') reached' SIGNAL Exit END /* record is NULL at EOF */ IF dtaInput <> '' THEN DO SAY substr(dtaInput,65,10) SIGNAL Read END Say 'EOF reached' Exit: RETURN --buck
11-05-2003, 12:03 PM
The example doesn't hard-code offsets in the receiver user space. On the contrary: <UL><LI>"Int(125)" fetchs the soft-coded location of the first list item <LI>"Int(133)" fetchs the soft-coded number of list items <LI>"Int(137)" fetchs the soft-coded length of a list item[/list] No need to change the REXX if IBM in a future release changes the offsets and lengths in the API's receiver user space.
11-06-2003, 06:49 AM
That's great thanks for the help.
11-06-2003, 07:12 AM
The only times I have used APIs have been when someone gives me the code. Where can I go to learn more? I am sure there is alot of other code on our system that could be much more effective if I had an understanding of APIs. Is there a course or a book that you can reccommend?
11-06-2003, 07:37 AM
> The example doesn't hard-code offsets in the receiver user space. On the contrary: I did not read deeply enough and missed the function 'int' at the bottom. My apologies, and thanks for the correction! Your approach looks better every time I look at it. Colin, API information can be found in the Infocenter, under the programming link on the left. http://www.iseries.ibm.com/infocenter --buck
11-07-2003, 06:51 AM
Does any one have a reference for managing files using REXX? I have been trying to figure out a way to list, store and eventually display a member list of a file. I am sure there must be an easy way that I just haven't figured out yet. Does any one have any suggestions
11-07-2003, 06:51 AM
Colin, you might find our book called APIs at Work useful. Here's the link: http://www.mc-store.com/5024.html Victoria Mack, Editor, MC Mag Online
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.