Updating Sales Order Lines after change to Header

I have the same issue

i want to update a custom field in the detail based on the value in the
header and i found that BPM will not work.
can anyone explain why this will not work with a BPM


Thanks
ephraim

On Thu, Jul 28, 2011 at 9:28 AM, Joe Rojas <jrojas@...> wrote:

> **
>
>
> Hi All,
>
> I have a couple of BPMs that update fields on all associated sales order
> lines when a change happens at the header level.
>
> The problem with this is that it always results in the message that the
> order has been changed by another user.
>
> I going to try to do this with a UI customization.
>
> Does anyone have example code of how to iterate through all the lines of
> a sales order, change the field, update, and then refresh the order?
>
>
>
>
>
>
>
> Joe Rojas | Director of Information Technology | Mats Inc
> dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
> jrojas@... | www.matsinc.com Ask us about our clean, green and
> beautiful matting and flooring
>
> This message is intended only for the individual named. If you are not the
> named addressee you should not disseminate, distribute or copy this e-mail.
> Please notify the sender immediately by e-mail if you have received this
> e-mail by mistake. Please note that any views or opinions presented in this
> email are solely those of the author and do not necessarily represent those
> of the company.
>
> [Non-text portions of this message have been removed]
>
>
>


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



I have a couple of BPMs that update fields on all associated sales order
lines when a change happens at the header level.

The problem with this is that it always results in the message that the
order has been changed by another user.



I going to try to do this with a UI customization.

Does anyone have example code of how to iterate through all the lines of
a sales order, change the field, update, and then refresh the order?










Joe Rojas | Director of Information Technology | Mats Inc
dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring


This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.


[Non-text portions of this message have been removed]
You have to be sure to check the rowmod field in the TT. If you "FOR EACH tt..." and change both the "" and "U" rowmod records it could cause the "changed by another user" because the before-image record will not match what is in the database.

We have a couple of BPM's which ripple changes in the order header down into the lines, or in this case, the releases.

This is a "forward to procedure" from the pre-processing method directives on SalesOrder. If the order is changed, it checks the release type of the line items, and sets a flag in the order header if the release is DC (Distribution Center) or PTL Only (Pick to Light).

Note that this program runs an external 4GL program ([Custom/]pny/GetRelType.p) passing parameters which returns the release type. that program is called from various other places in the system. This keeps that logic consistent.

/* Actions/PNYSalesOrder.p - Order lookup with sales security
06.10.2011 CAH: initial write.
- Got time down from 102 seconds to 5.
*/

{Bpm/Bpm.i &OBJECT_NAME="SalesOrder" &BPM_BO_SOURCE_BO=1 &CUR-COMP=}
{Bpm/MiscCallContext.i}
{core/UserDefinedData.i "new global"}

{pny/standard.i}

define buffer bittOrderHed for ttorderhed. /* before image to detect changed fields */

procedure MasterUpdateBefore:
define input-output parameter lcheckForResponse as logical.
define input-output parameter cTableName as character.
define input-output parameter iCustNum as integer.
define input-output parameter iOrderNum as integer.
define input-output parameter lweLicensed as logical.
define input-output parameter lContinue as logical.
define input-output parameter cResponseMsg as character.
define input-output parameter cDisplayMsg as character.
define input-output parameter cCompliantMsg as character.
define input-output parameter dataset for SalesOrderDataSet.
{&TRY_PRIVATE}

def var vlPurePTL as logical no-undo.
def var vlHasLines as logical no-undo.

/* Check to see if ShipTo is a DC */
For each ttOrderHed where RowMod = "A" or RowMod = "U":

if ttorderhed.checkbox01 = false then do:

if top-debug then Run PNY/debugmsg.p ("BOJ-KJ").

Find First ShipTo where ShipTo.Company = ttOrderHed.Company
and shipto.custnum = ttorderhed.shiptocustnum
and ShipTo.ShipToNum = ttOrderHed.ShipToNum no-lock no-error.

If available (shipto) then do:
if ShipTo.CheckBox01 = yes then
assign ttOrderHed.CheckBox01 = yes.
/* if top-debug then Run PNY/debugmsg.p ("-- ShiptoCheckbox01: " + string(ShipTo.CheckBox01)
+ " Orderhed.CheckBox04: " + string(ttOrderHed.CheckBox04)). */
end.
/* else run pny/debugmsg.p ("*** There was no shipto for order# " + string(ttorderhed.ordernum)).

if top-debug then Run PNY/debugmsg.p ("EOJ-KJ"). */

end.

/* 06.07.2011 CAH: This should probably be in a "post" directive as it ripples to orderrel
which might be updated as part of the same master update. could overwrite our changes
*/
if ttorderhed.rowmod = "U" then do:
/* see if DC flag has changed */
find first bittorderhed where bittorderhed.sysrowid = ttorderhed.sysrowid
and bittorderhed.rowmod = "" no-lock no-error.

if available (bittorderhed) then do:

assign vlPurePTL = yes vlHasLines = no.

if bittorderhed.checkbox01 <> ttorderhed.checkbox01 then do:
/* 05.26.2011 CAH: set the release packing types by calling ABL */
def var top-debug as logical no-undo initial true.

def var vlcb1 as logical no-undo.
def var vlcb2 as logical no-undo.
def var vlcb3 as logical no-undo.


for each orderrel
where orderrel.company = ttorderhed.company
and orderrel.ordernum = ttorderhed.ordernum:

run pny/GetRelType.p (input orderrel.company,
input orderrel.ordernum,
input orderrel.orderline,
input orderrel.orderrelnum,
input orderrel.partnum,
input "",
output vlcb1,
output vlcb2,
output vlcb3) no-error.

run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Checkbox01', vlCB1).
run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Checkbox02', vlCB2).
run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Checkbox03', vlCB3).

assign
vlPurePTL = vlPurePTL and vlCB2
vlHasLines = true.

end. /* each orderrel */

if top-debug then run pny/debugmsg.p ("DC Flag of releases for order# "
+ string(ttorderhed.ordernum)
+ " Updated to: " + string(ttorderhed.checkbox01)
+ " [Rowmod:" + ttorderhed.rowmod + "]").

if vlHasLines then do:
/* if all lines are PTL then update the flag */
assign ttorderhed.checkbox04 = vlPurePTL.
end.


end. /* DC Flag Changed */
end. /* found before image */
end. /* changed record */
End. /* each ttorderhed */

{&CATCH_PRIVATE}
end procedure.



--- In vantage@yahoogroups.com, Joe Rojas <jrojas@...> wrote:
>
> Hi All,
>
>
>
> I have a couple of BPMs that update fields on all associated sales order
> lines when a change happens at the header level.
>
> The problem with this is that it always results in the message that the
> order has been changed by another user.
>
>
>
> I going to try to do this with a UI customization.
>
> Does anyone have example code of how to iterate through all the lines of
> a sales order, change the field, update, and then refresh the order?
>
>
>
>
>
>
>
>
>
>
> Joe Rojas | Director of Information Technology | Mats Inc
> dir: 781-573-0291 | cell: 781-408-9278 | fax: 781-232-5191
> jrojas@... | www.matsinc.com Ask us about our clean, green and beautiful matting and flooring
>
>
> This message is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company.
>
>
> [Non-text portions of this message have been removed]
>