READE & SETLL

620 pts.
Tags:
AS/400
READE
SETLL
File: exam

..................
No . name
..................
2 chow
2 siva
3 mical
4 swami
4 radha
2 lord
..................
I need only equal records: 2-chow,2-siva,2-lord but I got the wrong output:2-chow, 2-siva,2-lord, 2-lord. it's reading the last rec 2 times. Please correct the below code. And please help me how to read the all duplicate records without SQL. Code:
fexam uf e k disk
c no setll exam
c dou %eof(exam)
c reade examr
C if %found()
c no dsply
c name dsply
c ENDIF
c enddo
c seton
1

Answer Wiki

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

Table missing the above

File: exam
………………
No     .  name
………………
2         chow       
2         siva     
3         mical
4         swami  
4         radha  
2         lord
………………

READE statement reads data against some key value. Secondly there should be another same READ statement just before ENDDO statement. You code should look like.
READE no examr
DOW %EOF(emamr)
 if no = column name;
   dsply no;
   dsply name;
 endif;
READE no examr;
ENDDO;

Discuss This Question: 8  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.
  • chowas400
    plz  see the below code format and help me guys
    Code:

    fexam      uf   e           k disk                                 
    c     no            setll     exam                                 
    c                   dou       %eof(exam)                           
    c                   reade     examr                                
    C                   if        %found()                             
    c     no            dsply                                          
    c     name          dsply                                          
    c                   ENDIF                                          
    c                   enddo                                          
    c                   seton
    620 pointsBadges:
    report
  • chowas400
    yeah, go it. thank you.

    plz help me how to read the all duplicate records without sql.
    620 pointsBadges:
    report
  • hunshabbir7
    If you don't want to use SQL then according to my knowledge you have to READ through all PF with multiple IF ANDIF ANDIF conditions. 
    2,900 pointsBadges:
    report
  • philpl1jb

    plz help me how to read the all duplicate records without sql.

    Not sure what you're expecting .. output that looks like this.  Just the rows where the key appears more then once?


    2         chow       
    2         siva     

    4         swami  
    4         radha  

    54,090 pointsBadges:
    report
  • Splat
    First off, provide a search argument in Factor 1 for the READE operation

    Then replace the
    C                   if        %found()                             
    c     no            dsply                                          
    c     name          dsply                                          
    c                   ENDIF                
    
     
    with

    C                   if        not %found()                             
    c                   leave                                         
    c                   endif
    
    c     no            dsply                                          
    c     name          dsply      
    Dou checks at the bottom of the group (it will execute the code in the group at least once), hence the employment of the Leave operation above when no further records meet the argument.
    12,895 pointsBadges:
    report
  • Splat
    Argh.  (Proofread, proofread, proofread).

    Ignore the second code segment above.  This is what I intended to included:
    C                   if        %eof()                             
    c                   leave                                         
    c                   endif
    
    c     no            dsply                                          
    c     name          dsply    
    %found is for CHAIN, DELETE, SETGT, SETLL, not READ, READE, READP, READPE.
    12,895 pointsBadges:
    report
  • Splat
    Correction:

    The code should read
    C                   if        %eof() 
    c                   leave                                         
    c                   endif
    not

    C                   if        not %found()                             
    c                   leave                                         
    c                   endif
    %found isn't a valid test for READ operations.
    12,895 pointsBadges:
    report
  • lance2221357
    fexam      uf   e           k disk                                 
    c     '2'           setll     exam                                 
    c                   dou       %eof(exam)                           
    c     '2'            reade     examr                                
    C                   if            not %eof(exam)                             
    c     no            dsply                                          
    c     name       dsply                
    c                   ENDIF                                          
    c                   enddo                                          
    270 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: