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




Rather than reading the record again in the edit routine, I thought I
could pass a pointer to the record layout from the file process program.
The edit program would simply treat the fields as 'input' for edit
processing.

Why do you want to use a pointer for this? Why not simply pass the record as a parameter?

I presume that I would include the record as a data structure in the
second program

Exactly. Load the record into a data structure, and pass that data structure as a parameter.


and somehow or other 'connectt' it to the pointer passed in, so that the DS layout was 'overlaid' to storage from the pointer reference position.

why do you want to "connect" it to a pointer? This is where you're losing me. Why not just pass the data structure with the record. Why the pointer logic?

I hope I've explained the problem clearly, and that someone can provide
some code snippets or specific references .

It's not difficult, you just need to make it load the record into a data structure so that you have something to pass. For example:

     FCUSTMAS   IF   E           K DISK
     D CustRec       e ds                  extname(CUSTMAS)
      .
      .
     c     custno        chain     custmas

     C                   if        %found
     C                   CALL      'EDITPGM'
     c                   PARM                    CustRec
     c                   endif

What happens in that code is that the fields from the CUSTMAS file are all in the CustRec data structure. Why? Because the data structure is declared to have the same fieldnames as the CUSTMAS file. Therefore, all of the fields will be loaded into it. Now, I can call a program, and simply pass the data structure as a parameter.

The EDITPGM program can receive the parameter the same way:

     D CustRec       e ds                  extname(custmas)

     c     *entry        plist
     c                   parm                    CustRec

Now the record will be loaded, and the field names will be the same as the ones in the CUSTMAS file. Note that no F-spec is required.

Now, granted, that's more traditional coding. If you're someone who prefers free format RPG and prototypes, you'd code it this way:

Copy Book for EDITPGM (I called it EDITPGM_H):

     D CUSTMAS_T     E ds                  qualified
     D                                     extname(CUSTMAS)
     D                                     based(TEMPLATE)

     D EDITPGM         PR                  ExtPgm('EDITPGM')
     D   Record                            likeds(CUSTMAS_T)
     D   ErrorCode                   10I 0
     D   ErrorMsg                    80A   dim(10)

     D ERRBADCUST      C                   const(1001)
      .
      .

The calling program:

     FCUSTMAS   IF   E           K DISK    Prefix('CUSTREC.')

      /copy EDITPGM_H

     D CustRec         ds                  likeds(CUSTMAS_T)
     D errcode         s             10I 0
     D errmsg          s             80a   dim(10)

      /free
         .
         .
            chain custno CUSTMAS;
            if %found;
               EDITPGM(CustRec: errCode: ErrMsg);
            endif;
         .
         .
      /end-free

And the EDITPGM code would look something like this:

      /copy EDITPGM_H

     D EDITPGM         PI
     D   Record                            likeds(CUSTMAS_T)
     D   ErrorCode                   10I 0
     D   ErrorMsg                    80A   dim(10)

      /free

           if (Record.CustNo < 0);
                ErrorCode = ERRBADCUST;
                ErrorMsg(1) = 'Customer number must be 0 or higher';
                return;
           endif;

           .
           .

      /end-free

So, no matter how you prefer to code it, it's actually very easy to do this in RPG. I don't see why you'd ever want to pass a pointer for this. (Though, it wouldn't be difficult, either... it just wouldn't make sense.)

Does that help?

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.