× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Yep, *ALL is used for EXFMT. Not implemented for tables. As far as I could figure out, there is no way to make one DS do both functions.


I did get it to work using two separate structures. Working code is like this...

     D rec1            DS                  likerec(makrec:*input)
     D rec1out         DS                  likerec(makrec:*output)
     D
      /FREE
       chain (inKey) maktest2 rec1;
       if %found(maktest2);
         rec1.thistime += 1;
         update makrec rec1;
       else;
         rec1out.mkuser = inKey;
         rec1out.thistime = 1;
         write makrec rec1out;
       EndIf;
      /END-FREE  



________________________________
From: Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>
To: RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>
Sent: Thursday, May 3, 2012 3:02 PM
Subject: Re: Input, update and output file in procedure

I believe you have to code likerec(whatever:*input) and
likerec(whatever:*output).  I don't think you can use *ALL unless you're
coding an EXFMT opcode.  (I could be wrong, though.)

Worth a try?

On 5/3/2012 2:20 PM, Mike Krebs wrote:
I am trying out a new technique for me that involves reading, writing and updating a file in procedure using a file described in the procedure (so it doesn't mess up my main program file). It can be illustrated in the program below but it is the standard if found update otherwise write. I can't get it to compile with various RNF7701 and RNF7595 errors. Am I missing something? Do I have to define the data structure twice - once for input and once for output?

CREATE TABLE MIKETEST/MAKTEST2 (MKUSER CHAR (10 ) NOT NULL WITH
DEFAULT, THISTIME INT NOT NULL WITH DEFAULT, PRIMARY KEY (MKUSER))



       D*--------------------------------------------------
       D* Procedure name: WriteUpdateTable
       D* Purpose:        Write and update table
       D* Returns:
       D* Parameter:      inKey =>  Key to files
       D*--------------------------------------------------
       D WriteUpdateTable...
       D                 PR
       D  inKey                        10A   CONST

        /free
          WriteUpdateTable('TEST');
          *inlr = *on;
        /end-free

       P*--------------------------------------------------
       P* Procedure name: WriteUpdateTable
       P* Purpose:        Write and update table
       P* Returns:
       P* Parameter:      inKey =>  Key to files
       P*--------------------------------------------------
       P WriteUpdateTable...
       P                 B
       Fmaktest2  uf A E           k DISK    rename(maktest2:makrec)
       F
       F
       D WriteUpdateTable...
       D                 PI
       D  inKey                        10A   CONST

       D rec1            DS                  likerec(makrec:*all)
       D
        /FREE
         chain (inKey) maktest2 rec1;
         if %found(maktest2);
           rec1.thistime += 1;
           update makrec rec1;
         else;
           rec1.mkuser = inKey;
           rec1.thistime = 1;
           write makrec rec1;
         EndIf;
        /END-FREE
       P WriteUpdateTable...
       P                 E


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.