Auto Increment a Number in PeopleSoft

Your rating: None Average: 3.5 (4 votes)

Use the GetNextNumber function to increment the value in a record for the field you specify by one.

Syntax:
GetNextNumber ({record.field | record_name, field_name}, max_number)

Best place to add such code is in SavePostChange event.

Example:
My_Field = GetNextNumber(My_Record.My_Field, 99999999);

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
hari's picture
hari (not verified)
Hi Nice

Hi
Nice

Nitin's picture
Nitin (not verified)
Re: Auto Increment a Number in PeopleSoft

There ia another function GetNextNumberWithCommits.
This created a new connection .. fetch the number,.. updated with new and commits.

One of them is having an Issue on OS390.

Lepa's picture
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 06/23/2008
Posts: 590
Re: Auto Increment a Number in PeopleSoft

Nitin, your talking about GetNextNumberWithGapsCommit, right? I think you just forgot the word "Gaps". But yes I agree with you, GetNextNumberWithGapsCommit has more flexibility and provides better performance. Thanks for your tip!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Mayank's picture
Mayank (not verified)
Re: Auto Increment a Number in PeopleSoft

Nitin / Lepa i do agree with both of you..and want to update 1 more thing which is --
The GetNextNumberWithGaps function is very restrictive in its usage. The GetNextNumberWithGapsCommit function can be used in any event.

david wong's picture
david wong (not verified)
Re: Auto Increment a Number in PeopleSoft

do you place the code on the record or on the page?

Lepa's picture
User offline. Last seen 2 weeks 2 days ago. Offline
Joined: 06/23/2008
Posts: 590
Re: Auto Increment a Number in PeopleSoft

I would put that code on the component level if you code under savepostchange event.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Guest's picture
Guest
Re: Auto Increment a Number in PeopleSoft

Better way :-
If %Page = Page.LNT_OPENACNT_104 Then
If %Mode = "A" Then
SQLExec(" select max(LNT_ACCNO_104) from ps_lnt_cdetail_104", &var1);

If &var1 = "" Then
LNT_CDETAIL_104.LNT_ACCNO_104 = "S000001";
Else
&fvar = Code(Substring(&var1, 1, 1));
&lvar = Value(Substring(&var1, 2, 6));

If &lvar = 999999 Then
&newvar = Char(&fvar + 1) | "000001";
Else
&lvar = &lvar + 1;
&len = (6 - Len(&lvar));
For &i = 1 To &len
&pad = &pad | "0";
End-For;
&newvar = Char(&fvar) | &pad | (&lvar);
End-If;
LNT_CDETAIL_104.LNT_ACCNO_104.Value = &newvar;

End-If;
WinMessage("Account Created Successfully!!!Account no=" |
End-If;
End-If;

Guest's picture
Guest
Re: Auto Increment a Number in PeopleSoft

i m new to peoplesoft
can u tell me how to autoincrement
example
en_001
en_002
en_003 etc

Guest's picture
Guest
Re: Auto Increment a Number in PeopleSoft

You can try with below simple peoplecode at component level save pre change event.

Local Rowset &RS;
Local number &SEQNBR;

&SEQNBR = 0;
&RS = GetLevel0()(1).GetRowset(Scroll.ESA_ANOUNCE);
SQLExec("SELECT MAX(SEQNBR) FROM PS_ESA_ANOUNCE", &SEQNBR);

For &i = 1 To &RS.ActiveRowCount
If None(&RS(&i).ESA_ANOUNCE.SEQNBR.Value) Then
&RS(&i).ESA_ANOUNCE.SEQNBR.Value = &SEQNBR + 1;
&SEQNBR = &SEQNBR + 1;
End-If;
End-For;

Regards,
Jigneshkumar Chauhan

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
1 + 12 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.