Fetch unique and Duplicate Record in AS/400

320 pts.
Tags:
AS/400
AS/400 Records
I have the file with data as below:
Num  Name

1        aaa

2        bbb

2        bbb

1        aaa

4        ccc

5        ddd.

7        eee
I want to retrieve the unique record and write in one file and retrieve duplicate record and written in another file.
But the file which I'm writing must not write Duplicate Records.
Please help me how to go further.
The answer should be like this:
File1(Unique)      File2(Duplicate)
num name           num name

4      ccc              1       aaa

5      ddd             2       bbb

7      eee

Answer Wiki

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

You could try using embedded SQL. Read from your input file. Then using SQL, query input file for that data returning a count.  If value returned is 1 then write unique. If more than on the write to duplicate. Then read next input record and repeat till %EOF.

Discuss This Question: 4  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.
  • ToddN2000
    What language RPG, SQL, COBOL? Show us what you have written so far.
    107,875 pointsBadges:
    report
  • srivijay1
       Setll *Loval MainLf1;                                    
       Read MainLf1;                                            
       Dow Not %Eof(Mainlf1);                                   
          If Flag = *off;         //first time it will be off   
             Variable = name;                                   
          Endif;                                                
          If variable = Name and variable1 <> Name;             
             Variable1 = Name;                                  
             Chain (name) UnqRec;                               
             Write UNQFMT;                                      
             Flag = *on;                                        
          EndIf;                                                
          Read MainLf1;                                         
       Enddo;                                                   
       *Inlr = *on;                                             

    Hi, in this taken single records of the duplicate, but i dono how to keep the cursor to next record
    320 pointsBadges:
    report
  • srivijay1
    Pls share, the scenario which i mentioned above is the valid scenario.
    320 pointsBadges:
    report
  • philpl1jb
    Is this a recruiter or inverview question?
    54,090 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: