Subfile whats the difference between in READC and SFLNXTCHG

35 pts.
Tags:
READC
SFLNXTCHG
Subfile
Hi Friends, I am new learner of as/400. Can somebody tell me that whats diff. between in READC and SFLNXTCHG ..can somebody gv me a practical example of sflnxtchg means why and when we use this keyword.... Thanks in advance....

Answer Wiki

Thanks. We'll let you know when a new response is added.

ReadC Reds the Changed Record Once
means when it reads thefirst Subfile Record it sets off the Modified tag
so next time ReadC will ignore that record even if it gets changed

SFLNXTCHG keyword is used to set the modified Tag on after READC so if it will not ignore the Same Records if gets changed next time

Discuss This Question: 10  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.
  • Gilly400
    Hi, READC will read the record ONLY when it has changed (for example a record is selected on the subfile with an option - think of PDM with an option 2 next to a source member). SFLNXTCHG sets all records in the subfile to be marked as changed, so that READC will read all records in the subfile. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • TomLiotta
    SFLNXTCHG sets all records in the subfile to be marked as changed... SFLNXTCHG only sets the tag for the subfile records that are written when SFLNXTCHG is on. It only affects "all" subfile records if you have it on for every subfile record you write. READC will read any subfile record that was updated by the user (regardless of whether or not READC read the same subfile record in a previous I/O cycle through the subfile.) READC will also read any subfile record that wasn't changed by the user if that record was written while SFLNXTCHG was enabled. The difference between the two is that READC is a RPG program I/O instruction and SFLNXTCHG is an attribute of a row written to a subfile regardless of whether it was written by RPG or a different language. READC is a RPG instruction; SFLNXTCHG is a DDS keyword. They're not words from the same language. Tom
    125,585 pointsBadges:
    report
  • pdraebel
    A practical use of SLFNXTCHG and READC would be if you have a subfile where the user can enter data. The program than checks this data for errors and returns the wrongly entered data on the subfile in reverse image. It the users enters without changing the erroneous data these subfile records would not be read with a READC. So whenever you encounter a subfile record that does not meet validity checking and you return the subfile display with the indications of which fields are wrong make sure the SFLNXTCHG is in effect when you update the subfile record. This way you make sure the subfile record is read and validated even if the user did not change a thing on the record. So again he will be presented with the same error screen.
    7,545 pointsBadges:
    report
  • Kalyansun
    i would like to know about
    10 pointsBadges:
    report
  • anandx
    The inquiry has been lucidly addressed already, a plethora of examples sprayed all over websites and this reply is coming up a light year late, and yet one more won't hurt, I guess.
    A pgm can read all records in a subfile, randomly (by CHAIN) or sequentially (by READ), any number of times and each time the result is the same as the previous one. However, when pgm wants to selectively read ONLY most recently changed records, then READ and CHAIN will fail and we need the service of READC then. READC picks only changed recs as though there is a 'where' clause. READC has a kind of a constraint, it picks the changed recs only once, if a changed rec is unchanged after first display of sfl, it doesn't treat that rec as changed (thru a fancy mechamnism called *MDT). Now, let's say we allow READC to pick changed recs on the first display, bypass *MDT and let the pgm allow changed status to persist even after multiple displays until some conditions exist thereby make READC to believe the changed status continues even though user has not touched those recs after the first display. SFLNXTCHG does that trick. Here are two scenarios with and without SFNXTCHG. Some extra coding removed for brevity. Const 'sflnxtchg' is declared elsewhere as part of DS of INDARA as *IN39. 

    (1) without
    A          R SF1                       SFL
    A*                                                
    A            name1         10A  B 10 10           
    A            name2         10A  B 10 25
               
    readc(e)  sf1 ;                             
    dow not %eof ;                              
        if  %eof ;                              
            leave ;                             
        endIF ;                                                                
        readc(e)  sf1 ;                         
    endDO ;                                     
    (2) with
    A          R SF1                       SFL        
    A  39                                  SFLNXTCHG 

    readc(e)  sf1 ;                             
    dow not %eof ;                              
        if  %eof ;                              
            leave ;                             
        endIF ;                                 
        if  %subst(name1: 1: 1) = 'Z' ;      
            clear sflnxtchg ;                  
        else ;                                  
            sflnxtchg = *on ;                   
        endIF ;                                 
        write(e)  sf1 ;                         
        readc(e)  sf1 ;                         
    endDO ;                                     

    435 pointsBadges:
    report
  • azohawk

    The two work in conjunction with each other. SFLNXTCHG is value in the DSPF SFL record. READC is an operation code in your RPG program.

    2,905 pointsBadges:
    report
  • anandx
    azohawk: That's a nice matured professional way of distinguishing the two. Agreed without hesitation. Matter of fact it is changing my way of looking at other similar things as well, such as SFLFOLD/DROP...Thanks.

    Just a digression, for fun. Qn: can we get rid off and work without both READC and SFLNXTCHG? We don't need to, but can we? 

    Suppose, we take a copy of subfile and push that into a dynamic array data structure and keep it alive as and when new recs are added to the subfile. Actually let's keep two copies, one current and one an immediate predecessor. In the DS, add two additional fields, a boolean var and RRN of the sfl rec. 

    After user responds to every exfmt, compare every input capable fields of every rec of current with *prv, turn *on the boolean variable  when there is a change, keep it *on until you decide when to turn it *off, sort the array based on the  boolean var, re-display only those (chain with hidden rrn var). 

    I know 'why to use a sickle when you have a lawn mover'? Well, people do crazy things, just for the heck of it, don't they

    435 pointsBadges:
    report
  • Splat
    anandx, you can access subfile records by relative record number with a Chain operation.
    11,455 pointsBadges:
    report
  • GregManzo
    OR... you could just add Hidden fields into the subfile for the previous copies of each field (or a DS of all of them) - then you have your two copies already.
    1,830 pointsBadges:
    report
  • Splat
    If you're going to allow changes to the data being displayed, GregManzo's suggestion is spot on.
    11,455 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: