Jose, this BPM is updating twice. I have few other BPMs in the same BO(SalesOrder.Update) which also gets triggered when this BPM runs.
Is there anyway, I could make it run only once.
If I am correct the last update line: RUN Update IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}). is causing the problem. How can I fix it? Thanks.
Is there anyway, I could make it run only once.
If I am correct the last update line: RUN Update IN hSalesOrder({&input-output_dataset_SalesOrderDataSet}). is causing the problem. How can I fix it? Thanks.
--- In vantage@yahoogroups.com, Jose Gomez <jose@...> wrote:
>
> Sure...
> Sanya wanted to add a line misc charge using a BPM.
>
> Last night i finished testing this and I know it works its commented the
> best I can. This example will add a Misc Charge to the First line in the
> order if that charge is not already there. This needs to be done as a Post
> Proc directive on Sales Order Update
>
>
> DEFINE VARIABLE hSalesOrder AS HANDLE NO-UNDO.
> DEFINE VARIABLE miscCode AS CHARACTER NO-UNDO.
> DEFINE VARIABLE orderNum AS INTEGER NO-UNDO.
> ASSIGN miscCode ='GCTF'.
> /* 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.
>
>
> *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?*
>
>
> [Non-text portions of this message have been removed]
>