Syspro - 更新销售价格查询

时间:2015-10-02 09:59:02

标签: sql sql-server

我似乎无法找到有关Syspro的SQL脚本的任何信息 - 尽管Syspro使用了一个相当标准的SQL数据库,谷歌搜索只是提出了第三方软件。

我只是想知道这里是否有人有通过SQL更新更新Syspro的经验 - 我有一个使用Syspro的客户端,他们之前通过将所有内容导出到Access中进行更新,进行更改和更新从那里开始的一切 - 他们的外部IT顾问告诉我,这是更新Syspro的唯一方法(我怀疑,这不是真的)。​​

在我搞砸数据之前,只是寻找一些不做的事情!

谢谢,

的Darren

1 个答案:

答案 0 :(得分:1)

不建议直接更新SYSPRO数据库。虽然分解和跟踪哪些数据存储在哪里等相对简单,但是更新字段的位置通常不超过1个和/或还有更改的附加标志。此外,直接在数据库中更新它也可以摆脱任何可能的审计跟踪。

如果需要批量完成(正如您的问题似乎可以参考)那么最好通过使用其中一个SYSPRO“业务对象”发布更新来完成。有关业务对象的更多信息,请查看此处:SYSPRO Business Object Library

有两种方法可以使用它:在SYSPRO中的自定义窗格中(当时没有许可要求)或者如果您的客户获得相应业务对象的许可,您可以编写外部程序以使用业务对象发布更新

下面是我之前创建的自定义窗格,它根据Excel电子表格更新商品的价格。将以下代码部分保存到txt文件中,当在SYSPRO中时,如果单击下拉箭头(在任何窗格的右上角),则可以选择自定义窗格>导入自定义窗格并指定您保存的此txt文件。这将创建标题为价格表导入的自定义窗格。如果您现在按下此自定义窗格上的刷新按钮,它将要求您提供excel文件以使其更新。默认情况下,它会在您正在使用的计算机的 SYSPRO \ Base \ Settings 文件夹中查找名为 Pricelist Import.xlsx 的文件。您还需要创建一个包含5列的电子表格,并按此顺序创建(StockCode,PriceCode,SellingPrice,PriceBasis,CommisionCode)。获得电子表格并在此提示符处指定文件后,它会将电子表格的内容加载到列表视图中,默认情况下将选择所有条目进行导入。如果您现在按更新,它将相应地更新价格,如果不可能,则会将相应的错误消息返回到列表视图中。

# Customized Panes for 'IMPDH2LZ' Created: 2013/09/17
# PANE:Pricelist Import
[PANE]
CHRISVIMPDH2LZ    01000Pricelist Import                                                                                    020                                                                                                                                                                                                                                                               000000500001IMPDH2000M000Update              3362                    00000                          0
[VBSCRIPT]
' This script contains functions for customized pane events.
' You must not modify the name of the functions.
Option Explicit

Public Debug : Debug = "False"

Function CustomizedPane_OnRefresh()
        Dim ImportFilePmt : ImportFilePmt = InputBox("Enter Location of Excel file to Import?",  "Pricelist Import File", SystemVariables.CodeObject.baseSettingsFolder &"Pricelist Import.xlsx")
        Dim objExcel : Set objExcel = CreateObject("Excel.Application")
        On error resume next
        Dim objWorkbook : Set objWorkbook = objExcel.Workbooks.Open(ImportFilePmt)
        If err then
            If ImportFilePmt <> "" then
            msgbox "Error Importing File: " & vbcrlf & err.Description & vbCrlf & vbCrlf & "Import Cancelled!!", vbCritical, "Error Importing/Opening File"
            Exit Function
            Else
            CustomizedPane_OnLoad
            Exit Function
            End If
        End if
        on error Goto 0
        Dim objWorksheet : Set objWorksheet = objExcel.Worksheets(1)
        objWorksheet.Activate
        Dim intRow : intRow = 2

        Dim XMLForList

        Dim intLinesRow : intLinesRow = 2
        XMLForList = "<ImportList>"
        Do Until objExcel.Cells(intLinesRow,1).Value = "" or objExcel.Cells(intLinesRow,1).Value = " "
            XMLForList = XMLForList & "<Item><StockCode>"& objExcel.Cells(intLinesRow, 1).Value &"</StockCode>"
            XMLForList = XMLForList & "<PriceCode>" & objExcel.Cells(intLinesRow,2).Value & "</PriceCode>"
            XMLForList = XMLForList & "<SellingPrice>" & objExcel.Cells(intLinesRow,3).Value & "</SellingPrice>"
            XMLForList = XMLForList & "<PriceBasis>" & objExcel.Cells(intLinesRow,4).Value & "</PriceBasis>"
            XMLForList = XMLForList & "<CommisionCode>" & objExcel.Cells(intLinesRow,5).Value & "</CommisionCode>"
            XMLForList = XMLForList & "<Import>1</Import>"
            XMLForList = XMLForList & "</Item>"
            intLinesRow = intLinesRow + 1
            Loop
        XMLForList = XMLForList & "</ImportList>"
        objExcel.Quit

        Dim ListXML
        ListXML = ListXML & "<Columns PrimaryNode='Item' Style='DataGrid' AutoSize='true' FreezeColumn='0' >"
        ListXML = ListXML & "<Column Name='StockCode' Description='Stock code' />"
        ListXML = ListXML & "<Column Name='PriceCode' Description='Price code' />"
        ListXML = ListXML & "<Column Name='SellingPrice' Description='Selling price' Type='Numeric' Alignment='Right' HdrAlignment='Right' Decimals='2' />"
        ListXML = ListXML & "<Column Name='PriceBasis' Description='Price basis' />"
        ListXML = ListXML & "<Column Name='CommisionCode' Description='Commision code' />"
        ListXML = ListXML & "<Column Name='Import' Description='Import' Type='checkbox' Editable='true' />"
        ListXML = ListXML & "</Columns>"
        CustomizedPane.CodeObject.ListviewProperties = ListXML
        CustomizedPane.CodeObject.ListviewData = XMLForList
        msgbox intLinesRow - 2 & " record/s read",vbInformation,"File Imported"
