Read numeric duplicate key values in RPG program

35 pts.
Tags:
AS/400
RPG
How do I read numeric duplicate key values in an RPG program?
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: 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.
  • philpl1jb
    That would depend on the design of your program. Please show us a snipped. Basically it would be with a READE (or a READ followed with some logic to determine if its the same/different).
    54,090 pointsBadges:
    report
  • 227364
    Hi,

    This is my data base file field name Which i have defined.
    and which i want to reade record from data base file.
    *************** Beginning of data ******************
                    R REC1                              
                      EMPID          5P 0               
                      EMPNAME       10A                 
                      EMPSAL         5P 0               
                    K EMPID                             
                                                        
    ****************** End of data *********************

    This is the record in database file but I want to reade EMPID = 3 only record disply.

    EMPID   EMPNAME     EMPSAL       
        3   RAJ         34,545       
        1   MOHAN       45,355       
        2   SOHAN       45,455       
        3   KALENDRA    44,545       
        4   VENU        44,444       
    *******  End of report  ******** 
    35 pointsBadges:
    report
  • 227364
    I have write code like this but didn't run pgm. pls let me know why don't disply result.

    FPP1       IF   E           K DISK                                       
    C                         EVAL      EMPID = 3                                  
    C     EMPID         READE     REC1                                       
    C                         DOW       NOT %EOF()                                 
    C     EMPID         DSPLY                                                
    C     EMPNAME   DSPLY                                                
    C     EMPSAL      DSPLY                                                
    C     EMPID         READE     REC1                                       
    C                         ENDDO                                                
    C                         SETON                                            LR  
    ****************** End of data ******************************************
    35 pointsBadges:
    report
  • azohawk

    I am going to presume that PP1 is the proper file name.  And Rec1 is correct.

    Most code that I have encountered would read by file name. I always specify the what I am checking when I use %EOF(). 

    C     EMPID        READE    PP1

    C                         DOW       NOT %EOF(PP1)

    But really, I don't think that should make a difference in your results.

    You did not indicate which OS release you are on. I am on V7.1 and have a file I get unpredictable results with using Reade with an alpha key.

    One thing that strikes me as very unusual in your sample data is that you have two employees with the same employee ID. Perhaps you did that for the purpose of illustration, but not something I would expect to see. In various processing that might be done, how do you know which employee is which. 

    Does this code compile successfully? if not what are the errors. Does it compile, but not run? Run but not yield expected results?...

    4,055 pointsBadges:
    report
  • TheRealRaven
    Assuming it compiles cleanly, I don't see anything wrong. Two possible issues come to mind.

    First, how was it called? Interactive or batch?

    Second, if it was interactive, what was on the screen when the program was called? Depending on what DSPF is active when the CALL is issued, the job might or might not pause when DSPLY runs. That is, the proper values might have been "displayed", but they're only clearly visible in the joblog. DSPLY wthout a reply isn't always a good idea.
    35,650 pointsBadges:
    report
  • NeilD

    There appears to be one important line missing prior to your first READE:

    C     EMPID         SETLL     REC1                                       

    570 pointsBadges:
    report
  • TheRealRaven
    That's the ticket. A line that isn't there can be hardest to see. Good catch.
    35,650 pointsBadges:
    report
  • 227364
    yes, it's working fine. I have checked.

    thanks a lot  for your guidelines..


    35 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: