+ Reply to Thread
Results 1 to 5 of 5

Thread: Data structure parameter issue

  1. #1

    Default Data structure parameter issue

    d_meca wrote: > > I am creating a procedure (within a service program) that accepts a data structure as a parameter. > > Since the procedure is generic it will receive different types of data structures. The length and type of the data structure being passed is unknown and will vary. > > Is there a way of finding the lengths/types/names of each field within the data structure being passed? > Can any of this be achieved using pointers? > If the data structure is externally-described from a file, you could also pass the file name to your procedure, and your procedure could use an API (QUSLFLD) to get the layout of the data structure (field names, lengths, types etc). Use google to search for this API - you should be able to find some RPG examples. If you add "extpgm" to your search, it will increase the likelihood of it being an RPG example. http://www.google.com/search?hl=en&q=quslfld+extpgm

  2. #2
    Guest.Visitor Guest

    Default Data structure parameter issue

    Thanks Barbara. I have already implemented what you have described above. Now I'm trying to take the next step and use 'internal user defined data structures'. From what people have been telling me it looks like it can't be done.

  3. #3
    Guest.Visitor Guest

    Default Data structure parameter issue

    I am creating a procedure (within a service program) that accepts a data structure as a parameter. Since the procedure is generic it will receive different types of data structures. The length and type of the data structure being passed is unknown and will vary. Is there a way of finding the lengths/types/names of each field within the data structure being passed? Can any of this be achieved using pointers?
    Code

  4. #4
    odedf Guest

    Default Data structure parameter issue

    You can write the metadata in the same DS. for each field writre its attributes befor you send it . The srvpgm will read them and put in tPROGRAM A D abcd_DS DS D A_TYP 1A (= A,T,D...) D A_LNG 2S (= LENGTH) D A_DEC 2S (=LENGTH) D a 1a D b 2a D c 3a D d 4a D END 1A INZ('/') he proper filds. Use varchar will help.

  5. #5

    Default Data structure parameter issue

    d_meca wrote: > > Thanks Barbara. I have already implemented what you have described above. Now I'm trying to take the next step and use 'internal user defined data structures'. From what people have been telling me it looks like it can't be done. Correct, a called procedure can't detect anything about a data structure parameter that it was passed, by on looking at the parameter's data. You would have to have some way of telling the procedure about the layout of the DS. Rather than have the information directly in the data structure as odedf suggested, I would add a separate parameter that described the data structure, probably as an array of data structures, with each element describing one subfield. But the complexity of defining the describing data structure might be too great compared to whatever your procedure does. Unless the program described data structures would have features that aren't supported by DDS, it would probably be easiest to have the programmers define a file to describe their data structure, and use your existing procedure.

+ Reply to Thread

Similar Threads

  1. data structure data area write to PF
    By B.Morris in forum RPG
    Replies: 2
    Last Post: 01-10-2005, 05:07 PM
  2. Data Structure as Parms
    By rawinans in forum RPG
    Replies: 7
    Last Post: 09-01-2004, 07:05 AM
  3. Data Structure... How To..????
    By DougCMH in forum RPG
    Replies: 2
    Last Post: 10-01-2003, 05:23 AM
  4. Array and Data Structure with same name
    By Guest.Visitor in forum RPG
    Replies: 3
    Last Post: 08-14-2002, 10:29 AM
  5. Data Structure
    By chuck.nordin@hmhpub.com in forum RPG
    Replies: 1
    Last Post: 05-01-2002, 11:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts