Customization to Get Next Part number

Not good. You are assuming that the last part has a numeric. If not you will always be putting up a 1.
Next issue is formatting. Since the PartNum is not a number but an Alpha, you want to forward fill (most likely with zeros) the number to a desired length. Otherwise you will get part 1, 10, 100, 11, 12, 2, etc. as the part sort.
I concur with others that you store the next part number in the company file or build the part number based on a specific set of parameters which could be determined by a BPM form.

Charlie Smith
2W Technologies Inc., Sr. Business Consultant
Phone: (312) 533-4033 Office
               (860) 919-1708 Cell
     Fax: (847) 374-3620
2W Tech on Facebook www.2WTech.com


-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf Of Jose Gomez
Sent: Tuesday, October 16, 2012 2:22 PM
To: vantage@yahoogroups.com
Subject: Re: [Vantage] Customization to Get Next Part number

This is much easier / better done in a BPM (if you want all Parts to be incremented this way) On a Post Processing n GetNewPart

Excecute 4GL Code roughly not on an editor so the syntax may be slightly off.

FIND LAST Part NO-ERROR NO-LOCK.
IF AVAILABLE PART THEN DO:
ttPart.PartNum = NUMERIC(Part.PartNum)+1.
END.


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Tue, Oct 16, 2012 at 2:18 PM, Brian Roberts <broberts@...> wrote:

> **
>
>
> You'll want to do a screen customization on Part Maintenance, and
> either add a button that people manually click to fill in the next
> number, or possibly hook up to the after adapter method GetNewPart
> (guessing at the method name) so its automatic. Call your code below,
> then update the PartNum field in the dataset. My sample code (C# in
> 9.05, hooked up to a button) is below for an example.
>
> Brian.
>
> // assign new part
> number to brand new Part record
>
> if (nextpartnum != "") {
>
> EpiDataView edvPart = (EpiDataView)oTrans.EpiDataViews["Part"];
>
> edvPart.dataView[edvPart.Row].BeginEdit();
>
> edvPart.dataView[edvPart.Row]["PartNum"] = nextpartnum;
>
> edvPart.dataView[edvPart.Row].EndEdit();
>
> edvPart.Notify(new EpiNotifyArgs(oTrans, edvPart.Row,
> edvPart.Column));
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On
> Behalf Of melissa hietala
> Sent: Tuesday, October 16, 2012 12:53 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Customization to Get Next Part number
>
>
> I have sent code to one of the session presenters from Epicor to
> verify I am on the correct path to do a "get next part number" customization.
> Here's what I sent:
>
> private string GetNextPartNumber()
> {
> string nextPartNumber=String.Empty;
> try
> {
> // Declare and
> Initialize EpiDataView Variables
> // Declare and create an
> instance of the Adapter.
> CompanyAdapter
> adapterCompany = new CompanyAdapter(this.oTrans);
>
> adapterCompany.BOConnect();
>
> // Declare and
> Initialize Variables
> ILaunch iLnch = oTrans
> as ILaunch;
> string
> company = ((Epicor.Mfg.Core.Session)iLnch.Session).CompanyID;
>
>
> // Call Adapter method
> bool result =
> adapterCompany.GetByID(company);
> if (result)
> {
>
> nextPartNumber =
> adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToString();
>
> adapterCompany.CompanyData.Company.Rows[0].BeginEdit();
>
> int origNum =
> Int32.Parse(adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToS
> tr
> ing());
>
> adapterCompany.CompanyData.Company.Rows[0]["Number02"] = ++origNum;
> //Adds one to Number02 value origNum +1
>
> adapterCompany.CompanyData.Company.Rows[0].EndEdit();
>
> adapterCompany.Update();
> }
> // Cleanup Adapter
> Reference
>
> adapterCompany.Dispose();
> adapterCompany=null;
>
>
> }
> catch (System.Exception ex)
>
> {
> ExceptionBox.Show(ex);
> }
>
> return nextPartNumber;
> }
>
> End Try
> End Sub
> End Module
>
> His response was as following:You can continue with your idea below
> and create a customization that increases the part number through
> code. To write a customization that automatically increments the part
> number by one, create code that does the following:
>
> 1. Define a variable vNextPartNum
> 2. Find last Part.PartNum
> 3. Assign vNextPartNum=vNextPartNum + 1
>
> My issue is that I am new at this whole thing and have no idea how or
> where to define this variable and where to insert it in my code. Can
> any of you help me with this? Is there an example in one of the tool
> guides that could help?
>
> Thank you,
> Melissa Hietala
> UMC, Inc.
> melissah@... <mailto:melissah%40ultramc.com>
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]



------------------------------------

