Search code examples
ibm-midrangerpgle

Copy implicit variables from an external defined file into a struct on IBM i


I have a PF, referenced in an rpgle-program. The record format name is "ROETBL".

FROEPF     UF A E           K DISK

Now I create a struct of fields with a distinct name (C_ for "copy") from the resulting (internal) input specs:

DC_ROETBL       E DS                  EXTNAME(ROEPF:ROETBL) PREFIX(C_)

How am I supposed to to something like:

C                   MOVE      ROETBL        C_ROETBL

The compiler complains with RNF7260: ROETBL in Factor 2 isn't valid for the given operation.

Since I read that it's possible to utilize functions in the C library from within RPGLE, I also tried that to exploit using memcpy. Unfortunately, I don't have the exact error message at hand anymore but I also could not compile the source because ROETBL is not a pointer to a struct.

Any comments on that? I am using operating system version V4R5.


Solution

  • Mike's right, EVAL-CORR is designed to make it easy to copy data from DS to DS...

    But EVAL-CORR was added at v5r4...plus it's really designed for working with qualified data structures and doing I/O directly into a DS; as opposed to stand-a-lone global variables.

    Your other issue is thinking that the format name (ROETBL) is a memory structure like a DS, it isn't.

    Try defining another DS without a prefix, so that the file fields will be organized into a DS.

     fROEPF     UF A E           K DISK
    
     d rec           e ds                  extname(roepf)
    
     d rec2          e ds                  extname(roepf) prefix(c_)
    
     c                   eval      rec2 = rec
     c                   eval      *INLR = *ON
     c                   return