|
Well, i'm not from IBM. But obviously i understood the manuals. They could be better, it is not easy, i agree. You build up the structure for the input DS, that you've got right. So you have to know. The offset is simply of the same kind as offset in the left of the structures in the manuals. It's a storage layout. The info you have to provide can vary from some bytes to many bytes. It's a self-describing structure, designed to be used with pointers. Solution proposal: Get yourself some storage. Define a DS with, say, 32767 bytes. You can shorten it to a reasonable value later on. D MyJSLT0200 DS 32767 You build up a DS for all fixed postioned fields of JSLT0200 (you didn't tell us which you want to use, i take this one). These are for JSLT0200 all fields up to CCSID and the reserved 4 bytes. This leads us to a DS with a size of 92 bytes, but that is irrelevant. This DS is based on your storage. D JSLT0200Hdr DS based(%ADDR(MyJSLT0200) D JSLT0200MaxMsg... D 10I 0 <snip> D JSLT0200OfsFI... offset to field identifiers of fields to return D 10I 0 D JSLT0200NofFI... number of fields to return (better: field identifiers of fields to return) D 10I 0 and so on till D JSLT0200ReservedMustBeZero D 10I 0 The based means that you get no storage for this DS-variables. You have to provide a pointer pointing on existing storage to have values in it. In this case, as it will never change, the address of the big DS is put into the based() and JSLT0200Hdr lies over the very same storage as MyJSLT0200. And then you have to EVAL JSLT0200ReservedMustBeZero = *ZERO. (e.g. *INZSR) Now build up another DS, again based. This time with a pointer. D JSLT0200FIDS DS based(PtrJSLT0200FIDS) D JSLT0200FI 10I 0 This time, a pointer field is in the based(). Its a variable that can only hold addresses in storage. Now its *NULL, you've to set it. It is filled with the pointer of your address PLUS an offset to the beginning of this DS. You need the offset anyway, so let's set and use it. C EVAL JSLT0200OfsFI = %SIZE(JSLT0200Hdr) the size in byte of the "Header"-DS. C EVAL PtrJSLT0200FIDS = %ADDR(MyJSLT0200) + C JSLT0200OfsFI Now set the first key you want to retrieve, e.g. 0301 Message. C EVAL JSLT0200FI = 0301 Say, you want another key. Now comes the big adavantage, you simply shift the DS around in storage to fill the next 4 bytes. C EVAL PtrJSLT0200FIDS = PtrJSLT0200FIDS + C %SIZE(SLT0200FIDS) This increases the address and "moves" the DS this way. C EVAL JSLT0200FI = 00603 Sending program name Now you have to provide the number of entries you have in the "Number of fields to return"-field. C EVAL JSLT0200NofFI = 2 Wen want two keys in this example, 0301 and 00603. The offset to call message queue is calculated: C EVAL JSLT0200OfsCMQ = JSLT0200OfsFI + C JSLT0200NofFI * %SIZE(JSLT0200FIDS) (You might also calculate such things by subtracting two pointers to get the difference in numbers of bytes between them.) And with this info, you build up a based DS (Pointer) and fille the Pointer with the address of MYJSLT0200 plus the offset, just like before. When you debug, look at MyJSLT0200 (ev MyJSLT0200:x 256) and compare it with the manual. You should see the light then. Download the redbook "Who knew you could that with RPG?" to see that there are good books at IBM. (regardless of how near the writers are or were to IBM.) It's suddenly needed to register, but i did it and it's fast and does no harm. http://www.redbooks.ibm.com/abstracts/sg245402.html right click the link "View online" and save target as. You'll need Adobe Acrobat Reader. (For free at http://www.adobe.com/products/acrobat/readstep1.html ) GET IT, YOU NEED IT! 0.04 Euro Anton Gombkötö +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.