Useful links for the Yahoo!Groups Vantage Board are: ( Note: You must have already linked your email address to a yahoo id to enable access. )
(1) To access the Files Section of our Yahoo!Group for Report Builder and Crystal Reports and other 'goodies', please goto: http://groups.yahoo.com/group/vantage/files/.
(2) To search through old msg's goto: http://groups.yahoo.com/group/vantage/messages
(3) To view links to Vendors that provide Vantage services goto: http://groups.yahoo.com/group/vantage/linksYahoo! Groups Links
I have sent code to one of the session presenters from Epicor to verify I am on the correct path to do a "get next part number" customization. Here's what I sent:

private string GetNextPartNumber()
               {
                               string nextPartNumber=String.Empty;
                               try
                               {
                                               // Declare and Initialize EpiDataView Variables
                                               // Declare and create an instance of the Adapter.
                                               CompanyAdapter adapterCompany = new CompanyAdapter(this.oTrans);
                                               adapterCompany.BOConnect();
Â
                                               // Declare and Initialize Variables
                                               ILaunch iLnch = oTrans as ILaunch;
                                                               string company = ((Epicor.Mfg.Core.Session)iLnch.Session).CompanyID;
                                              Â
                                              Â
                                               // Call Adapter method
                                               bool result = adapterCompany.GetByID(company);
                                               if (result)
                                                               {
                                                                               nextPartNumber = adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToString();
                                                                                               adapterCompany.CompanyData.Company.Rows[0].BeginEdit();
                                                                                               int origNum = Int32.Parse(adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToString());
                                                                                                               adapterCompany.CompanyData.Company.Rows[0]["Number02"] = ++origNum; //Adds one to Number02 value origNum +1
                                                                                                               adapterCompany.CompanyData.Company.Rows[0].EndEdit();
                                                                                                               adapterCompany.Update();
                                                               }
                                               // Cleanup Adapter Reference
                                               adapterCompany.Dispose();
                                               adapterCompany=null;
                                              Â
Â
                               }
                               catch (System.Exception ex)
Â
{
                                               ExceptionBox.Show(ex);
                               }
Â
                               return nextPartNumber;
               }
               Â
                               End Try
               End Sub
End Module
Â
His response was as following:You can continue with your idea below and create a customization that increases the part number through code. To write a customization that automatically increments the part number by one, create code that does the following:
Â
1.      Define a variable vNextPartNum
2.      Find last Part.PartNum
3.      Assign vNextPartNum=vNextPartNum + 1
Â
My issue is that I am new at this whole thing and have no idea how or where to define this variable and where to insert it in my code. Can any of you help me with this? Is there an example in one of the tool guides that could help?
Â
Thank you,
Melissa Hietala
UMC, Inc.
melissah@...

[Non-text portions of this message have been removed]
You'll want to do a screen customization on Part Maintenance, and either
add a button that people manually click to fill in the next number, or
possibly hook up to the after adapter method GetNewPart (guessing at the
method name) so its automatic. Call your code below, then update the
PartNum field in the dataset. My sample code (C# in 9.05, hooked up to
a button) is below for an example.



Brian.



// assign new part
number to brand new Part record

if (nextpartnum != "") {


EpiDataView edvPart = (EpiDataView)oTrans.EpiDataViews["Part"];


edvPart.dataView[edvPart.Row].BeginEdit();


edvPart.dataView[edvPart.Row]["PartNum"] = nextpartnum;


edvPart.dataView[edvPart.Row].EndEdit();


edvPart.Notify(new EpiNotifyArgs(oTrans, edvPart.Row, edvPart.Column));





From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of melissa hietala
Sent: Tuesday, October 16, 2012 12:53 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Customization to Get Next Part number





I have sent code to one of the session presenters from Epicor to verify
I am on the correct path to do a "get next part number" customization.
Here's what I sent:

private string GetNextPartNumber()
{
string nextPartNumber=String.Empty;
try
{
// Declare and
Initialize EpiDataView Variables
// Declare and create an
instance of the Adapter.
CompanyAdapter
adapterCompany = new CompanyAdapter(this.oTrans);

adapterCompany.BOConnect();

// Declare and
Initialize Variables
ILaunch iLnch = oTrans
as ILaunch;
string
company = ((Epicor.Mfg.Core.Session)iLnch.Session).CompanyID;


// Call Adapter method
bool result =
adapterCompany.GetByID(company);
if (result)
{

nextPartNumber =
adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToString();

adapterCompany.CompanyData.Company.Rows[0].BeginEdit();

int origNum =
Int32.Parse(adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToStr
ing());

adapterCompany.CompanyData.Company.Rows[0]["Number02"] = ++origNum;
//Adds one to Number02 value origNum +1

adapterCompany.CompanyData.Company.Rows[0].EndEdit();

adapterCompany.Update();
}
// Cleanup Adapter
Reference

adapterCompany.Dispose();
adapterCompany=null;


}
catch (System.Exception ex)

{
ExceptionBox.Show(ex);
}

return nextPartNumber;
}

End Try
End Sub
End Module

His response was as following:You can continue with your idea below and
create a customization that increases the part number through code. To
write a customization that automatically increments the part number by
one, create code that does the following:

1. Define a variable vNextPartNum
2. Find last Part.PartNum
3. Assign vNextPartNum=vNextPartNum + 1

My issue is that I am new at this whole thing and have no idea how or
where to define this variable and where to insert it in my code. Can any
of you help me with this? Is there an example in one of the tool guides
that could help?

Thank you,
Melissa Hietala
UMC, Inc.
melissah@... <mailto:melissah%40ultramc.com>

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]
This is much easier / better done in a BPM (if you want all Parts to be
incremented this way)
On a Post Processing n GetNewPart

