× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



John,

Unfortunately, there isn't a really good way to handle this.

The DS has to have some finite size defined. I just define a buffer of 32K or
so and use the offsets
to figure out where stuff is at.

It should be too big of a deal as your program calling the API can be wrapped
in a procedure that is
easier to use.

d t_RtvMsgFmt0100...
d ds qualified based(TEMPLATE)
d bytesRtnd like(t_Int4)
d bytesAval like(t_Int4)
d msgLenRtnd like(t_Int4)
d msgLenAval like(t_Int4)
d msgHlpLenRtnd like(t_Int4)
d msgHlpLenAval like(t_Int4)
d data like(t_Buffer32k)

if msgInfo.msgHlpLenRtnd > 0;
msgHelp = %subst(msgInfo.Data
:msgInfo.msgLenRtnd + 1
:msgInfo.msgHlpLenRtnd);
else;
msgHelp = *BLANKS;
endif;

HTH,

Charles

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of johnking@xxxxxxx
Sent: Tuesday, June 26, 2007 4:30 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: Defining DS to retrieve variable length data from API

All,

Q) How to define a DS to retrieve variable-length data from
an API? The goal is to define an /include member that can be
used in V5R3 RPGLE.

For example, QMHRCVM uses format RCVM0100 to return the text
of a message.
Although the length of the data available to "MsgRplData" is
actually defined by "RplDAvail", for most purposes just
defining "MsgRplData" as a fixed length is sufficient.
Referencing this DS in a calling program with
"LikeDS(RCVM0100_t) Inz(*likeDS)" makes using this API
convenient and consistent.

D RCVM0100_t DS Qualified
D RCVM0100 32767A
D ByteReturn 10I 0 INZ Overlay(RCVM0100)
D ByteAvail 10I 0 INZ Overlay(RCVM0100:*next)
D MsgSever 10I 0 INZ Overlay(RCVM0100:*next)
D MsgId 7 INZ Overlay(RCVM0100:*next)
D MsgTyp 2 INZ Overlay(RCVM0100:*next)
D MsgKey 4 INZ Overlay(RCVM0100:*next)
D Resserve_1 7 INZ Overlay(RCVM0100:*next)
D CCSID_CnvSt 10I 0 INZ Overlay(RCVM0100:*next)
D CCSID_RplD 10I 0 INZ Overlay(RCVM0100:*next)
D RplDReturn 10I 0 INZ Overlay(RCVM0100:*next)
D RplDAvail 10I 0 INZ Overlay(RCVM0100:*next)
D MsgRplData 127 INZ Overlay(RCVM0100:*next)

So how should RCVM0200 be defined if it became necessary to
retrieve the "MsgText" or "MsgHText" fields? Their start
positions depend of the length of the previous fields.

D RCVM0200_t DS Qualified
D RCVM0200 32767A
D ByteReturn 10I 0 INZ Overlay(RCVM0200)

D RplDReturn 10I 0 INZ Overlay(RCVM0200:*next)
D RplDAvail 10I 0 INZ Overlay(RCVM0200:*next)
D MsgReturn 10I 0 INZ Overlay(RCVM0200:*next)
D MsgAvail 10I 0 INZ Overlay(RCVM0200:*next)
D MsgHReturn 10I 0 INZ Overlay(RCVM0200:*next)
D MsgHAvail 10I 0 INZ Overlay(RCVM0200:*next)
D RplDText (*)
D MsgText (*)
D MsgHText (*)

I'm sure there is some combination of "%addr" and "%len" and
"overlay" and "presto" that will accomplish this but I'm sure
having trouble getting clear on the concept. Would anyone be
kind enough to point me to a previous thread or article that
discusses this?

Many thanks, JK

---- Msg sent via Internet America Webmail -
http://www.internetamerica.com/
--
This is the RPG programming on the AS400 / iSeries (RPG400-L)
mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




This e-mail transmission contains information that is intended to be
confidential and privileged. If you receive this e-mail and you are not a
named addressee you are hereby notified that you are not authorized to read,
print, retain, copy or disseminate this communication without the consent of
the sender and that doing so is prohibited and may be unlawful. Please reply
to the message immediately by informing the sender that the message was
misdirected. After replying, please delete and otherwise erase it and any
attachments from your computer system. Your assistance in correcting this
error is appreciated.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.