Automatic Miscellaneous Charge add..9.05.702a Progress

Attempting to trigger a miscellaneous charge addition to each new line on an order. I’ve found a post on a different forum with the following “Jose C Gomez’s working Code” :

DEFINE VARIABLE hSalesOrder AS HANDLE NO-UNDO.
DEFINE VARIABLE miscCode AS CHARACTER NO-UNDO.
DEFINE VARIABLE orderNum AS INTEGER NO-UNDO.
ASSIGN miscCode =‘FRGT’.
/* CREATE A HANDLE FOR THE SALES ORDER BO /
RUN bo/SalesOrder.p PERSISTENT SET hSalesOrder.
/
GET THE SALES ORDER NUMBER*/
FOR EACH ttOrderHed:
Assign orderNum= ttOrderHed.OrderNum.
END.

/* RUN GET BY ID TO GET THE MOST UP TO DATE COPY OF THE ORCER */
RUN GetByID IN hSalesOrder(INPUT orderNum,
{&output_dataset_SalesOrderDataSet}).

/* WE GET THE FIRST ORDER LINE IN THE ORDER*/
FOR FIRST ttOrderDtl:
/* CHECK TO SEE IF OUR MISC CHARGE ALREADY EXISTS*/
FIND FIRST OrderMsc WHERE OrderMsc.Company=ttOrderDtl.Company AND
OrderMsc.OrderNum=ttOrderDtl.OrderNum AND OrderMsc.OrderLine =
ttOrderDtl.OrderLine AND OrderMsc.MiscCode=miscCode NO-LOCK NO-ERROR.
/* IF IT DOES NOT EXIST /
IF NOT AVAILABLE OrderMsc THEN DO:
/
GET A NEW MISC CHARGE FOR THE FIRST LINE /
RUN GetNewOrderMsc IN
hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ttOrderDtl.OrderNum,
ttOrderDtl.OrderLine).
/
ASSIGN THE MISC CODE /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.MiscCode=miscCode.
END.
/
RUN THE CHANGE MISC CODE BO TO GET DESCRIPTION AND SUCH /
RUN ChangeMiscCode IN
hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ‘OrderMsc’).
/
ASSIGN THE AMOUNT OF THE MISC CHARGE /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.DocMiscAmt=35.50.
END.
/
RUN THE CHANGE AMOUNT BO TO GET THE REST OF THE INFO FILLED /
RUN ChangeMiscAmount IN
hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ‘OrderMsc’).
/
SET THE FREQUENCY /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.FreqCode=‘F’.
END.
/
UPDATE OUR CHANGES. THIS TIME OUR BPM WILL STOP SHORT BECAUSE WE HAVE
THAT MISC CHARGE /
RUN Update IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}).
/
RUN GET BY ID TO GET THE MOST FRESH COPY OF OUR DATA */
RUN GetByID IN hSalesOrder(INPUT orderNum,
{&output_dataset_SalesOrderDataSet}).
END.
END.

…and some discussion that this has to be a post-processing Method Directive on SalesOrder.Update. I created the post-processing method Directive, with the Action of “synchronously execute ABL code…record nothing” and pasted the code. Everything validated ok. Set up the charge type itself and attempted to execute…and receive a “4GL STOP condition error”.

Any ideas as to what we’re doing wrong?

Hey Doyle
That’s my code! I wonder who took it elsewhere shakes fist
Looking at your server logs when this runs what is the error there? It could be that this was written for a different version and the method signatures have changed.

-Jose Gomez

Hello Jose! Thank you for responding!

The error I see in the server logs is:

(Procedure: ‘UpdatePost13_A1 bo/SalesOrder/SalesOrder.p’ Line:11614) ** “bo/SalesOrder.p” was not found. (293)

…so I’m guessing it is code for SQL?

Yeah this was written for 8
In 9 they moved the BO into folders
Find the Bo/SalesOrder.p line and add a folder
Bo/SalesOrder/SalesOrder.p

-Jose Gomez

I’ve located the Server\bo\SalesOrder directory, but there is no SalesOrder.p. There is SalesOrder.i, SalesOrder.r, SalesOrder_ds.i, SalesOrder_eq.i, saleOrderAfterGetRows.i, and SalesOrderTrg.r, but no “SalesOrder.p”.

That’s fine, progress is weird. Just changed the path on the code to say no/SalesOrder/SalesOrder.p

Sorry, should have been clearer…there is not a “bo\SalesOrder\SalesOrder.p” file.

In the “bo\SalesOrder” directory, I have:

SalesOrder.i
SalesOrder.r
SalesOrder_ds.i
SalesOrder_eq.i
saleOrderAfterGetRows.i
SalesOrderTrg.r

The only directory I can find a “SalesOrder.p” in are:

  1. C:\Epicor\Epicor905\BPMExec\TestBPM\bo\SalesOrder
  2. C:\Epicor\Epicor905\BPMExec\LiveBPM\bo\SalesOrder
  3. C:\Epicor\Epicor905\BPMExec\PilotBPM\bo\SalesOrder
  4. C:\Epicor\Epicor905\Custom\bo\sample