Excecute 4GL Code roughly not on an editor so the syntax may be slightly
off.

FIND LAST Part NO-ERROR NO-LOCK.
IF AVAILABLE PART THEN DO:
ttPart.PartNum = NUMERIC(Part.PartNum)+1.
END.


*Jose C Gomez*
*Software Engineer*
*
*
*
*T: 904.469.1524 mobile
E: jose@...
http://www.josecgomez.com
<http://www.linkedin.com/in/josecgomez> <http://www.facebook.com/josegomez>
<http://www.google.com/profiles/jose.gomez> <http://www.twitter.com/joc85>
<http://www.josecgomez.com/professional-resume/>
<http://www.josecgomez.com/feed/>
<http://www.usdoingstuff.com>

*Quis custodiet ipsos custodes?*



On Tue, Oct 16, 2012 at 2:18 PM, Brian Roberts <broberts@...> wrote:

> **
>
>
> You'll want to do a screen customization on Part Maintenance, and either
> add a button that people manually click to fill in the next number, or
> possibly hook up to the after adapter method GetNewPart (guessing at the
> method name) so its automatic. Call your code below, then update the
> PartNum field in the dataset. My sample code (C# in 9.05, hooked up to
> a button) is below for an example.
>
> Brian.
>
> // assign new part
> number to brand new Part record
>
> if (nextpartnum != "") {
>
> EpiDataView edvPart = (EpiDataView)oTrans.EpiDataViews["Part"];
>
> edvPart.dataView[edvPart.Row].BeginEdit();
>
> edvPart.dataView[edvPart.Row]["PartNum"] = nextpartnum;
>
> edvPart.dataView[edvPart.Row].EndEdit();
>
> edvPart.Notify(new EpiNotifyArgs(oTrans, edvPart.Row, edvPart.Column));
>
> From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
> Of melissa hietala
> Sent: Tuesday, October 16, 2012 12:53 PM
> To: vantage@yahoogroups.com
> Subject: [Vantage] Customization to Get Next Part number
>
>
> I have sent code to one of the session presenters from Epicor to verify
> I am on the correct path to do a "get next part number" customization.
> Here's what I sent:
>
> private string GetNextPartNumber()
> {
> string nextPartNumber=String.Empty;
> try
> {
> // Declare and
> Initialize EpiDataView Variables
> // Declare and create an
> instance of the Adapter.
> CompanyAdapter
> adapterCompany = new CompanyAdapter(this.oTrans);
>
> adapterCompany.BOConnect();
>
> // Declare and
> Initialize Variables
> ILaunch iLnch = oTrans
> as ILaunch;
> string
> company = ((Epicor.Mfg.Core.Session)iLnch.Session).CompanyID;
>
>
> // Call Adapter method
> bool result =
> adapterCompany.GetByID(company);
> if (result)
> {
>
> nextPartNumber =
> adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToString();
>
> adapterCompany.CompanyData.Company.Rows[0].BeginEdit();
>
> int origNum =
> Int32.Parse(adapterCompany.CompanyData.Company.Rows[0]["Number02"].ToStr
> ing());
>
> adapterCompany.CompanyData.Company.Rows[0]["Number02"] = ++origNum;
> //Adds one to Number02 value origNum +1
>
> adapterCompany.CompanyData.Company.Rows[0].EndEdit();
>
> adapterCompany.Update();
> }
> // Cleanup Adapter
> Reference
>
> adapterCompany.Dispose();
> adapterCompany=null;
>
>
> }
> catch (System.Exception ex)
>
> {
> ExceptionBox.Show(ex);
> }
>
> return nextPartNumber;
> }
>
> End Try
> End Sub
> End Module
>
> His response was as following:You can continue with your idea below and
> create a customization that increases the part number through code. To
> write a customization that automatically increments the part number by
> one, create code that does the following:
>
> 1. Define a variable vNextPartNum
> 2. Find last Part.PartNum
> 3. Assign vNextPartNum=vNextPartNum + 1
>
> My issue is that I am new at this whole thing and have no idea how or
> where to define this variable and where to insert it in my code. Can any
> of you help me with this? Is there an example in one of the tool guides
> that could help?
>
> Thank you,
> Melissa Hietala
> UMC, Inc.
> melissah@... <mailto:melissah%40ultramc.com>
>
> [Non-text portions of this message have been removed]
>
> [Non-text portions of this message have been removed]
>
>
>


[Non-text portions of this message have been removed]