End Function

Function FileHandle(Action, ActVariable)
Dim Path : Path = SystemVariables.CodeObject.baseSettingsFolder & "ExcelImportPanePath.txt"
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

dim fso, ts
Set fso = CreateObject("Scripting.FileSystemObject")
If Action = "WritePath" then
        Set ts = fso.CreateTextFile(Path,2,False)
        ts.Write (ActVariable)
        ts.Close
Elseif Action = "DeletePath" then
                Set ts = fso.OpenTextFile(Path,1)
                Dim FilePathDP : FilePathDP = ts.ReadAll
                ts.Close
                fso.DeleteFile FilePathDP
Elseif Action = "ReadPath" then
                on error Resume Next
                Set ts = fso.OpenTextFile(Path,ForReading)
                Dim strLine
                Do Until ts.AtEndOfStream
                        strLine = ts.ReadLine
                Loop
                ts.close
                if Err then
                        FileHandle = "File Deleted"
                Else
                        FileHandle = strLine
                End if
                On Error Goto 0
Elseif Action = "Delete" then
                On Error Resume Next
                fso.DeleteFile Path
                If err then
                Exit Function
                End if
                On Error Goto 0
End if
End Function

Function CustomizedPane_OnLoad()
        Dim ListXML
        ListXML = ListXML & "<Columns PrimaryNode='Notify' Style='DataGrid' AutoSize='true' FreezeColumn='0' >"
        ListXML = ListXML & "<Column Name='Note' Description='NOTE' />"
        ListXML = ListXML & "</Columns>"
        CustomizedPane.CodeObject.ListviewProperties = ListXML

        Dim ShowNote
        ShowNote = "<Start>"
        ShowNote = ShowNote & "<Notify><Note>First Load the Excel File Path...</Note></Notify>"
        ShowNote = ShowNote & "</Start>"
        CustomizedPane.CodeObject.ListviewData = ShowNote
End Function

Function CustomizedPane_OnToolbarButton1Clicked()
    Dim MaxRows : MaxRows = Ubound(CustomizedPane.CodeObject.Array, 2)
    If MaxRows = 0 OR CustomizedPane.CodeObject.Array(0,0) = "First Load the Excel File Path..." then
        Exit Function
    Else
        Dim Counter
        Dim CLineCounter : CLineCounter = 0
        For Counter = 0 to MaxRows - 1
            If CustomizedPane.CodeObject.Array(5, Counter) = "1" then
                                CLineCounter = CLineCounter + 1
            End If
        Next
                If CLineCounter = 0 then
                        msgbox "There was nothing selected to import.",vbInformation,"Importing..."
                        Exit Function
                Else
                msgbox CLineCounter & " record/s to be updated.",vbInformation,"Importing..."
                CallINVSPR
                End If
    End If
End Function

