Write duplicate record to a PF

10 pts.
Tags:
AS/400
RPG
A screen has one input field called number. whenever the number is inputted, the value gets stored in a file. The file has 2 fields, Value and Sequence. So, if any user has inputted '10', the files will store 10 as value and 1 as sequence. If any user inputs a value, which is already present in the file, a message in the screen appears that 'Duplicate value'. There are 10 users who have opened the same screen in 10 different AS/400 sessions. All 10 of them are about to input '50' from the screen at the same time. Since '50' is not in the file, so error message should not appear. But they do not know that others users are also giving '50'. How can we code this scenario so that file will store 50 from all 10 users with sequence number from 1 to 10 without giving error message 'Duplicate value'?
1

Answer Wiki

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

Check both the value and the sequence not just the value.

Discuss This Question: 5  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
    If 50 is valid for more than 1 user then why even check for duplicates in the first place? How is the sequence incremented?
    135,305 pointsBadges:
    report
  • Splat
    Sequence = 1;
    Dou not %equal;
    SetLl (Number: Sequence) [file format];
    If %equal:
    Sequence += 1;
    Iter;
    EndIf;
    EndDo;
    Write(e) [file format];

    12,915 pointsBadges:
    report
  • ToddN2000
    If you are trying to stop the same user form entering the same value, I think you need to add a user ID field to your check for duplicates. The sequence number is irrelevant.
    135,305 pointsBadges:
    report
  • CharlieBrowne
    This seems like a homework question.

    If not, please give us more information behind the business requirement for this question. There can be a variety of answers based on the actual requirements.

    62,385 pointsBadges:
    report
  • GregManzo
    Alternative to Splat's code:

    SETGT (Number) [format];
    READPE(N) (Number) [format];
    IF %found;
    Sequence += 1;
    ELSE;
    Sequence = 1;
    ENDIF;
    WRITE(E) [format];
    2,970 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: