I have accomplished what you are doing with I/O and data structs, exactly
the same way you are doing it.  I have seen similar issues when using the
file name on the READ, rather than the format name, but it looks like you
are using the format name.  So here's an idea... Try using the file name on
the READP.  Other than that, like Tim suggested, use LIKEREC on the DS
instead.

Of course, encapsulation would prefer you to place the Q data structure
inside the subproc that needs it (private), but that is just a matter of
preference, and won't cause a compile error.  I have become more militant
about such things in my own coding since I have learned java ;-)

On 12/7/05, Rich Duzenbury <rduz-midrange@xxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi all,
>
> I'm getting a compile error on what looks like OK code to me.  I've
> stripped the program down as small as possible to demonstrate the error,
> which happens to occur on a V5R2 machine.
>
> What I want to do is load the WMERLG record format fields, then, locate
> the highest EID in the file, add one to it, and attempt to use it for
> the new record key.  I don't want the 'next_eid' routine to clobber the
> E* fields, hence the need for reading into a data structure.
>
> Here is the file, WMERLGP:
>      A                                      UNIQUE
>      A          R WMERLG
>      A            EID           11P 0
>      A            EACCT#        11P 0
>      A            EAPLNM        20A
>      A            EAPFNM        12A
>      A            EAPITL         1A
>      A            EVISDT          Z
>      A            EREVDT          Z
>      A            EUSRID        10A
>      A            ERSTS          1A
>      A          K EID
>
> And the code:
>      H dftactgrp(*no) actgrp(*caller)
>      H OPTION(*SRCSTMT:*NODEBUGIO)
>
>      FWMERLGP   if a e           k disk
>
>      d Q             e DS
> EXTNAME(WMERLGP:WMERLG:*INPUT)
>      d                                     QUALIFIED
>
>      d next_eid        pr            11s 0
>      d $err            s               n
>
>       /free
>          $err = '0';
>          dow $err = '0';
>              EID = next_eid();
>              write(e) WMERLG;
>              $err = %error;
>          enddo;
>          *inlr = '1';
>       /end-free
>
>      p next_eid        b
>      d next_eid        pi            11s 0
>
>      d result          s             11s 0
>
>       /free
>          setgt *hival wmerlgp;
>          // read into a ds so as not to disturb the
>          // global file fields
>          readp wmerlg Q;
>      // RNF7701 here!
>          if %eof(wmerlgp);
>              result = 1;
>          else;
>              result = q.eid + 1;
>          endif;
>          return result;
>       /end-free
>      p                 e
>
>
> The error is RNF7701, 'Data structure is not allowed for the operation',
> and lists the line of code that does 'readp wmerlg Q'.
>
> I've tried EXTNAME(WMERLGP), EXTNAME(WMERLGP:*INPUT),
> EXTNAME(WMERLGP:*OUTPUT) and also with and without the 'QUALIFIED',
> still get the error.
>
> PS - I tried to put the code on the code.midrange.com app
> (http://code.midrange.com), but I receive the following error, 'Access
> denied for user 'nopaste'@'localhost' (using password: YES)'
>
> If you have any ideas, let me know, please.
>
> Thanks.
>
> Regards,
> Rich
>
>
> --
> 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.
>
>


--
"Enter any 11-digit prime number to continue..."
"In Hebrew SQL, how do you use right() and left()?..." - Random Thought
"If all you have is a hammer, all your problems begin to look like nails"

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.