× 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.



I introduced loop to test whether it is retrieving the data correctly
or not. And If i do not break loop using WWIND it is going into
infinite loop.

Yes. As I indicated, I suspect this is a bug.

I used hard coded values because the sized of the header wont change
right (constant), I do not feel its worthy to calculate the size every
time.

Ah, but %Size(myHeader) is not a run-time calculation. It works as a
constant introduced by the compiler. But it's self-documenting, and if at
some point you do need to adjust the size of the header (for example, for
some different format), then all you have to do is - adjust the header!
Imagine that! %Size will also remind YOU what YOU were doing. Many are the
times I've had to go back and figure out just how I came up with some
hard-coded value that would have been so easily named!

As you mentioned to use user space. So here the assumption is that The
whole data will be returned during the first call it self right.

If you have a bunch of 64K fields and you're returning hex values, as you
did in this program, you may be surprised how quickly the real estate is
consumed. But the user space should get you past the situation you faced
before. I would still allow for looping in the event that continuation
handle is present. I would still pursue with support. (I'm not in a
position to do this at present.)

For my product programs have max of 9, 999,999 bytes (i guess) of
data. Creating user space more than this should solve the problem, if
API returns all the data in a single hit.

I don't know how you came up with that value, but I trust you've done your
homework. (The "I guess" expression notwithstanding of course.)

I am thinking of another approach. If this API does not work.
1) My calling program will dump by executing DUMP opcode.
2) In called program I will CPYSPLF *LAT spool file into Physical file
. Selct the required fiels by using SQLRPGLE in the dump. (Do u guys
have any source code to read through ILERPG DUMP and returns the
required data?)

Let's hope we never again have to fall back on that type of "solution!" One
way to ensure that, is to inform the software supplier (IBM) when something
doesn't seem to be working as designed!

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
The 50-50-90 rule: Anytime you have a 50-50 chance of getting something
right, there's a 90% probability you'll get it wrong.


On Sun, May 16, 2010 at 1:51 AM, Dennis Lovelady <iseries@xxxxxxxxxxxx>
wrote:
     I need a help on the API "QteDumpModuleVariables".

Here I am trying to retrieve the variables of calling program in the
called program ( both are ILERPG and compiled iwth DEBUG *ALL views)
by
using the above API.

The Calling program has HUGE number of variables, DSs and up to 20
files
each having more than 200 fields.

Fo the API I have defined the receiver variable size as 51000.
1) For the First time It has returned around (BYtes Returned) 49,000
bytes
of data with Continuation handler <> *blanks and Number of variable
<>
*Zeros. (Bu=ytes available is 449,000).
    I have parsed the variables and sorted them in an array -
variables
and their values.

2) For the second time I called the API with Continuation handle
same as
in the previous call. Now it is returning - Bytes returned (48 byest)
-
Bytes vailable (400,000) and Number of variables = *zero and Conhand
=
*zero.
    ******Means Here It is failing and Not returning the Data
*************

This message is more appropriate in the RPG400-L list.  Please reply
there
only.

After you've put so much work into this, why would you set the error
structure (erDs) to low values?  At a minimum, I would define it as a
proper
error structure and tell the system the real number of bytes
available (80
in this case).

I have no idea why you would introduce the "do 10 times" loop toward
the
beginning of the code - data will be lost - but perhaps this is part
of
initial debug?

Your use of Off2Var is very like a kludge and prone to mishap.  In
fact,
you're using hard-coded values throughout the program for setting
your
pointers. This can have disastrous results.  You should take
statements like
the following to heart: "The caller must use the offset to next
variable
field to find the start of the next module variable section and use
the
length of module variable section to determine the length of the
current
section."  (The quote is from the documentation for the API in
question.)

Having said all that, I believe that what you are running into, is a
situation where the next variable requires more space than you have
supplied
in the rcvrVar parameter.  Although the documentation doesn't mention
this
effect, my testing shows that if I need 10000 bytes for the next
variable
and I supply less than that, the program repeated ends without error
and
without populating new data into the receiver variable (although the
continuation handle does change).  Interesting.  If the below
solution works
for you then you might want to pursue this with IBM as a bug.  It
doesn't
seem right to me.

I got around it by receiving into a user space (where rcvrVar is
based(pSpace) and pSpace is the address of the user space (returned
from
QUSPTRUS).  This is my standard method for receiving large or
potentially
large data (such as this API and the QDBRTVFD API as examples).  When
using
this technique, supply a large number (I use 16000000) as the "size
of the
return area.  (Note that when I create user spaces, I also - by
default -
create them with the "extendable" flag set.  It's a shame IBM doesn't
allow
that flag on the QUSCRTUS call, but oh well.  You can pick up my
createUserSpace procedure at http://www.lovelady.com/api-samp/

Here's a look at some of the changes I made to your program:

d RtvVar          Pr
 ExtProc('QteDumpModuleVariables')
d  Rcvvar                    50000    Options(*varSize)
d  RcvvarL                      10i 0 Const
d  Fmtnm                         8    Const
d  QPgmName                     20    Const
d  PgmTyp                       10    Const
d  ModName                      10    Const
d  DtaOpt                       10i 0 Const
d  Conhand                      16    Const
d  ErrCd                              Options(*varsize) LikeDS(erDs)

(Note addition of Const where appropriate.  This allows me to use
non-variable data in the actual call.)

d RcvrHdr_T       Ds                   Qualified Based(proto_only)
d  Brtn                         10i 0
d  BAvl                         10i 0
d  NumVar                       10i 0
d  LibO                         10
d  Res                          10
d  ConHdr                       16

D rcvrVar$        S               *
D rcvrvar         DS                   Qualified Based(rcvrVar$)
D  hdr                                 LikeDS(rcvrHdr)
D  theRest                   50000


Now I can (and will) use %Size(RcvrHdr_T) in calculating position of
first
variable section.

d erDs            DS                  Inz
D  bytesProv                    10I 0 Inz(%Size(erDS))
D  bytesAvail                   10I 0 Inz(0)
D  errID                         7
D                                1
D  errData                    4096

It's so easy!  How in this world could someone be writing a debugger
and not
have error handling in mind!???!!!?

 rcvrVar$ = createUserSpace(mySpace: 'My space') ;
 //WWIND = 1;
 rcvrVar.Hdr.conHdr = *Blanks ;
 //DOW WWIND <10;
    rtvvar(RcvrVar
         : 16000000
         : fmtName
         : qPgmNm
         : PgmTyp
         : QPgmNm.Pgm
         : dtaOpt
         : rcvrVar.Hdr.conHdr
         : erDs) ;
    ModVarHdr$ = %Addr(rcvrVar) + %Size(rcvrHdr) ;
    ModVarSec$ = ModVarHdr$ + %Size(modVarHdr) ;
 //   WWIND += 1;
 //enddo;

I did not touch anything below this point since my goal was to figure
out
your issue and try to help you get past it.  I see a few potential
problems
below here, but don't want to set your style.

Do lose the constants (and Off2Var), and work off of variables as you
see in
the setting of all these pointers.  And let us know how it turns out.

Dennis Lovelady
http://www.linkedin.com/in/dennislovelady
--
"Is there aught you would withold?  All you have shall someday be
given;
therefore, give now, that the season of giving may be yours and not
your
inheritors'."
       -- Kahil Gibran



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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.