Closing Order lines within a % range automatically

I was able to get it to do what I wanted in a different way. We are make to order I am just checking the production quantity agains the shipped quantity & if there is less than 100 left to ship I am closing it out.

find first ttShipHead where ttShipHead.ShipStatus = "Shipped" no-lock no-error.
if available ttShipHead then do:
find first ShipDtl where ShipDtl.PackNum = ttShipHead.PackNum.
if available ShipDtl then do:
find first JobProd where ShipDtl.JobNum = JobProd.JobNum.
if available JobProd then do:
DEFINE VARIABLE OrdNum AS INTEGER NO-UNDO.
DEFINE VARIABLE OrdLine As INTEGER NO-UNDO.
DEFINE VARIABLE ProdQty As INTEGER NO-UNDO.
DEFINE VARIABLE ShippedQty As INTEGER NO-UNDO.
DEFINE VARIABLE RemainQty As INTEGER NO-UNDO.
ProdQty = JobProd.ProdQty.
ShippedQty = JobProd.ShippedQty.
OrdNum = JobProd.OrderNum.
OrdLine = JobProd.OrderLine.
RemainQty = ProdQty - ShippedQty.
MESSAGE '>>Remaining' RemainQty.
If RemainQty < 100 then do:
For Each OrderDtl where(OrderDtl.OrderNum = OrdNum)and(OrderDtl.OrderLine = OrdLine) and (OrderDtl.Company = ttShipHead.Company)no-lock:
Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE,'OpenLine',False).

end.
end.
end.
end.
end.

--- In vantage@yahoogroups.com, "Michael McWilliams" <mmcwilliams22@...> wrote:
>
> I have had this working for a bit now just closing as we ship. Now I need to start with the actual validation of quantities. I am trying to access some fields like ttShipDtl.OurRemainQty(not an actual ShipDtl field only in the temp table)
> So when defining the variables I have
> DEFINE VARIABLE RemQty AS INTEGER NO-UNDO.
> RemQty = ttShipDtl.OurRemainQty.
>
>
> but at that point the ttShipDtl is not available.
> Where should I define it so that I can check every ttShipDtl to see the remaining quantity & if it is under say 100 then process & close the order line/release?
>
> --- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@> wrote:
> >
> > Hi Michael,
> >
> > I have a BPM that closes a sales order upon shipping. It doesn't do
> > any checks, it just closes - we don't keep back orders - but you
> > should be able to adapt the code to do what you need.
> >
> > It's a post-processing directive setup on the CustShip.Update BO.
> >
> > Condition: number of rows in the <query> is equal to 1
> > query: for each ttShipHead where ReadyToInvoice=True and
> > CheckBox01=True
> > (CheckBox01 is used by us to check if this customer accepts
> > backorders.)
> >
> > Action: execute the following 4GL code
> > code:
> >
> > find first ttShipHead where ttShipHead.ShipStatus="Shipped" no-lock
> > no-error.
> > if available ttShipHead then do:
> > find first ShipDtl where ShipDtl.Company=ttShipHead.Company and
> > ShipDtl.PackNum=ttShipHead.PackNum.
> > if available ShipDtl then do:
> > DEFINE VARIABLE OrdNum AS INTEGER NO-UNDO.
> > OrdNum = 0.
> > OrdNum = ShipDtl.OrderNum.
> > FOR EACH OrderRel WHERE (OrderRel.OrderNum = OrdNum) and
> > (OrderRel.OpenRelease = True) and (OrderRel.Company =
> > ttShipHead.Company) no-lock:
> > Run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE,
> > 'OpenRelease',False).
> > end.
> >
> > FOR EACH OrderDtl WHERE (OrderDtl.OrderNum = OrdNum) and
> > (OrderDtl.OpenLine = True) and (OrderDtl.Company =
> > ttShipHead.Company) no-lock:
> > Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE,
> > 'OpenLine',False).
> > end.
> >
> > FOR EACH OrderHed WHERE (OrderHed.OrderNum = OrdNum) and
> > (OrderHed.OpenOrder = True) and (OrderHed.Company =
> > ttShipHead.Company) no-lock:
> > Run lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE,
> > 'OpenOrder',False).
> > end.
> > end.
> > end.
> >
> >
> > Hope this is of some help.
> >
> > Nigel.
> >
> >
> > --- In vantage@yahoogroups.com, "Michael McWilliams"
> > <mmcwilliams22@> wrote:
> > >
> > > We are a make to orders hop, & each order Line is a Job. Many of
> > our
> > > jobs are for quantities of 10k or more. Most of the time they ship
> > up
> > > to 10% short. I am trying to figure out a way to autmatically
> > close
> > > an order if it is shipped within 10% of the ordered quantity.
> > >
> >
>
We are a make to orders hop, & each order Line is a Job. Many of our
jobs are for quantities of 10k or more. Most of the time they ship up
to 10% short. I am trying to figure out a way to autmatically close
an order if it is shipped within 10% of the ordered quantity.
Hi Michael,

