Generate incrementing ID for custom table method?

Thank you very much Linda, that functions perfectly.

Appears I was on the right track in the first place, but the error I was getting kept me changing my code over and over. The error "Cannot find the row in the database" lingered (even with your code) until I shut down and restarted the client app and then all functioned.

Wonder if that's a known problem with BPM's or something.

Thanks again.

--- In vantage@yahoogroups.com, "Linda Lowney" <llowney@...> wrote:
>
> I use the UD40 table to store a few keys, but some people use the
> Company table to store them. For UD02 I store the "next key" in the
> UD40.Number01 field, but you may want to store yours in the
> Company.Number01 field. Here is my code.
>
>
>
> /* Calculate UD02 Key1*/
>
> define variable vNextUD02Num as Integer.
>
> define variable vNextUD02Key as character.
>
> for each ttUD02 no-lock.
>
> /*Get the next UD02.Key1 number that is stored in
> UD40.Number01*/
>
> find UD40 where UD40.Company = cur-comp and UD40.Key1 = "1"
> no-lock.
>
> if UD40.Number01 = ? then do:
>
> vNextUD02Num = 1.
>
> end.
>
> if UD40.Number01 <> ? then do:
>
> vNextUD02Num = UD40.Number01.
>
> end.
>
> /*Store key number in the UD02 table */
>
> vNextUD02Key = string(VNextUD02Num).
>
> ttUD02.Key1 = vNextUD02Key.
>
> /*Update the next key in the UD40 table */
>
> vNextUD02Num = UD40.Number01 + 1.
>
> Run lib\UpdateTableBuffer.p(input BUFFER
> UD40:Handle,'Number01',vNextUD02Num).
>
> end.
>
>
>
>
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of pbparker
> Sent: Monday, November 02, 2009 3:53 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Re: Generate incrementing ID for custom table method?
>
>
>
>
>
> Anyone able to throw me a bone on this one.
>
> I started trying pre/post 4GL statements on both GetNewUD01 and
> GetANewUD01 and can't get the process of assigning a new row value via
> the code.
>
> I even tried to simplify it just to see if I could get the ttUD01.Key1
> value just set via 4GL with:
> assign ttUD01.Key1 = '17'.
>
> However, in all cases that statement results in:
> Cannot find the row in the database.
>
> My more elaborate attempts failed to do anything.
> DEFINE VARIABLE NextCounter as DECIMAL.
> FOR EACH UD02 no-lock.
> IF AVAILABLE UD02 THEN DO:
> ASSIGN NextCounter = UD02.Number01.
> ttUD01.Key1 = STRING(NextCounter).
> END.
> ELSE DO:
> ttUD01.Key1 = "NADA".
> END.
> END.
>
> --- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ,
> "Linda Lowney" <llowney@> wrote:
> >
> > Try UD01.GetANewUD01. I did not have any luck with the Get New without
> > the A in the middle.
> >
> >
> >
> > From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> [mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
> Behalf
> > Of pbparker
> > Sent: Friday, October 30, 2009 5:00 PM
> > To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> > Subject: [Vantage] Generate incrementing ID for custom table method?
> >
> >
> >
> >
> >
> > Can anyone share with me how they're generating a unique incrementing
> ID
> > for the key on custom forms/tables?
> >
> > I'm using UD01 and have a form working just as I'd like, however I'd
> > like to generate an incrementing number.
> >
> > I started trying to place a number in UD02.Number01 and tried to
> > reference and increment it from a UD01.GetNewUD01 BPM method but
> failed.
> >
> > So, wondering if it needs to be in the form itself. Couldn't find a
> > AddRow event in the customization wizards so far.
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
Can anyone share with me how they're generating a unique incrementing ID for the key on custom forms/tables?

I'm using UD01 and have a form working just as I'd like, however I'd like to generate an incrementing number.

I started trying to place a number in UD02.Number01 and tried to reference and increment it from a UD01.GetNewUD01 BPM method but failed.

So, wondering if it needs to be in the form itself. Couldn't find a AddRow event in the customization wizards so far.
Try UD01.GetANewUD01. I did not have any luck with the Get New without
the A in the middle.



From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of pbparker
Sent: Friday, October 30, 2009 5:00 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Generate incrementing ID for custom table method?





Can anyone share with me how they're generating a unique incrementing ID
for the key on custom forms/tables?

I'm using UD01 and have a form working just as I'd like, however I'd
like to generate an incrementing number.

I started trying to place a number in UD02.Number01 and tried to
reference and increment it from a UD01.GetNewUD01 BPM method but failed.

So, wondering if it needs to be in the form itself. Couldn't find a
AddRow event in the customization wizards so far.





[Non-text portions of this message have been removed]
Anyone able to throw me a bone on this one.

I started trying pre/post 4GL statements on both GetNewUD01 and GetANewUD01 and can't get the process of assigning a new row value via the code.

I even tried to simplify it just to see if I could get the ttUD01.Key1 value just set via 4GL with:
assign ttUD01.Key1 = '17'.

However, in all cases that statement results in:
Cannot find the row in the database.

My more elaborate attempts failed to do anything.
DEFINE VARIABLE NextCounter as DECIMAL.
FOR EACH UD02 no-lock.
IF AVAILABLE UD02 THEN DO:
ASSIGN NextCounter = UD02.Number01.
ttUD01.Key1 = STRING(NextCounter).
END.
ELSE DO:
ttUD01.Key1 = "NADA".
END.
END.



--- In vantage@yahoogroups.com, "Linda Lowney" <llowney@...> wrote:
>
> Try UD01.GetANewUD01. I did not have any luck with the Get New without
> the A in the middle.
>
>
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of pbparker
> Sent: Friday, October 30, 2009 5:00 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Generate incrementing ID for custom table method?
>
>
>
>
>
> Can anyone share with me how they're generating a unique incrementing ID
> for the key on custom forms/tables?
>
> I'm using UD01 and have a form working just as I'd like, however I'd
> like to generate an incrementing number.
>
> I started trying to place a number in UD02.Number01 and tried to
> reference and increment it from a UD01.GetNewUD01 BPM method but failed.
>
> So, wondering if it needs to be in the form itself. Couldn't find a
> AddRow event in the customization wizards so far.
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
I use the UD40 table to store a few keys, but some people use the
Company table to store them. For UD02 I store the "next key" in the
UD40.Number01 field, but you may want to store yours in the
Company.Number01 field. Here is my code.



/* Calculate UD02 Key1*/

define variable vNextUD02Num as Integer.

define variable vNextUD02Key as character.

for each ttUD02 no-lock.

/*Get the next UD02.Key1 number that is stored in
UD40.Number01*/

find UD40 where UD40.Company = cur-comp and UD40.Key1 = "1"
no-lock.

if UD40.Number01 = ? then do:

vNextUD02Num = 1.

end.

if UD40.Number01 <> ? then do:

vNextUD02Num = UD40.Number01.

end.

/*Store key number in the UD02 table */

vNextUD02Key = string(VNextUD02Num).

ttUD02.Key1 = vNextUD02Key.

/*Update the next key in the UD40 table */

vNextUD02Num = UD40.Number01 + 1.

Run lib\UpdateTableBuffer.p(input BUFFER
UD40:Handle,'Number01',vNextUD02Num).

end.







From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of pbparker
Sent: Monday, November 02, 2009 3:53 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Re: Generate incrementing ID for custom table method?





Anyone able to throw me a bone on this one.

I started trying pre/post 4GL statements on both GetNewUD01 and
GetANewUD01 and can't get the process of assigning a new row value via
the code.

I even tried to simplify it just to see if I could get the ttUD01.Key1
value just set via 4GL with:
assign ttUD01.Key1 = '17'.

However, in all cases that statement results in:
Cannot find the row in the database.

My more elaborate attempts failed to do anything.
DEFINE VARIABLE NextCounter as DECIMAL.
FOR EACH UD02 no-lock.
IF AVAILABLE UD02 THEN DO:
ASSIGN NextCounter = UD02.Number01.
ttUD01.Key1 = STRING(NextCounter).
END.
ELSE DO:
ttUD01.Key1 = "NADA".
END.
END.

--- In vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ,
"Linda Lowney" <llowney@...> wrote:
>
> Try UD01.GetANewUD01. I did not have any luck with the Get New without
> the A in the middle.
>
>
>
> From: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
[mailto:vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com> ] On
Behalf
> Of pbparker
> Sent: Friday, October 30, 2009 5:00 PM
> To: vantage@yahoogroups.com <mailto:vantage%40yahoogroups.com>
> Subject: [Vantage] Generate incrementing ID for custom table method?
>
>
>
>
>
> Can anyone share with me how they're generating a unique incrementing
ID
> for the key on custom forms/tables?
>
> I'm using UD01 and have a form working just as I'd like, however I'd
> like to generate an incrementing number.
>
> I started trying to place a number in UD02.Number01 and tried to
> reference and increment it from a UD01.GetNewUD01 BPM method but
failed.
>
> So, wondering if it needs to be in the form itself. Couldn't find a
> AddRow event in the customization wizards so far.
>
>
>
>
>
> [Non-text portions of this message have been removed]
>





[Non-text portions of this message have been removed]
I have used 2 methods to make this work. One is using one of the fields on the company increment by one and then save back to the company. The other is ODBC to get the last record in the table I am using.
--- In vantage@yahoogroups.com, "pbparker" <scrumbus@...> wrote:
>
> Anyone able to throw me a bone on this one.
>
> I started trying pre/post 4GL statements on both GetNewUD01 and GetANewUD01 and can't get the process of assigning a new row value via the code.
>
> I even tried to simplify it just to see if I could get the ttUD01.Key1 value just set via 4GL with:
> assign ttUD01.Key1 = '17'.
>
> However, in all cases that statement results in:
> Cannot find the row in the database.
>
> My more elaborate attempts failed to do anything.
> DEFINE VARIABLE NextCounter as DECIMAL.
> FOR EACH UD02 no-lock.
> IF AVAILABLE UD02 THEN DO:
> ASSIGN NextCounter = UD02.Number01.
> ttUD01.Key1 = STRING(NextCounter).
> END.
> ELSE DO:
> ttUD01.Key1 = "NADA".
> END.
> END.
>
>
>
> --- In vantage@yahoogroups.com, "Linda Lowney" <llowney@> wrote:
> >
> > Try UD01.GetANewUD01. I did not have any luck with the Get New without
> > the A in the middle.
> >
> >
> >
> > From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> > Of pbparker
> > Sent: Friday, October 30, 2009 5:00 PM
> > To: vantage@yahoogroups.com
> > Subject: [Vantage] Generate incrementing ID for custom table method?
> >
> >
> >
> >
> >
> > Can anyone share with me how they're generating a unique incrementing ID
> > for the key on custom forms/tables?
> >
> > I'm using UD01 and have a form working just as I'd like, however I'd
> > like to generate an incrementing number.
> >
> > I started trying to place a number in UD02.Number01 and tried to
> > reference and increment it from a UD01.GetNewUD01 BPM method but failed.
> >
> > So, wondering if it needs to be in the form itself. Couldn't find a
> > AddRow event in the customization wizards so far.
> >
> >
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>