Sage 100

Expand all | Collapse all

Delete PO automatically

  • 1.  Delete PO automatically

    Posted 05-10-2019 14:51
    Customer wants me to export Inventory data out of one company and import as a new PO into another company every night. We need to delete the existing PO and import a new PO with the latest data from the other company. I have no problem with automating the Export/Import every night but  how do i delete the PO from the previous day prior to starting the import. Is there a way to automatically delete a PO number (it will be the same PO number) either in VI Perform Logic or a Script that kicks in at a specific time prior to the import. TIA

    ------------------------------
    Kenny Daniel
    Technoclarity, Inc.
    ------------------------------


  • 2.  RE: Delete PO automatically

    Posted 05-10-2019 16:16
    Edited by Alnoor Cassim 05-10-2019 16:53
    ** EDIT ** Added @Michelle Taylor 's important note a PO can't be re-used if already deleted before and you have Retain Deleted POs turned on in P/O Options.
    __________________________________

    Hi Kenny - Since you know the PO Number, yes you can have Perform Logic run on the Job Execution (meaning Job Start) event that will delete the existing PO then the rest of the import will run where presumably you have ASSIGNed the same PO Number in the import job. I can post a sample if you like. The only issue will be if the PO can't be deleted for some reason (e.g. it's in a Rcpt of Goods / Invoice batch OR it's already marked in History as Deleted b/c you have Retain Deleted POs turned on and can't re-use it), errors would appears in the Job Log during the import. If email notification on errors is relevant for you this could be worth checking out - Email Alerts for VI

    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 3.  RE: Delete PO automatically

    Posted 05-10-2019 16:36
    Just keep in mind that with History enabled in PO to retain deleted entries, you can't reuse a deleted PO Number.

    ------------------------------
    Michelle Taylor
    ERP Team Manager, CS3 Technology
    918-388-9772
    ------------------------------



  • 4.  RE: Delete PO automatically

    Posted 05-10-2019 16:47
    I was pondering PO History with this.  I wonder if a script, (triggered by a header UDF for import date, column post validate?) to delete existing PO lines, might be better than deleting the entire PO.  If something fails (like a Purchases Clearing issue on a line), it might at least clean up the rest.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 5.  RE: Delete PO automatically

    Posted 05-10-2019 16:58
    Most interesting idea Kevin. Yeah it could be Script or Perform Logic but either way it does need to add back at least one line for it to save. Maybe that could be a /C line which could then be removed by separate Script or Perform Logic that runs when the job completes.

    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 6.  RE: Delete PO automatically

    Posted 05-10-2019 17:01
    Presumably the new lines added by the import would suffice.  You wouldn't Write() on the header script, just delete the old lines... then the import would add new ones and save as normal (including the deletions). 
    Completely untested of course... just pondering possibilities.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 7.  RE: Delete PO automatically

    Posted 05-11-2019 15:28
    They do not keep deleted PO history so that’s not a concern. @Kevin Moyes I’m still not sure what you mean by activate a script via a UDF. We can delete the whole PO or just the lines but how do I trigger it? Thanks for all your help.

    ---------------------------------
    Kenny Daniel
    Technoclarity, Inc.
    ---------------------------------





  • 8.  RE: Delete PO automatically

    Posted 05-13-2019 03:19
    Kenny - Kevin is just saying scripts can also interact with V/I jobs to delete the PO or delete the existing lines on the PO because they also execute at the business object level. This is a very good approach if you don't deal in ProvideX or want to avoid it.

    Having said that here is the quick Perform Logic you could use to delete a PO so long as Retain Deleted POs in History is not enabled. Click on the Perform button in Import Job Maintenance and make it look like this:



    Here is full Command line. Replace "0000017" with the actual PO number.
    The NOT(cTest) means don't run if you pressed the Test button.

    IF NOT(cTest) {coBusiness'SetKey("0000017");coBusiness'Delete()}

    Since this can be done with a single line of code (albeit multiple statements) we don't need to point it to a separate file / program. Thank you @David Speck II for reminding me of that on your Sage City post.


    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 9.  RE: Delete PO automatically

    Posted 05-13-2019 11:49
    Thank you @Alnoor Cassim and @Kevin Moyes. This is amazing. I just want to know how and where you guys learn all this magic and why I wasn’t invited 😀.Thanks again

    ---------------------------------
    Kenny Daniel
    Technoclarity, Inc.
    ---------------------------------





  • 10.  RE: Delete PO automatically

    Posted 05-13-2019 09:23
    Create a UDF in the header table, and set a script to run column Post-Validate.  Import the system date into that field as part of your job... but Alnoor's PL seems easier to set up.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 11.  RE: Delete PO automatically

    Posted 05-14-2019 11:44
    @Alnoor Cassim, are you referring to my recent post on how to delete price code records with a VI import?

    I found out that you could use a an "!" In the perform logic command to Execute a statement by looking a compiled VI import job with the basic providex ide. Saw how it looks for different characters in the perform value to do different actions.

    When I get a chance, i'll post more in detail about the different actions it recognizes. ​

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



  • 12.  RE: Delete PO automatically

    Posted 05-15-2019 00:52
    Alright, so here is a breakdown of how framework VI perform logic is handled.

    If the logic starts with "*" (asterisk) then the logic will have the ProvideX SYS function called against it. This is similar to VBScript's Shell.Run method. See this link for more detail. https://manual.pvxplus.com/PXPLUS/functions/sys.htm

    If the logic starts with a "~" (tilde) then the logic will be supplied as an argument to the called program "..\SOA\SYZDLL;SHELL_AND_WAIT" which is another way to execute a program. I'm not certain on the pros and cons between this and the SYS function (which is similar to the INVOKE directive) but perhaps @Alnoor Cassim can provide insight.​​

    If the logic contains a "'" (apostrophe) then the logic is execute as a ProvideX statement. See the "Statement" section at this link for more detail. https://manual.pvxplus.com/PXPLUS/PxPlus%20User%20Guide/Language%20Elements/Directives,%20Statements%20and%20Programs/Overview.htm

    If the logic doesn't meet any of the above criteria and it is not blank, then the logic will be "PERFORMED". See this link for more detail. https://manual.pvxplus.com/PXPLUS/directives/perform.htm

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



  • 13.  RE: Delete PO automatically

    Posted 05-15-2019 01:39
    Edited by Alnoor Cassim 05-15-2019 01:40
    Great share David. For some reason I had compartmentalized this info in the past as only applying to Job Execution and Job Completion but of course that's not true. Give me a few days as I'm going to tied up but I'll start a new thread and to the best of my knowledge explain the difference between ProvideX functions like:

    • INVOKE (and its variations) 
    • SYS - one does cmd.exe /c the other cmd.exe /k
    • SYSTEM_HELP (I call it an old friend. Ideal for popping open a log file in Notepad, a PDF in Acro Reader, things like that. Always runs from the CLIENT side even on Adv and Premium. It's the closest equivalent to WScript.Run in VBScript.
    and calls to Windows functions like:

    • SYZDLL;Shell_And_Wait (uses Sage's MasExt32.dll as a hook to Kernel32 and User32 calls to run o/s commands and keep dependent windows open)
    • DLX() calls to Kernel32 functions such as CopyFileA (for copying files)  



    ------------------------------
    Alnoor Cassim

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 14.  RE: Delete PO automatically

    Posted 10-21-2019 14:59

    Related to this thread​, I have a similar situation in v2017 where we'd like the ability to delete certain sales orders during a VI import, because we need to re-import the ones that have changed in the client's custom/source system (we can't just change them in Sage 100, we can't just re-import because the changes will likely include line item changes, we're not importing sales order #).  Is this feasible with Perform Logic / Scripting?  Also, since we're using 'Next' for the sales order # during the import, the 'deletion' would be controlled via the UDF data/column in the import source file.  So basically for that UDF data, we want the import to search all of S/O Entry (i.e. UDF field), and if found, delete that order.  (@Alnoor Cassim@David Speck II, @Kevin Moyes: re: your postings; and others of course​​​)

    ​​​​​​​​

    ------------------------------
    - Brett
    ------------------------------



  • 15.  RE: Delete PO automatically

    Posted 10-21-2019 15:20
    Quick thoughts: Header post-write script, take your UDF value and open a new business object to delete the old SO (exempting the new / current SO).  Filter to a specific VI job, so you don't cause chaos.

    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 16.  RE: Delete PO automatically

    Posted 10-23-2019 17:11

    Thanks, @Kevin Moyes!!  In the past we've had problems with that method and the 'delete' was unsuccessful and threw errors, but we'll give it another whirl.  Would love your further thoughts on the following if you have a chance:

    Wondering if we'd run into a performance issue with this.  The client's S/O Entry is rather large (13k+ records for the import routine to constantly churn thru as it looks for the applicable orders to delete) and therefore it's possible that could slow things down considerably even though we're planning to set the import to run automatically in the background (every 10 minutes).  So there's a chance that could have a performance impact on other users in S/O Entry and/or elsewhere in Sage 100, as well as likely needing a given import to finish before it next runs (i.e. if a given import takes longer than 10 minutes to run); I suppose we have the option to potentially purge/archive a good portion of S/O Entry.  Also, do you know if the 'On SO' bucket in inventory will be properly reflected when deleting sales orders in this manner?


      ​​

    ------------------------------
    - Brett
    ------------------------------



  • 17.  RE: Delete PO automatically

    Posted 10-23-2019 17:35
    OnSO, no idea.
    For performance, you don't really have options in a pure BOI script unless there is a index to set a browse filter.  A UDF won't have that, but if you used something like CustomerPONo, you could avoid looping through the entire table.

    Otherwise, pre-process the input file though an external VBScript with ODBC query where you can simply Select the row you want when searching for the SO#.


    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------