I have a BPM that closes a sales order upon shipping. It doesn't do
any checks, it just closes - we don't keep back orders - but you
should be able to adapt the code to do what you need.

It's a post-processing directive setup on the CustShip.Update BO.

Condition: number of rows in the <query> is equal to 1
query: for each ttShipHead where ReadyToInvoice=True and
CheckBox01=True
(CheckBox01 is used by us to check if this customer accepts
backorders.)

Action: execute the following 4GL code
code:

find first ttShipHead where ttShipHead.ShipStatus="Shipped" no-lock
no-error.
if available ttShipHead then do:
find first ShipDtl where ShipDtl.Company=ttShipHead.Company and
ShipDtl.PackNum=ttShipHead.PackNum.
if available ShipDtl then do:
DEFINE VARIABLE OrdNum AS INTEGER NO-UNDO.
OrdNum = 0.
OrdNum = ShipDtl.OrderNum.
FOR EACH OrderRel WHERE (OrderRel.OrderNum = OrdNum) and
(OrderRel.OpenRelease = True) and (OrderRel.Company =
ttShipHead.Company) no-lock:
Run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE,
'OpenRelease',False).
end.

FOR EACH OrderDtl WHERE (OrderDtl.OrderNum = OrdNum) and
(OrderDtl.OpenLine = True) and (OrderDtl.Company =
ttShipHead.Company) no-lock:
Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE,
'OpenLine',False).
end.

FOR EACH OrderHed WHERE (OrderHed.OrderNum = OrdNum) and
(OrderHed.OpenOrder = True) and (OrderHed.Company =
ttShipHead.Company) no-lock:
Run lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE,
'OpenOrder',False).
end.
end.
end.


Hope this is of some help.

Nigel.


--- In vantage@yahoogroups.com, "Michael McWilliams"
<mmcwilliams22@...> wrote:
>
> We are a make to orders hop, & each order Line is a Job. Many of
our
> jobs are for quantities of 10k or more. Most of the time they ship
up
> to 10% short. I am trying to figure out a way to autmatically
close
> an order if it is shipped within 10% of the ordered quantity.
>
I will give a try. Thanks..

