update vs4tpomb set tpobtotaldelivery=(select sum(tpdetotaldelivery) from vs4tpodelivery where tpdetpobtpodno=tpobtpodno and tpdetpobln=tpobln)
update vs4tpomb set tpobtotaldelivery2=(select sum(tpdetotaldelivery2) from vs4tpodelivery where tpdetpobtpodno=tpobtpodno and tpdetpobln=tpobln)
update vs4tpomb set tpobtotaldelivery3=(select sum(tpdetotaldelivery3) from vs4tpodelivery where tpdetpobtpodno=tpobtpodno and tpdetpobln=tpobln)
update vs4tpomb set tpobtotalarrear=tpobquantity-tpobtotaldelivery
update vs4tpomb set tpobtotalarrear2=tpobquantity2-tpobtotaldelivery2
update vs4tpomb set tpobtotalarrear3=tpobquantity3-tpobtotaldelivery3

update vs4tsomb set TSOBtotaldelivery=(select sum(TMDStotaldelivery) from vs4TSOMDS where TMDSTSOBTSODno=TSOBTSODno and TMDSTSOBln=TSOBln)
update vs4tsomb set TSOBtotaldelivery2=(select sum(TMDStotaldelivery2) from vs4TSOMDS where TMDSTSOBTSODno=TSOBTSODno and TMDSTSOBln=TSOBln)
update vs4tsomb set TSOBtotaldelivery3=(select sum(TMDStotaldelivery3) from vs4TSOMDS where TMDSTSOBTSODno=TSOBTSODno and TMDSTSOBln=TSOBln)
update vs4tsomb set TSOBtotalarrear=TSOBquantity-TSOBtotaldelivery
update vs4tsomb set TSOBtotalarrear2=TSOBquantity2-TSOBtotaldelivery2
update vs4tsomb set TSOBtotalarrear3=TSOBquantity3-TSOBtotaldelivery3