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);
Title | Under | Posted on |
---|---|---|
Component interface Error: no rows exist for the specified keys | PeopleSoft Technical | 03/15/2019 - 3:54am |
ADD 24 months starting from current month.(peoplesoft) | PeopleSoft Functional | 07/29/2018 - 8:44pm |
TRC values dropdown | PeopleSoft Technical | 04/04/2018 - 12:54am |
how to find missing sequence in GRID and print the mising sequence number while saving through peoplecode | PeopleSoft Technical | 09/11/2017 - 4:49am |
Comments
Hi
Nice
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.
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
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.
do you place the code on the record or on the page?
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
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;
i m new to peoplesoft
can u tell me how to autoincrement
example
en_001
en_002
en_003 etc
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