1 Like

I understand the .p is the progress code file and it will work just set the path as I asked and try again

-Jose Gomez

Even though you don’t see the file setting the path to Bo/SalesOrder/SalesOrder.p will work
The .I file is a compiled version of the .p

-Jose Gomez

Gotcha, makes sense. I explicitly called out the path as

“RUN C:\Epicor\Epicor905\Server\bo\SalesOrder\SalesOrder.p”

…and it picked up and added the charge correctly. Thank you for your patience!

As Jose said you are fine. In Progress .r = compiled, .i = include file, .p and .w are source code.

In your case the SalesOrder.r = SalesOrder.p + any include files that are called out, most likely the SalesOrder.i but there could be others.

Jim M.

Don’t call the path specifically, that is bad practice. Just set s local path within the PROPATH. Start with Bo/

-Jose Gomez

I hate to dig up an old post, but I have run into a little problem using the code above. I have added a lookup for a decimal field on the customer record to use to set the value for the DocMiscAmt field. This allows for different customers to be charged a different processing fee amount. Here is my complete BPM code:

DEFINE VARIABLE hSalesOrder AS HANDLE NO-UNDO.
DEFINE VARIABLE miscCode AS CHARACTER NO-UNDO.
DEFINE VARIABLE orderNum AS INTEGER NO-UNDO.
DEFINE VARIABLE procFeeAmt AS DECIMAL NO-UNDO.
ASSIGN miscCode =‘PROC’.
/* CREATE A HANDLE FOR THE SALES ORDER BO /
RUN bo/SalesOrder/SalesOrder.p PERSISTENT SET hSalesOrder.
/
GET THE SALES ORDER NUMBER*/
FOR EACH ttOrderHed:
Assign orderNum= ttOrderHed.OrderNum.
FIND FIRST Customer WHERE Customer.Company=ttOrderHed.Company AND Customer.CustNum=ttOrderHed.CustNum NO-LOCK NO-ERROR.
IF AVAILABLE Customer THEN DO:
ASSIGN procFeeAmt=Customer.Number02.
END.
END.

/* RUN GET BY ID TO GET THE MOST UP TO DATE COPY OF THE ORCER */
RUN GetByID IN hSalesOrder(INPUT orderNum,
{&output_dataset_SalesOrderDataSet}).

/* WE GET THE FIRST ORDER LINE IN THE ORDER*/
FOR FIRST ttOrderDtl:
/* CHECK TO SEE IF OUR MISC CHARGE ALREADY EXISTS*/
FIND FIRST OrderMsc WHERE OrderMsc.Company=ttOrderDtl.Company AND OrderMsc.OrderNum=ttOrderDtl.OrderNum AND OrderMsc.OrderLine=ttOrderDtl.OrderLine AND OrderMsc.MiscCode=miscCode NO-LOCK NO-ERROR.
/* IF IT DOES NOT EXIST /
IF NOT AVAILABLE OrderMsc THEN DO:
/
GET A NEW MISC CHARGE FOR THE FIRST LINE /
RUN GetNewOrderMsc IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ttOrderDtl.OrderNum, ttOrderDtl.OrderLine).
/
ASSIGN THE MISC CODE /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.MiscCode=miscCode.
END.
/
RUN THE CHANGE MISC CODE BO TO GET DESCRIPTION AND SUCH /
RUN ChangeMiscCode IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ‘OrderMsc’).
/
ASSIGN THE AMOUNT OF THE MISC CHARGE /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.DocMiscAmt=procFeeAmt.
END.
/
RUN THE CHANGE AMOUNT BO TO GET THE REST OF THE INFO FILLED /
RUN ChangeMiscAmount IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}, ‘OrderMsc’).
/
SET THE FREQUENCY /
FOR EACH ttOrderMsc WHERE ttOrderMsc.RowMod=‘A’:
Assign ttOrderMsc.FreqCode=‘E’.
END.
/
UPDATE OUR CHANGES. THIS TIME OUR BPM WILL STOP SHORT BECAUSE WE HAVE THAT MISC CHARGE /
RUN Update IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}).
/
RUN GET BY ID TO GET THE MOST FRESH COPY OF OUR DATA */
RUN GetByID IN hSalesOrder(INPUT orderNum, {&output_dataset_SalesOrderDataSet}).
END.
END.

The problem is, the ttOrderMsc table is never actually saved to the DB. There are no errors in processing the BPM, and if you look at the Order -> Lines -> Misc Charges tab on the Order entry, all of the ttOrderMsc table data is displayed, until you click the “Refresh” button on the UI (at which point that data disappears). Also, if you are viewing the ttOrderMsc data (with the changes that the BPM made) and click on the “Save” button in the ribbon, it does nothing. Any suggestions?

Version is Epicor 9.05.702, SQL 64-bit DB

Ok, so even though it is bad practice to call out a file from within a BPM by its full path, I had to do it that way in order to get the charge to apply on the Order Line properly. If I change it back to a relative path, it will not save the misc charge. Anybody have any ideas on that?