In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> Hi Michael,
>
> I have a BPM that closes a sales order upon shipping. It doesn't
do
> any checks, it just closes - we don't keep back orders - but you
> should be able to adapt the code to do what you need.
>
> It's a post-processing directive setup on the CustShip.Update BO.
>
> Condition: number of rows in the <query> is equal to 1
> query: for each ttShipHead where ReadyToInvoice=True and
> CheckBox01=True
> (CheckBox01 is used by us to check if this customer accepts
> backorders.)
>
> Action: execute the following 4GL code
> code:
>
> find first ttShipHead where ttShipHead.ShipStatus="Shipped" no-
lock
> no-error.
> if available ttShipHead then do:
> find first ShipDtl where ShipDtl.Company=ttShipHead.Company and
> ShipDtl.PackNum=ttShipHead.PackNum.
> if available ShipDtl then do:
> DEFINE VARIABLE OrdNum AS INTEGER NO-UNDO.
> OrdNum = 0.
> OrdNum = ShipDtl.OrderNum.
> FOR EACH OrderRel WHERE (OrderRel.OrderNum = OrdNum) and
> (OrderRel.OpenRelease = True) and (OrderRel.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE,
> 'OpenRelease',False).
> end.
>
> FOR EACH OrderDtl WHERE (OrderDtl.OrderNum = OrdNum) and
> (OrderDtl.OpenLine = True) and (OrderDtl.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE,
> 'OpenLine',False).
> end.
>
> FOR EACH OrderHed WHERE (OrderHed.OrderNum = OrdNum) and
> (OrderHed.OpenOrder = True) and (OrderHed.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE,
> 'OpenOrder',False).
> end.
> end.
> end.
>
>
> Hope this is of some help.
>
> Nigel.
>
>
> --- In vantage@yahoogroups.com, "Michael McWilliams"
> <mmcwilliams22@> wrote:
> >
> > We are a make to orders hop, & each order Line is a Job. Many
of
> our
> > jobs are for quantities of 10k or more. Most of the time they
ship
> up
> > to 10% short. I am trying to figure out a way to autmatically
> close
> > an order if it is shipped within 10% of the ordered quantity.
> >
>
I have had this working for a bit now just closing as we ship. Now I need to start with the actual validation of quantities. I am trying to access some fields like ttShipDtl.OurRemainQty(not an actual ShipDtl field only in the temp table)
So when defining the variables I have
DEFINE VARIABLE RemQty AS INTEGER NO-UNDO.
RemQty = ttShipDtl.OurRemainQty.


but at that point the ttShipDtl is not available.
Where should I define it so that I can check every ttShipDtl to see the remaining quantity & if it is under say 100 then process & close the order line/release?

--- In vantage@yahoogroups.com, "Nigel Kerley" <nigel.kerley@...> wrote:
>
> Hi Michael,
>
> I have a BPM that closes a sales order upon shipping. It doesn't do
> any checks, it just closes - we don't keep back orders - but you
> should be able to adapt the code to do what you need.
>
> It's a post-processing directive setup on the CustShip.Update BO.
>
> Condition: number of rows in the <query> is equal to 1
> query: for each ttShipHead where ReadyToInvoice=True and
> CheckBox01=True
> (CheckBox01 is used by us to check if this customer accepts
> backorders.)
>
> Action: execute the following 4GL code
> code:
>
> find first ttShipHead where ttShipHead.ShipStatus="Shipped" no-lock
> no-error.
> if available ttShipHead then do:
> find first ShipDtl where ShipDtl.Company=ttShipHead.Company and
> ShipDtl.PackNum=ttShipHead.PackNum.
> if available ShipDtl then do:
> DEFINE VARIABLE OrdNum AS INTEGER NO-UNDO.
> OrdNum = 0.
> OrdNum = ShipDtl.OrderNum.
> FOR EACH OrderRel WHERE (OrderRel.OrderNum = OrdNum) and
> (OrderRel.OpenRelease = True) and (OrderRel.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderRel:HANDLE,
> 'OpenRelease',False).
> end.
>
> FOR EACH OrderDtl WHERE (OrderDtl.OrderNum = OrdNum) and
> (OrderDtl.OpenLine = True) and (OrderDtl.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderDtl:HANDLE,
> 'OpenLine',False).
> end.
>
> FOR EACH OrderHed WHERE (OrderHed.OrderNum = OrdNum) and
> (OrderHed.OpenOrder = True) and (OrderHed.Company =
> ttShipHead.Company) no-lock:
> Run lib\UpdateTableBuffer.p(input BUFFER OrderHed:HANDLE,
> 'OpenOrder',False).
> end.
> end.
> end.
>
>
> Hope this is of some help.
>
> Nigel.
>
>
> --- In vantage@yahoogroups.com, "Michael McWilliams"
> <mmcwilliams22@> wrote:
> >
> > We are a make to orders hop, & each order Line is a Job. Many of
> our
> > jobs are for quantities of 10k or more. Most of the time they ship
> up
> > to 10% short. I am trying to figure out a way to autmatically
> close
> > an order if it is shipped within 10% of the ordered quantity.
> >
>