Function CallINVSPR()
        dim XMLOut, XMLParam, XMLDoc

        XMLParam = "<SetupInvPrice>"
        XMLParam = XMLParam & "  <Parameters>"
        XMLParam = XMLParam & "    <IgnoreWarnings>N</IgnoreWarnings>"
        XMLParam = XMLParam & "    <ApplyIfEntireDocumentValid>Y</ApplyIfEntireDocumentValid>"
        XMLParam = XMLParam & "    <ValidateOnly>N</ValidateOnly>"
        XMLParam = XMLParam & "  </Parameters>"
        XMLParam = XMLParam & "</SetupInvPrice>"

        XMLDoc = " <SetupInvPrice>"
        Dim MaxRows : MaxRows = Ubound(CustomizedPane.CodeObject.Array, 2)
        Dim Counter
        Dim LineCounter : LineCounter = 0
        Dim CLineCounter : CLineCounter = 0
        For Counter = 0 to MaxRows - 1
                If CustomizedPane.CodeObject.Array(5, Counter) = "1" then
                    XMLDoc = XMLDoc & "   <Item>"
                    XMLDoc = XMLDoc & "     <Key>"
                    XMLDoc = XMLDoc & "       <StockCode>" & CustomizedPane.CodeObject.Array(0, Counter) & "</StockCode>"
                    XMLDoc = XMLDoc & "       <PriceCode>" & CustomizedPane.CodeObject.Array(1, Counter) & "</PriceCode>"
                    XMLDoc = XMLDoc & "     </Key>"
                    XMLDoc = XMLDoc & "     <SellingPrice>" & CustomizedPane.CodeObject.Array(2, Counter) & "</SellingPrice>"
                    XMLDoc = XMLDoc & "     <PriceBasis>" & CustomizedPane.CodeObject.Array(3, Counter) & "</PriceBasis>"
                    XMLDoc = XMLDoc & "     <CommissionCode>" & CustomizedPane.CodeObject.Array(4, Counter) & "</CommissionCode>"
                    XMLDoc = XMLDoc & "   </Item>"
                    CLineCounter = CLineCounter + 1
            End If
        Next
        XMLDoc = XMLDoc & " </SetupInvPrice>"
        on error resume next
        XMLOut = CallSetup("INVSPR",XMLParam,XMLDoc,"Update","auto")
        if err then
          msgbox err.Description, vBCritical, "Calling Business Object"
          exit function
        end if
        ' Switch on error handling
        on error goto 0
        'msgbox CLineCounter & " rows updated"

        If Debug = "True" then
                Dim Path : Path = SystemVariables.CodeObject.baseSettingsFolder & "DEBUGExcelImportPane.txt"
                'Output XML to file
                dim fso, ts
                Set fso = CreateObject("Scripting.FileSystemObject")
                Set ts = fso.CreateTextFile(Path,2,True)
                ts.Write ("XMLIn:" & vbCrlf & XMLDoc & vbCrlf &"XMLParam:" & vbCrlf & XMLParam & vbCrlf &"XMLOut:" & vbCrlf & XMLOut)
                ts.Close
                msgbox "Debug Done." & vbCrLf & " Check: "& Path
        End If
        ResultValidate XMLOut, "Update", CLineCounter
End Function

Function ResultValidate(XMLIn, Action, CLineCounter)
        Dim XMLDOM : Set XMLDOM = CreateObject("Microsoft.XMLDOM")
        XMLDOM.Async = False
        XMLDOM.LoadXML(XMLIn)
        Dim ListXML

        Dim WarningMsgs : Set WarningMsgs = XMLDOM.GetElementsByTagName("ErrorDescription")
        Dim StkList
        If WarningMsgs.Length > 0 then
            StkList = "<List>"
            StkList = StkList & "<StockList>"
                StkList = StkList & "<Notes>Errors Found: " & WarningMsgs.Length & "</Notes>"
                StkList = StkList & "</StockList>"
            If WarningMsgs.Length > 0 then
                Dim WarnItems
                For Each WarnItems in WarningMsgs
                    StkList = StkList & "<StockList>"
                    StkList = StkList & "<Notes>Error in : " & WarnItems.ParentNode.NodeName & " - " & WarnItems.PreviousSibling.PreviousSibling.Text & ": " & WarnItems.Text &"</Notes>"
                    StkList = StkList & "</StockList>"
                Next
            End If
            StkList = StkList & "</List>"
            ListXML = "<Columns PrimaryNode='StockList' Style='DataGrid' AutoSize='true' FreezeColumn='0' >"
            ListXML = ListXML & "<Column Name='Notes' Description='Notes' Link='false' />"
            ListXML = ListXML & "</Columns>"
        else
            StkList = "<List>"
            StkList = StkList & "<StockList>"
            StkList = StkList & "<Notes>No Errors Found..." & CLineCounter & " record/s updated</Notes>"
            StkList = StkList & "</StockList>"
            StkList = StkList & "</List>"
            ListXML = "<Columns PrimaryNode='StockList' Style='DataGrid' AutoSize='true' FreezeColumn='0' >"
            ListXML = ListXML & "<Column Name='Notes' Description='Notes' Link='false' />"
            ListXML = ListXML & "</Columns>"
        End If
        CustomizedPane.CodeObject.ListviewProperties = ListXML
        CustomizedPane.CodeObject.ListviewData = StkList
End Function

也许如果他们有一家测试公司先在那里尝试一下,那么你可以看看它在做什么?

NB:这是针对SYSPRO 6.1和7完成的。可能需要进行少量更新才能使其在其他版本中运行。
您还可以查看SYSPRO Forums以获取与相关的帮助。

希望这有帮助。