Calculating Total Release Weight and Total Order Weight

This was my first time posting to this group and I can't believe the quick and knowledgeable responses... thanks a lot guys! I'll have to try to help out where I can from now on.

As far as my question goes, I just needed to Find the Orderhed table before using the updatetablebuffer. Here is my working code:

DEFINE VAR relWeight AS DECIMAL.
DEFINE VAR totWeight AS DECIMAL.

FOR EACH ttorderhed:
FIND FIRST orderhed WHERE ttorderhed.company = orderhed.company AND ttorderhed.ordernum = orderhed.OrderNum.
IF AVAIL ttorderhed THEN DO:
FOR EACH ttorderrel:
FOR EACH orderrel WHERE ttorderrel.company = orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum = orderrel.OrderRelNum:
FIND FIRST part WHERE ttorderrel.company = part.company AND ttorderrel.PartNum = part.PartNum.
IF AVAIL part THEN DO:
relWeight = part.NetWeight * ttorderrel.OurReqQty.
ttorderrel.number01 = relWeight.
RUN lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01', relWeight).
END.
END.
END.
FOR EACH orderrel WHERE ttorderhed.company = orderrel.company AND ttorderhed.ordernum = orderrel.OrderNum:
relWeight = orderrel.number01.
totWeight = totWeight + relWeight.
END.
ttorderhed.number04 = totWeight.
RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE, 'Number04', totWeight).
END.
END.

--- In vantage@yahoogroups.com, "Dan Sirow" <dansirow@...> wrote:
>
>
>
> I think you need to FIND the OrderHed with EXCLUSIVE-LOCK before you can update it with UpdateTableBuffer.p
>
> Also, you need an ASSIGN when updating a value of a table or temp-table, so ASSIGN ttorderhed.Number04 = totWeight will work
>
> Happy New Year to All !!
>
> --- In vantage@yahoogroups.com, "Jeff" <jeff.rogers@> wrote:
> >
> > I'm new to 4GL and am stumbling my way through a new post-process BPM to calculate and display the total release weights and the total order weight on the Order Entry screen. Calculating the release weights work and display great, but I can not get the total order weight to display (or update the orderhed table with the value) even though it is calculated correctly. Any feed back would be great! Keep in mind I'm on Vantage 8. Here's my 4GL code below:
> >
> > DEFINE VAR relWeight AS DECIMAL.
> > DEFINE VAR totWeight AS DECIMAL.
> >
> > FOR EACH ttorderhed NO-LOCK:
> > FOR EACH ttorderrel:
> > FOR EACH orderrel WHERE ttorderrel.company = orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum = orderrel.OrderRelNum:
> > FIND FIRST part WHERE ttorderrel.company = part.company AND ttorderrel.PartNum = part.PartNum.
> > IF AVAIL part THEN DO:
> > relWeight = part.NetWeight * ttorderrel.OurReqQty.
> > ttorderrel.number01 = relWeight.
> > RUN lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01', relWeight).
> > END.
> > END.
> > END.
> > FOR EACH orderrel WHERE ttorderhed.company = orderrel.company AND ttorderhed.ordernum = orderrel.OrderNum:
> > relWeight = orderrel.number01.
> > totWeight = totWeight + relWeight.
> > END.
> > ttorderhed.number04 = totWeight. /* NOT WORKING!!!*/
> > RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE, 'Number04', totWeight). /* NOT WORKING!!!*/
> > END.
> >
>
I'm new to 4GL and am stumbling my way through a new post-process BPM to calculate and display the total release weights and the total order weight on the Order Entry screen. Calculating the release weights work and display great, but I can not get the total order weight to display (or update the orderhed table with the value) even though it is calculated correctly. Any feed back would be great! Keep in mind I'm on Vantage 8. Here's my 4GL code below:

DEFINE VAR relWeight AS DECIMAL.
DEFINE VAR totWeight AS DECIMAL.

FOR EACH ttorderhed NO-LOCK:
FOR EACH ttorderrel:
FOR EACH orderrel WHERE ttorderrel.company = orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum = orderrel.OrderRelNum:
FIND FIRST part WHERE ttorderrel.company = part.company AND ttorderrel.PartNum = part.PartNum.
IF AVAIL part THEN DO:
relWeight = part.NetWeight * ttorderrel.OurReqQty.
ttorderrel.number01 = relWeight.
RUN lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01', relWeight).
END.
END.
END.
FOR EACH orderrel WHERE ttorderhed.company = orderrel.company AND ttorderhed.ordernum = orderrel.OrderNum:
relWeight = orderrel.number01.
totWeight = totWeight + relWeight.
END.
ttorderhed.number04 = totWeight. /* NOT WORKING!!!*/
RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE, 'Number04', totWeight). /* NOT WORKING!!!*/
END.
Take a look at your Vantage server log and see if anything interesting
is being logged when your BPM is running.

-bws

-----Original Message-----
From: vantage@yahoogroups.com [mailto:vantage@yahoogroups.com] On Behalf
Of Jeff
Sent: Thursday, December 30, 2010 4:15 PM
To: vantage@yahoogroups.com
Subject: [Vantage] Calculating Total Release Weight and Total Order
Weight

