How to get number of modified rows in subfile(SFL)?

Tags:
AS 400
IBM
RPG
RPG Free
SQL
If READC function reads only modified records of a Subfile(SFL), I would like to know if there is any system function or it is any way to know the amount of modified records on a subfile(SFL) using an RPG file.

Ejemplo
READC SUBFILE1;
         DOW %EOF = *OFF;
           IF VAR_FIELD_1 = 'A';
             SUM = SUM + 1;
           ENDIF;
           READC(E) SUBFILE1;
         ENDDO;

I have an issue with this. If I use previous cycle to get the amount of modified records, I am not be able to read the subfile(SFL) again afterwards.

------------------------------------
@GregManzo: I require it in an informative way, it will be inside a cycle and there I will an update screen for each modified record. For instance, 1/3, 2/3 and 3/3 -> End

@Splat: Hello, I do not find the way to use DSPATR(MDT). Could you help me a little bit more with this?

@ToddN2000: I want to display it as an information for the user.


Software/Hardware used:
as400
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 9  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TheRealRaven
    It can depend on whether it's a load-all or page-at-a-time subfile. What works for one can't be relied on for the other. What are you using?
    35,190 pointsBadges:
    report
  • Splat
    READC only reads changed records - once read they're no longer considered changed.  You can use the DSPATR(MDT) along with an UPDATE operation to mark the record as changed following the READC.


    12,885 pointsBadges:
    report
  • GregManzo
    Do you really need the count of changed records before you start processing any of them? Why not just process each changed record as your READC finds them, then do whatever you need with the count at the end?
    Failing that, read up on SFLNXTCHG & DSPATR(MDT) to see if either will suit you.
    2,960 pointsBadges:
    report
  • ToddN2000
    Yes, seems like a strange request for needing the number before processing. The simplest way way would be to put a counter in your READC logic and get the number of changes after processing.  If you can explain the reason for needing this figure before processing, it may help us provide a better solution.

    132,840 pointsBadges:
    report
  • GregManzo
    OK, try this then: Within your READC loop count the number of changes as you are, but also load an array with the key info from the changed record. Then after reaching EoF process your array showing the screen for each array entry. Your 1/3, 2/3 etc becomes <element #> / <count>.
    2,960 pointsBadges:
    report
  • Splat
    DSPATR(MDT) works like any other conditioned display attribute.  Use an indicator to condition the keyword, set the indicator on when you update the subfile record (set it off immediately after & ensure it's off when you write records to the subfile).
    12,885 pointsBadges:
    report
  • Splat
    BTW, if you want to display the count of changed records, why not send the message after processing those same changed records?  The user's already made the changes so you're just processing them & letting the user know x number have been processed.
    12,885 pointsBadges:
    report
  • azohawk
    I wonder if they are wanting the end user to do something like: mark items for processing. When the user presses enter present the user with "you have marked x records for processing. Proceed?"  If user confirms, then go back and process the selected items. 
    4,055 pointsBadges:
    report
  • TheRealRaven
    Note that READC and the MDT aren't as helpful when it's a page-at-a-time subfile. You get a count for the first page, but then you need to know the first page's modified rows after paging to a new page. The MDTs are then gone.
    35,190 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: