Altering the address of a PO when a new PO header is requested

bpm

(Clive Pottinger) #1

Hello all,

I am new to Vantage, with no training, and virtually no documentation. I have been able to muddle through requests for a few months now, but I am now seeing more complicated tickets come my way. I am somewhat behind the 8-ball here, and though I don’t want to sound like I’m asking someone to do my homework for me, I do need some help.

The problem we face is that when POs are created, they are automatically assigned the Ship To address of the user’s company. However, we have several remote plants, and even if the user selects the right plant, the PO is still created with the Ship To of the company and not the plant.

I had asked about this in another thread and was directed to look at creating a BMP (my thanks again to that user), I tried my best to muddle out creating a BMP, but I am not able to create anything that seems to have any effect.

Below is a summary of what I thought would be the correct procedure:

  • Create a new Method Directive for the Method Code “PO.GetNewPOHeader”.
  • In Base Processing, add a new directive with
    condition: the specified [POHeader.ShipAddress2] field of [the added row] [is equal to] the specific [“123 OurAddress St”] value
    action: set the specified [POHeader.ShipAddress2] field [the added row] to the specific [“987 PlantAddress St”] value
  • Set the Enabled flag on the directive

This, of course was just to test that I could get this to do something and I used proper values for the addresses. But, still I had no luck. Requesting a new PO is the Purchase Order Entry screen did not result in a change to the address.

So my question is 3-fold:
a) What did I do wrong above? I thought this directive would assure that when I asked for a new PO it would have an address of “987 PlantAddress St”.

b) I can already see my next problem - I can’t set the address to a specific value. I need to set the address fields to the values I would find in the database on the plants table. Which of the possible processing selections would let me do that?

c) I assume I would need to create a query to get the correct record from the plant table, but I am struggling to figure out what the query would like. I thought something like:
for each ttPOHeader,
for each plant
where plant.company = ttPOHeader.company
and plant.name = CurCompName
However, this is less of a problem, since problem b) means I don’t even know where I would use the query.

Any help, guidance, suggestions would be greatly appreciated.


Altering the address of POs created from PO Suggestions
(Greg Payne) #2

Clive:

NEVER use base processing until you are very seasoned in Epicor and even then never do it. Pre-processing is data going from the screen to the database and post-processing is going from the database to the screen.

In PO.GetNewPOHeader we are interrupting the data as it goes from the database to the screen, so it will be a post processing directive BPM.

The tools guide for your version is available on Epicweb here. https://epicweb.epicor.com/doc/Docs/EpicorTools_UserGuideebook_%20803400.pdf

For most of my solutions I go straight to ABL and some simple coding. I took your code below and tweaked it and this should get you going.

I use the message line like below to send debugging information into the server log. You will need a log reader to view the log while Epicor has it open. I use LTFViewr.

Good Luck,

Greg


/* Assign plant address to PO header */

For each ttPOHeader,
                  each Plant where Plant.Company = ttPOHeader.Company and Plant.Plant = Cur-plant.

                Message "In assign plant address"  + string(ttPOHeader.PONum).

                Assign ttPOHeader.ShipAddress1 = Plant.Address1
                                                                ttPOHeader.ShipAddress2 = Plant.Address2
                                                                ttPOHeader.ShipAddress3 = Plant.Address3
                                                                ttPOHeader.ShipCity = Plant.City
                                                                ttPOHeader.ShipState = Plant.State
                                                                ttPOHeader.ShipZip = Plant.Zip.

                                Find Country where Country.Company=Plant.Company and Country.CountryNum=Plant.CountryNum no-error.

                                                                If available Country Then
                                                                ttPOHeader.ShipCountry = Country.ISOCode.


End.



(Clive Pottinger) #3

Thank you, Greg. Thank You, THANK YOU ! ! !

This is exactly the kind of information I needed, and it is working… almost.

The only remaining issue now is that no matter how I try, the country dropdown box on the Purchase Order Entry screen always reads ‘Canada’. I can see that the query should be obtaining the proper countrynum value, but it does not seem to make any difference to the value shown in the dropdown.

I even changed the ABL in the directive in case the ‘IF’ portion that you provided was somehow the culprit (though I don’t see how it would be):

/* Assign plant address to PO header */

For each ttPOHeader,
      each Plant where Plant.Company = ttPOHeader.Company and Plant.Plant = Cur-plant,
      each Country where Country.Company=Plant.Company and Country.CountryNum=Plant.CountryNum.

                Message "In assign plant address"  + string(ttPOHeader.PONum).

                Assign ttPOHeader.ShipAddress1 = Plant.Address1
                           ttPOHeader.ShipAddress2 = Plant.Address2
                           ttPOHeader.ShipAddress3 = Plant.Address3
                           ttPOHeader.ShipCity = Plant.City
                           ttPOHeader.ShipState = Plant.State
                           ttPOHeader.ShipZip = Plant.Zip
                           ttPOHeader.ShipCountryNum = Plant.CountryNum
                           ttPOHeader.ShipCountry = Country.Description.

End.

Any ideas?

BTW: I don’t see where the Message is displayed anywhere - not a big deal, but it could prove useful for future work if I understood how that works.


(Greg Payne) #4

To set dropdowns you usually have to also set the description. Change the if to this.

                                                                If available Country Then do:
                                                                               Assign   ttPOHeader.ShipCountry = Country.ISOCode
                                                                                               ttPOHeader.ShipCountryNumDescription = Country.Description.
                                                                End.

Message goes to your server log. I never ran Vantage, but my logs are in \server\Epicor905\Server\Logs<file:///\server\Epicor905\Server\Logs> Like this.

[/uploads/default/original/2X/f/f0aa32be93c7701a50d92c1204cad792d13cadac.png]


(Clive Pottinger) #5

I owe you a coffee.

Thanks so very much. The country code is now being set correctly.


(Greg Payne) #6

Awesome. Mark the question as solved.