ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

External Data Structure for Multiple Files Same Field Names

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • External Data Structure for Multiple Files Same Field Names

    Okay, I have an issue where i have 2 files that have most of the same field names. I have these files record defined in an Ext DS...

    D RC727P E DS Extname(BLAN727P) prefix(A)
    D RC728P E DS Extname(BLAN728P) prefix(B)


    This fixed the compile issue and now I'm running the program as seeing not an error, but bad data. I know I didn't have to us the PREFIX on both files, but I did just for my doing. The Ext DS names...RC727P or RC728P will be used in a CALLP later in the program. When I get to the CALLP logic, the RC727P value is blanks/packed blanks...

    c call 'BLWO001R'
    c parm 'BLAN727P' blwfil
    c parm RC727P
    c parm H@CDT

    I can't change the CALLP as this a existing program working great at a client's site. I'm just added these new files into a current process. I can't change the name of the fields in the files, so I have to see why adding the PREFIX is causing an error in the data for the CALLP. There are 36 fields names that are the same across these (2) files. I have thought using the ExtFld, but it's way to many fields and I don't think I should have to. I really don't understand why the PREFIX doesn't work.

    Any ideas?

  • #2
    Re: External Data Structure for Multiple Files Same Field Names

    What about using a qualfied data structure instead of a prefix?

    In either way when using an externally data structure with prefix or a qualified data structure, it is not automatically filled when performing a (read/update) operation code such as READ or CHAIN. The externally data structure must be specified as factor2 in the operation code to be filled correctly.

    Birgitta

    Comment


    • #3
      Re: External Data Structure for Multiple Files Same Field Names

      Do you also have the PREFIX on the F-spec? If not, the DS definitions will work, but file opcodes won't read into them. Just putting prefix on the DSes themselves wiill make them separate from the file reads/writes.

      A more modern way to do this is by reading directly into the DS, and using QUALIFIED data structures. (Your method was the recommended way for V4Rx systems, but should still work.)

      I didn't understand the part about CALL in your description. (Actually, you say CALLP, but your code shows CALL). If you can change the DSes to put prefixes on them, why couldn't you change the CALL statement? Are they in different programs? But--- I don't think the CALL statement is related to the problem, is it? Or maybe you're not using RPG file operations, and the CALL is where the DS is populated? I'm very unclear about how this works -- can you explain?

      Comment

      Working...
      X