ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Update program described file

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

  • Update program described file

    Hi,
    I'm trying to update a program described file.

    I setup the F specs to allow processing by key
    Code:
    FFMYFILE1  UF  F      32  8AI     1 DISK                      A    UC
    I then coded a DS as the key with a field defined as 8 bytes to match the "F" spec
    Code:
    IKEYDS       DS                                      
    I                                        1   8 MYFLD1
    I also have an update DS
    Code:
    IUPDDS       DS                                    
    I                                        5  12 FLD1
    I                                       13  30 FLD2
    I                                       32  32 FLD3
    When the program runs I open the file and chain using the KEYDS
    Code:
    C                     OPEN FMYFILE1              
    C                     MOVELMYFLD1    $$FLD1 25    
    C           $$FLD1    CHAINFMYFILE2             99
    C           KEYDS     CHAINFMYFILE1  UPDDS      99
    C           @SFL1R    CHAINSFL1                 99
    C                     MOVELMYFLD2    FLD2         
    C                     MOVELMYFLD1    FLD1        
    C                     UPDATFMYFILE1  UPDDS        
    C                     CLOSEFMYFILE1
    I update the values in the UPDDS with a chain to another file to get a value and then the SFL to get what's on screen, then try to update the record but I get CPF5149 at the KEYDS chain which, basically informs me that the operation for the file is not valid!

    What am I doing wrong?

    Ah, an indexed file requires DDS, don't have any. It's just a flat file created in a cl before this pgm is called. Need to find another way.
    Last edited by redvan; August 11, 2009, 07:29 AM. Reason: Epiphany
    Everyday's a school day, what grade are you in?

  • #2
    Re: Update program described file

    I think the problem is with this statement

    Code:
    C           KEYDS     CHAINFMYFILE1  UPDDS      99
    since,
    Factor 1, the search argument, must contain the key or relative record number used to retrieve the record. If access is by key, factor 1 can be a field name, a named constant, a figurative constant, or a literal. In addition, a KLIST (Define a Composite Key) name can be specified in factor 1 for an externally described file. If access is by relative record number, factor 1 must contain an integer literal or a numeric field with zero decimal positions.

    And I am also very much clear about this line also:
    Code:
    C                     MOVELMYFLD1    $$FLD1 25
    I think u should reove KEYDS and take a field instead.

    Pramendra Pandeya
    Young people knows how to run fast but old people knows the way..

    Comment


    • #3
      Re: Update program described file

      If the key is multiple fields, define it with a KLIST. Otherwise use a field.

      BTW: That version of RPG is "obsolete". Try RPG-IV - you'll like it.

      Comment


      • #4
        Re: Update program described file

        Yes, I know a little ile and whenever I do something for myself, I use it.

        As for this shop; it's a JDE shop and everything is RPG III and anything you do must be the same.
        Everyday's a school day, what grade are you in?

        Comment


        • #5
          Re: Update program described file

          Well, rules are rules. Are they not allowed to use Windows either (RPG-IV has been around longer than Win95). ?

          Anyway, I uderstand, I am in a Mapics shop where most everything is RPG-III. So I can't really use ILE very often, but I can use RPG-IV for all new programs and major updates. RPG-IV does play nice with RPG-III until you get involved with ILE.

          GoodLuck

          Comment


          • #6
            Re: Update program described file

            Ah MAPICS, I had an encounter with that back at Pall years ago.
            Everyday's a school day, what grade are you in?

            Comment

            Working...
            X