Sage 100

 View Only
  • 1.  Script to step through tier lines.on a PO ROG and update the an UDF on the tief lines

    Posted 04-16-2019 14:48
    I am looking for a script that  would allow the user update an UDF date on a PO ROG header and have it automatically update all the Tier distribution records the corresponding UDF in each lot distribution tiers..

    Anyone do anything like this before?












































































































































































































    of the lot receipt. (Tier distribution) in a Purchase Order ROG. After the date has been entered on the header, the script  would navigate and set the corresponding UDF in  each of the tier distribution. 

    Anyone do something like this?

    Jim

    ------------------------------
    Jim Woodhead
    DSD Business Systems
    619-990-3946
    ------------------------------


  • 2.  RE: Script to step through tier lines.on a PO ROG and update the an UDF on the tief lines

    Posted 04-17-2019 10:16
    I don't have anything exactly like that, but that's certainly do-able.  My gut reaction would be to PostValidate against the Header date, and then ChildHandle the Lines and Lot objects and iterate through them to SetValue the Tier date UDF.  Then you probably want a Table PreWrite that basically does the same thing to make sure any Lines/Lots that were added after the header date was changed would also be updated.  Let me know if you're looking for a specific code snippet...

    ------------------------------
    Steve Iwanowski, NextStep Technology Advisors, aka DSD Lancaster PA ¯\_(ツ)_/¯
    ------------------------------



  • 3.  RE: Script to step through tier lines.on a PO ROG and update the an UDF on the tief lines

    Posted 04-18-2019 01:41
    Certainly doable but i'm not sure i see any benefit in triggering the script on the post validate of the udf in the event they cancel the changes anyway. I think it would be more efficient to just do it in the header table pre write event unless you do post validate on the header udf and a pre write on the tier table.

    Regardless of how you trigger it, here is a snippet from the header object's perspective. I don't have any notes added as it is pretty simple and straightforward but if you have any questions, ask away. This snippet was recycled from another project and has the lines to get and set the value for "UDF_Date$", change the column name to match yours.
    Dim sValidItemTypes
    Dim sValidItemValuations
    Dim oPO_Receipt_Bus
    Dim oPO_ReceiptDetail_Bus
    Dim sUDF_Date
    Dim sItemCode
    Dim sItemType
    Dim sItemValuation
    Dim nPO_ReceiptTierDistribution_Bus
    Dim oPO_ReceiptTierDistribution_Bus
    
    sValidItemTypes = """1"""
    sValidItemValuations = """5"",""6"""
    Set oPO_Receipt_Bus = oBusObj
    Set oPO_ReceiptDetail_Bus = oSession.AsObject(oPO_Receipt_Bus.Lines)
    If Not(CBool(oPO_ReceiptDetail_Bus.BoF And oPO_ReceiptDetail_Bus.EoF)) Then
    	sUDF_Date = "" : oPO_Receipt_Bus.GetValue "UDF_Date$", sUDF_Date
    	oPO_ReceiptDetail_Bus.MoveFirst
    	Do Until CBool(oPO_ReceiptDetail_Bus.EoF)
    		sItemCode = "" : oBusObj.GetValue "ItemCode$", sItemCode
    		If sItemCode <> "" Then
    			sItemType = "" : oBusObj.GetValue "ItemType$", sItemType
    			If CBool(InStr(sValidItemTypes, """" & sItemType & """") > 0) Then
    				sItemValuation = "" : oBusObj.GetValue "Valuation$", sItemValuation
    				If CBool(InStr(sValidItemValuations, """" & sItemValuation & """") > 0) Then
    					nPO_ReceiptTierDistribution_Bus = 0 : nPO_ReceiptTierDistribution_Bus = oPO_ReceiptDetail_Bus.Distribution
    					If nPO_ReceiptTierDistribution_Bus > 0 Then
    						Set oPO_ReceiptTierDistribution_Bus = oSession.AsObject(nPO_ReceiptTierDistribution_Bus)
    						If Not(CBool(oPO_ReceiptTierDistribution_Bus.BoF And oPO_ReceiptTierDistribution_Bus.EoF)) Then
    							oPO_ReceiptTierDistribution_Bus.MoveFirst
    							Do Until CBool(oPO_ReceiptTierDistribution_Bus.EoF)
    								oPO_ReceiptTierDistribution_Bus.SetValue "UDF_Date$", sUDF_Date
    								oPO_ReceiptTierDistribution_Bus.Write
    								oPO_ReceiptTierDistribution_Bus.MoveNext
    							Loop
    						End If
    						Set oPO_ReceiptTierDistribution_Bus = Nothing
    					End If
    				End If
    			End If
    		End If
    		oPO_ReceiptDetail_Bus.MoveNext
    	Loop
    End If
    Set oPO_ReceiptDetail_Bus = Nothing
    Set oPO_Receipt_Bus = Nothing
    ​


    ------------------------------
    David Speck II
    Tennessee Software Solutions
    ------------------------------