ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Copying data structures

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

  • Copying data structures

    I have been asked to modify a rather old RPG II program. I am going to convert it to and SQLRPGLE program. It reads a file as input primary and then uses IF statements the records it wants based on a date field. I am going to replace the logic with a SQL cursor and then fetch it into a external data structure using the the IP primary file name in the EXTNAME parameter of the DS definition. The field names of the IP primary file are used throughout the program and I don't want to have to replace the current field usage with qualified field names as there are just too many. Is there a way to copy the fields from the qualified data structure to another one one that is unqualified so I don't have to move each field individually'

    Hope this makes sense.

  • #2
    You can use EVAL-CORR between a qualified data structure and an unqualified data structure.

    But you didn't explain why you need the qualified data structure, why you can't just leave the EXTNAME data structure unqualified ...

    Comment


    • #3
      Originally posted by Barbara Morris View Post
      You can use EVAL-CORR between a qualified data structure and an unqualified data structure.

      But you didn't explain why you need the qualified data structure, why you can't just leave the EXTNAME data structure unqualified ...


      OK, I see what the problem is now. When I remove the "Qualified" from the data structure definition, I get this syntax error:
      Click image for larger version

Name:	Code 400.jpg
Views:	363
Size:	12.4 KB
ID:	157187
      this seems to be caused by the fact that ORSPDT is a field in file ORITEMJ8 and ORSPDT is defined as another data structure
      Click image for larger version

Name:	Code 400_2.jpg
Views:	385
Size:	14.3 KB
ID:	157188
      So, that brings me to ask the question how can I define fields OM, OD, OM (which are used elsewhere in the program) as subfields of ORSPDT in external data structure JRNLREC? Guess I could always rename data structure ORSPDT to ORSPDTX and then move ORSPDTX to ORSPDT after each fetch.

      Attached Files

      Comment


      • #4
        Perhaps you can use open access to replace the input primary file. In the handler you could put your SQL-statements.
        I'm all familiar with the problem with the data structures to group date fields.

        But take a look at my solution to emulate the eval-corr between a record buffer and the datastructure.
        4 years ago I started the RFE 89289 about "eval-corr using a record format from a file". Unfortunately it was declined recently. What I wanted to do was this (from the RFE): Description and use case Many times I need to move the contents of the fields in a record into a data structure or vice versa. because that


        Comment


        • #5
          You might consider to dump the old code and create a new program with the way we are coding today.

          I remember RPG/II code 30 years ago.
          All the indicators, matching record, primary / secondary files etc

          Comment

          Working...
          X