I'm new to 4GL and am stumbling my way through a new post-process BPM to
calculate and display the total release weights and the total order
weight on the Order Entry screen. Calculating the release weights work
and display great, but I can not get the total order weight to display
(or update the orderhed table with the value) even though it is
calculated correctly. Any feed back would be great! Keep in mind I'm on
Vantage 8. Here's my 4GL code below:

DEFINE VAR relWeight AS DECIMAL.
DEFINE VAR totWeight AS DECIMAL.

FOR EACH ttorderhed NO-LOCK:
FOR EACH ttorderrel:
FOR EACH orderrel WHERE ttorderrel.company =
orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND
ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum =
orderrel.OrderRelNum:
FIND FIRST part WHERE ttorderrel.company =
part.company AND ttorderrel.PartNum = part.PartNum.
IF AVAIL part THEN DO:
relWeight = part.NetWeight *
ttorderrel.OurReqQty.
ttorderrel.number01 = relWeight.
RUN
lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01',
relWeight).
END.
END.
END.
FOR EACH orderrel WHERE ttorderhed.company = orderrel.company
AND ttorderhed.ordernum = orderrel.OrderNum:
relWeight = orderrel.number01.
totWeight = totWeight + relWeight.
END.
ttorderhed.number04 = totWeight. /* NOT WORKING!!!*/
RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE,
'Number04', totWeight). /* NOT WORKING!!!*/
END.



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

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 think you need to FIND the OrderHed with EXCLUSIVE-LOCK before you can update it with UpdateTableBuffer.p

Also, you need an ASSIGN when updating a value of a table or temp-table, so ASSIGN ttorderhed.Number04 = totWeight will work

Happy New Year to All !!

--- In vantage@yahoogroups.com, "Jeff" <jeff.rogers@...> wrote:
>
> I'm new to 4GL and am stumbling my way through a new post-process BPM to calculate and display the total release weights and the total order weight on the Order Entry screen. Calculating the release weights work and display great, but I can not get the total order weight to display (or update the orderhed table with the value) even though it is calculated correctly. Any feed back would be great! Keep in mind I'm on Vantage 8. Here's my 4GL code below:
>
> DEFINE VAR relWeight AS DECIMAL.
> DEFINE VAR totWeight AS DECIMAL.
>
> FOR EACH ttorderhed NO-LOCK:
> FOR EACH ttorderrel:
> FOR EACH orderrel WHERE ttorderrel.company = orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum = orderrel.OrderRelNum:
> FIND FIRST part WHERE ttorderrel.company = part.company AND ttorderrel.PartNum = part.PartNum.
> IF AVAIL part THEN DO:
> relWeight = part.NetWeight * ttorderrel.OurReqQty.
> ttorderrel.number01 = relWeight.
> RUN lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01', relWeight).
> END.
> END.
> END.
> FOR EACH orderrel WHERE ttorderhed.company = orderrel.company AND ttorderhed.ordernum = orderrel.OrderNum:
> relWeight = orderrel.number01.
> totWeight = totWeight + relWeight.
> END.
> ttorderhed.number04 = totWeight. /* NOT WORKING!!!*/
> RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE, 'Number04', totWeight). /* NOT WORKING!!!*/
> END.
>
You might try replacing the for each on the order release line with a find statement since it should only be one record that matches at that level. Might need to do the same for loading the order header too. For a vague remembrance I am not sure if the update table buffer works under a for each loop, but that may be a false memory.

Jim Kinneman
Encompass Solutions, Inc

--- In vantage@yahoogroups.com, "Jeff" <jeff.rogers@...> wrote:
>
> I'm new to 4GL and am stumbling my way through a new post-process BPM to calculate and display the total release weights and the total order weight on the Order Entry screen. Calculating the release weights work and display great, but I can not get the total order weight to display (or update the orderhed table with the value) even though it is calculated correctly. Any feed back would be great! Keep in mind I'm on Vantage 8. Here's my 4GL code below:
>
> DEFINE VAR relWeight AS DECIMAL.
> DEFINE VAR totWeight AS DECIMAL.
>
> FOR EACH ttorderhed NO-LOCK:
> FOR EACH ttorderrel:
> FOR EACH orderrel WHERE ttorderrel.company = orderrel.Company AND ttorderrel.OrderNum = orderrel.OrderNum AND ttorderrel.OrderLine = orderrel.OrderLine AND ttorderrel.OrderRelNum = orderrel.OrderRelNum:
> FIND FIRST part WHERE ttorderrel.company = part.company AND ttorderrel.PartNum = part.PartNum.
> IF AVAIL part THEN DO:
> relWeight = part.NetWeight * ttorderrel.OurReqQty.
> ttorderrel.number01 = relWeight.
> RUN lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE, 'Number01', relWeight).
> END.
> END.
> END.
> FOR EACH orderrel WHERE ttorderhed.company = orderrel.company AND ttorderhed.ordernum = orderrel.OrderNum:
> relWeight = orderrel.number01.
> totWeight = totWeight + relWeight.
> END.
> ttorderhed.number04 = totWeight. /* NOT WORKING!!!*/
> RUN lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE, 'Number04', totWeight). /* NOT WORKING!!!*/
> END.
>