Skip to Content
author's profile photo Former Member
Former Member

Purchase Order Coding

Hi All,

iam developing a webservice using DI-server in my asp.net application to access my sap company DB.now i have to create a purchase order...can anybody give me some web service coding about how to create a purchase order.....(like creating new customers & updating them...)

Regads,

Shangai.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 02, 2008 at 01:32 AM

    Hi Shangai

    Please ensure that you use the same Patch Level for the SBO client,

    DI Server and the DI API.

    First, to ensure you are not using cached versions of the DI Server and

    the DI API, please do the following:

    1. Locate the Temp folder by going to Start -> Run and type %temp%.

    2. Locate the SM_OBS_DLL folder and delete it.

    Then,retry the action.

    Also,please check the Patch Level versions:

    1. SBO Client

    2. DI Server

    - Start -> Run and type %temp%

    - Go to that path, and in the directory SM_OBS_DLL\680320\.

    - Right click on the OBSServerDLL.dll file and select Properties >

    Version > Special Build Description.

    3. DI API

    -Go to DI API install directory. Default location:

    "C:\Program Files\SAP\SAP Business One DI API\DI API 2005"

    - Right click on the SAPbobsCOM2005.dll file select Properties > Version> Special Build Description.

    Regards,

    Syn Qin

    SAP Business One Forums Team

    Edited by: Syn Qin on Jul 2, 2008 3:32 AM

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi syn,

      iam using a webservice for making transactions through DI-Server....in that iam creating a sales order like....

      
       <WebMethod()> Public Function AddJV(ByVal SessionID As String) As Xml.XmlDocument  'ByVal xmlJVObject As String
       
              Dim n As SBODI_Server.Node
              Dim s, sCmd As String
              Dim d As Xml.XmlDocument
       
              d = New Xml.XmlDocument
              n = New SBODI_Server.Node
       
       
              sCmd = "<?xml version=""1.0"" encoding=""UTF-16""?> "
              sCmd += "<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/""> "
              sCmd += " <env:Header> "
              sCmd += "<SessionID>" & CStr(SessionID) & "</SessionID>"
              sCmd += " </env:Header> "
              sCmd += " <env:Body> "
              sCmd += "<dis:AddObject xmlns:dis=""http://www.sap.com/SBO/DIS"" > "
              sCmd += "<BOM>"
              sCmd += "<BO>"
              sCmd += "<AdmInfo>"
              sCmd += "<Object>oOrders</Object> "
              sCmd += "</AdmInfo> "
              sCmd += "<QueryParams>"
              sCmd += "<DocEntry>11</DocEntry>"
              sCmd += "</QueryParams>"
              sCmd += "<Documents>"
              sCmd += "<row>"
              sCmd += "<DocNum>11</DocNum>"
              sCmd += "<DocDate>20080702</DocDate>"
              sCmd += "<DocDueDate>20080707</DocDueDate>"
              sCmd += "<CardCode>C0009</CardCode>"
              sCmd += "<CardName>Sample</CardName>"
              sCmd += "</row>"
              sCmd += "</Documents>"
              sCmd += "<Document_Lines>"
              sCmd += "<row>"
              sCmd += "<ItemCode>I9999</ItemCode>"
              sCmd += "<ItemDescription>Sample</ItemDescription>"
              sCmd += "<Quantity>2</Quantity>"
              sCmd += "<Price>44.000</Price>"
              sCmd += "</row>"
              sCmd += "</Document_Lines>"
              sCmd += "</BO> "
              sCmd += "</BOM> "
              sCmd += "</dis:AddObject> "
              sCmd += " </env:Body> "
              sCmd += "</env:Envelope> "
       
              s = n.Interact(sCmd)
              d.LoadXml(s)
              Return (RemoveEnv(d))
       
          End Function
      
      

      all is fine it works & it's affecting the SAP db.....in that above command if i want to add a new itemcode into my sales order then i can enter it in a new row.....but how to pass the value from the frontend to this webservice

  • author's profile photo Former Member
    Former Member
    Posted on Jun 24, 2008 at 07:51 AM

    Hi Shangai

    Below is my sample code about how to add a jornal voucher via DIServer.

    You can add a purchase order in the similar way,the only thing need to be changed is

    the SOAP message format.

        ' add journal voucher
        '<WebMethod()> Public Function AddJV(ByVal SessionID As String, _
        '                                    ByVal xmlJVObject As String) As Xml.XmlDocument
    
        <WebMethod()> Public Function AddJV(ByVal SessionID As String) As Xml.XmlDocument
    
            Dim n As SBODI_Server.Node
            Dim s, sCmd As String
            Dim d As Xml.XmlDocument
    
            d = New Xml.XmlDocument
            n = New SBODI_Server.Node
    
    
            sCmd = "<?xml version=""1.0"" encoding=""UTF-16""?> "
            sCmd += "<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/""> "
            sCmd += " <env:Header> "
            sCmd += "<SessionID>" & CStr(SessionID) & "</SessionID>"
            sCmd += " </env:Header> "
            sCmd += " <env:Body> "
            sCmd += "<dis:AddObject xmlns:dis=""http://www.sap.com/SBO/DIS"" > "
            sCmd += "<BOM>"
            sCmd += "<BO>"
            sCmd += "<AdmInfo>"
            sCmd += "<Object>oJournalVouchers</Object> "
            sCmd += "</AdmInfo> "
            sCmd += "<JournalEntries>"
            sCmd += "<Row>"
            sCmd += "<ReferenceDate></ReferenceDate>"
            sCmd += "<Memo>TEST</Memo>"
            sCmd += "<DueDate>20080325</DueDate>"
            sCmd += "</Row>"
            sCmd += "</JournalEntries> "
            sCmd += "<JournalEntries_Lines> "
            sCmd += "<Row>"
            sCmd += "<AccountCode>111101</AccountCode> "
            sCmd += "<Debit>100</Debit>"
            sCmd += "</Row>"
            sCmd += "<Row>"
            sCmd += "<AccountCode>111101</AccountCode>"
            sCmd += "<Credit>100</Credit>"
            sCmd += "</Row>"
            sCmd += "</JournalEntries_Lines>"
            sCmd += "</BO> "
            sCmd += "</BOM> "
            sCmd += "</dis:AddObject> "
            sCmd += " </env:Body> "
            sCmd += "</env:Envelope> "
    
    
            s = n.Interact(sCmd)
            d.LoadXml(s)
            Return (RemoveEnv(d))
    
        End Function

    I posted the xml template format of purchase order here.

      <?xml version="1.0" encoding="utf-8" ?> 
    - <BOM>
    - <BO>
    - <AdmInfo>
      <Object>oDocuments</Object> 
      </AdmInfo>
    - <QueryParams>
      <DocEntry /> 
      </QueryParams>
    - <Documents>
    - <row>
      <DocNum /> 
      <DocType /> 
      <HandWritten /> 
      <Printed /> 
      <DocDate /> 
      <DocDueDate /> 
      <CardCode /> 
      <CardName /> 
      <Address /> 
      <NumAtCard /> 
      <DocCurrency /> 
      <DocRate /> 
      <DocTotal /> 
      <Reference1 /> 
      <Reference2 /> 
      <Comments /> 
      <JournalMemo /> 
      <PaymentGroupCode /> 
      <DocTime /> 
      <SalesPersonCode /> 
      <TransportationCode /> 
      <Confirmed /> 
      <ImportFileNum /> 
      <SummeryType /> 
      <ContactPersonCode /> 
      <ShowSCN /> 
      <Series /> 
      <TaxDate /> 
      <PartialSupply /> 
      <DocObjectCode /> 
      <ShipToCode /> 
      <Indicator /> 
      <FederalTaxID /> 
      <DiscountPercent /> 
      <PaymentReference /> 
      <Form1099 /> 
      <Box1099 /> 
      <RevisionPo /> 
      <RequriedDate /> 
      <CancelDate /> 
      <BlockDunning /> 
      <Pick /> 
      <PaymentMethod /> 
      <PaymentBlock /> 
      <PaymentBlockEntry /> 
      <CentralBankIndicator /> 
      <MaximumCashDiscount /> 
      <Project /> 
      <ExemptionValidityDateFrom /> 
      <ExemptionValidityDateTo /> 
      <WareHouseUpdateType /> 
      <Rounding /> 
      <ExternalCorrectedDocNum /> 
      <InternalCorrectedDocNum /> 
      <DeferredTax /> 
      <TaxExemptionLetterNum /> 
      <AgentCode /> 
      <NumberOfInstallments /> 
      <ApplyTaxOnFirstInstallment /> 
      <VatDate /> 
      <DocumentsOwner /> 
      <FolioPrefixString /> 
      <FolioNumber /> 
      <DocumentSubType /> 
      <BPChannelCode /> 
      <BPChannelContact /> 
      <Address2 /> 
      <PayToCode /> 
      <ManualNumber /> 
      <UseShpdGoodsAct /> 
      <IsPayToBank /> 
      <PayToBankCountry /> 
      <PayToBankCode /> 
      <PayToBankAccountNo /> 
      <PayToBankBranch /> 
      <BPL_IDAssignedToInvoice /> 
      <DownPayment /> 
      <LanguageCode /> 
      <TrackingNumber /> 
      <PickRemark /> 
      <ClosingDate /> 
      <SequenceCode /> 
      <SequenceSerial /> 
      <SeriesString /> 
      <SubSeriesString /> 
      <SequenceModel /> 
      <UseCorrectionVATGroup /> 
      <VatPercent /> 
      </row>
      </Documents>
    - <Document_Lines>
    - <row>
      <LineNum /> 
      <ItemCode /> 
      <ItemDescription /> 
      <Quantity /> 
      <ShipDate /> 
      <Price /> 
      <PriceAfterVAT /> 
      <Currency /> 
      <Rate /> 
      <DiscountPercent /> 
      <VendorNum /> 
      <SerialNum /> 
      <WarehouseCode /> 
      <SalesPersonCode /> 
      <CommisionPercent /> 
      <TreeType /> 
      <AccountCode /> 
      <UseBaseUnits /> 
      <SupplierCatNum /> 
      <CostingCode /> 
      <ProjectCode /> 
      <BarCode /> 
      <VatGroup /> 
      <Height1 /> 
      <Hight1Unit /> 
      <Height2 /> 
      <Height2Unit /> 
      <Lengh1 /> 
      <Lengh1Unit /> 
      <Lengh2 /> 
      <Lengh2Unit /> 
      <Weight1 /> 
      <Weight1Unit /> 
      <Weight2 /> 
      <Weight2Unit /> 
      <Factor1 /> 
      <Factor2 /> 
      <Factor3 /> 
      <Factor4 /> 
      <BaseType /> 
      <BaseEntry /> 
      <BaseLine /> 
      <Volume /> 
      <VolumeUnit /> 
      <Width1 /> 
      <Width1Unit /> 
      <Width2 /> 
      <Width2Unit /> 
      <Address /> 
      <TaxCode /> 
      <TaxType /> 
      <TaxLiable /> 
      <BackOrder /> 
      <FreeText /> 
      <ShippingMethod /> 
      <CorrectionInvoiceItem /> 
      <CorrInvAmountToStock /> 
      <CorrInvAmountToDiffAcct /> 
      <WTLiable /> 
      <DeferredTax /> 
      <NetTaxAmount /> 
      <NetTaxAmountFC /> 
      <LineTotal /> 
      <TaxPercentagePerRow /> 
      <ConsumerSalesForecast /> 
      <ExciseAmount /> 
      <CountryOrg /> 
      <SWW /> 
      <TransactionType /> 
      <DistributeExpense /> 
      <ShipToCode /> 
      <RowTotalFC /> 
      <CFOPCode /> 
      <CSTCode /> 
      <Usage /> 
      <TaxOnly /> 
      <UnitPrice /> 
      <LineStatus /> 
      <LineType /> 
      <COGSCostingCode /> 
      <COGSAccountCode /> 
      <ChangeAssemlyBoMWarehouse /> 
      <U_BLD_LyID /> 
      <U_BLD_NCps /> 
      </row>
      </Document_Lines>
    - <Document_LinesAdditionalExpenses>
    - <row>
      <LineNumber /> 
      <GroupCode /> 
      <ExpenseCode /> 
      <LineTotal /> 
      <TaxLiable /> 
      <VatGroup /> 
      <TaxPercent /> 
      <TaxSum /> 
      <DeductibleTaxSum /> 
      <TaxCode /> 
      <TaxType /> 
      <EqualizationTaxPercent /> 
      <EqualizationTaxSum /> 
      <WTLiable /> 
      <BaseGroup /> 
      </row>
      </Document_LinesAdditionalExpenses>
    - <WithholdingTaxLines>
    - <row>
      <WTCode /> 
      <WTAmountSys /> 
      <WTAmountFC /> 
      <WTAmount /> 
      <TaxableAmountinSys /> 
      <TaxableAmountFC /> 
      <TaxableAmount /> 
      <AppliedWTAmountSys /> 
      <AppliedWTAmountFC /> 
      <AppliedWTAmount /> 
      <BaseDocEntry /> 
      <BaseDocLine /> 
      <BaseDocType /> 
      </row>
      </WithholdingTaxLines>
    - <SerialNumbers>
    - <row>
      <ManufacturerSerialNumber /> 
      <InternalSerialNumber /> 
      <ExpiryDate /> 
      <ManufactureDate /> 
      <ReceptionDate /> 
      <WarrantyStart /> 
      <WarrantyEnd /> 
      <Location /> 
      <Notes /> 
      <BatchID /> 
      <SystemSerialNumber /> 
      <BaseLineNumber /> 
      </row>
      </SerialNumbers>
    - <BatchNumbers>
    - <row>
      <BatchNumber /> 
      <ManufacturerSerialNumber /> 
      <InternalSerialNumber /> 
      <ExpiryDate /> 
      <ManufacturingDate /> 
      <AddmisionDate /> 
      <Location /> 
      <Notes /> 
      <Quantity /> 
      <BaseLineNumber /> 
      </row>
      </BatchNumbers>
    - <DocumentsAdditionalExpenses>
    - <row>
      <ExpenseCode /> 
      <LineTotal /> 
      <Remarks /> 
      <DistributionMethod /> 
      <TaxLiable /> 
      <VatGroup /> 
      <TaxPercent /> 
      <TaxSum /> 
      <DeductibleTaxSum /> 
      <TaxCode /> 
      <TaxType /> 
      <EqualizationTaxPercent /> 
      <EqualizationTaxSum /> 
      <BaseDocEntry /> 
      <BaseDocLine /> 
      <BaseDocType /> 
      <LastPurchasePrice /> 
      <Stock /> 
      <WTLiable /> 
      </row>
      </DocumentsAdditionalExpenses>
    - <WithholdingTaxData>
    - <row>
      <WTCode /> 
      <WTAmountSys /> 
      <WTAmountFC /> 
      <WTAmount /> 
      <TaxableAmountinSys /> 
      <TaxableAmountFC /> 
      <TaxableAmount /> 
      <AppliedWTAmountSys /> 
      <AppliedWTAmountFC /> 
      <AppliedWTAmount /> 
      <BaseDocEntry /> 
      <BaseDocLine /> 
      <BaseDocType /> 
      </row>
      </WithholdingTaxData>
    - <TaxExtension>
    - <row>
      <TaxId0 /> 
      <TaxId1 /> 
      <TaxId2 /> 
      <TaxId3 /> 
      <TaxId4 /> 
      <TaxId5 /> 
      <TaxId6 /> 
      <TaxId7 /> 
      <TaxId8 /> 
      <TaxId9 /> 
      <State /> 
      <County /> 
      <Incoterms /> 
      <Vehicle /> 
      <VehicleState /> 
      <NFRef /> 
      <Carrier /> 
      <PackQuantity /> 
      <PackDescription /> 
      <Brand /> 
      <ShipUnitNo /> 
      <NetWeight /> 
      <GrossWeight /> 
      <StreetS /> 
      <BlockS /> 
      <BuildingS /> 
      <CityS /> 
      <ZipCodeS /> 
      <CountyS /> 
      <StateS /> 
      <CountryS /> 
      <StreetB /> 
      <BlockB /> 
      <BuildingB /> 
      <CityB /> 
      <ZipCodeB /> 
      <CountyB /> 
      <StateB /> 
      <CountryB /> 
      </row>
      </TaxExtension>
      </BO>
      </BOM>
    
    

    You can also get the template by GetBusinessObjectTemplate method.(oPurchaseOrders)

     <WebMethod()> Public Function GetTemplate(ByVal SessionID As String, ByVal ObjectType As String) As Xml.XmlDocument
            Dim n As SBODI_Server.Node
            Dim s, strXML As String
            Dim d As Xml.XmlDocument
    
            d = New Xml.XmlDocument
            n = New SBODI_Server.Node
    
            strXML = "<?xml version=""1.0"" encoding=""UTF-16""?>" & _
            "<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
            "<env:Header>" & _
            "<SessionID>" & CStr(SessionID) & "</SessionID>" & _
            "</env:Header>" & _
            "<env:Body>" & _
            "<dis:GetBusinessObjectTemplate xmlns:dis=""http://www.sap.com/SBO/DIS"">" & _
            "<Object>" & CStr(ObjectType) & "</Object>" & _
            "</dis:GetBusinessObjectTemplate>" & _
             "</env:Body></env:Envelope>"
    
            s = n.Interact(strXML)
            d.LoadXml(s)
            Return (RemoveEnv(d))
        End Function   

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello syn,

      i hav a problem with adding a new sales order...Here's my coding....when i add finally it's giving error as "invalid xml schema".....can u pls help me..

      
      Private Sub btnClick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClick.Click
              Dim oQuotationXml As Xml.XmlElement
              Dim oBpCode As Xml.XmlNodeList
              Dim oItemCode As Xml.XmlNode
              Dim oDocDate As Xml.XmlNode
              Dim oFirstRow As Xml.XmlNode
              Dim oNewRow As Xml.XmlNode
              Dim oTaxCode As Xml.XmlNode
              Dim oItemQuantity As Xml.XmlNode
              Dim oXmlReply As Xml.XmlElement
              Dim oDocumentLines As Xml.XmlNode
       
           
              oQuotationXml = DIS.GetEmptySalesXml(SessionID)
       
            
       
            
              oBpCode = oQuotationXml.SelectNodes("//CardCode")
             
              oBpCode.Item(0).InnerText = cmbCCode.SelectedValue
       
          
              oDocDate = oQuotationXml.SelectSingleNode("//DocDueDate")
            
              oDocDate.InnerText = txtDelivery.Text
              oItemCode = oQuotationXml.SelectSingleNode("//ItemCode")
              oItemCode.InnerText = txtICode.Text
              oItemQuantity = oQuotationXml.SelectSingleNode("//Quantity")
               oItemQuantity.InnerText = txtQty.Text
           
              oDocumentLines = oQuotationXml.SelectSingleNode("//Document_Lines")
       
            
              oFirstRow = oDocumentLines.FirstChild
              oNewRow = oFirstRow.CloneNode(True)
       
              oItemCode = oNewRow.SelectSingleNode("//ItemCode")
              oItemCode.InnerText = "X0004"
              oItemQuantity = oNewRow.SelectSingleNode("//Quantity")
              oItemQuantity.InnerText = "3"
       
        
              oDocumentLines.AppendChild(oNewRow)
       
              txtTmp.Text = oQuotationXml.OuterXml
        
              oXmlReply = DIS.AddSalesOrder(SessionID, oQuotationXml.OuterXml)
       
              Dim sRet As String
        
              If InStr(oXmlReply.InnerXml, "<env:Fault>") Then 'And (Not (sret.StartsWith("Error"))) Then
                  sRet = "Error: " & oXmlReply.InnerXml
                  txtError.Text = (sRet)
               
                  Exit Sub
              End If
       
              'saves the Quotation key
              msDocNum = oXmlReply.InnerText
              txtDocNo.Text = msDocNum
             
          End Sub
      
      

      this is my error code generated....can anybody help me pls....

       
      Error: <env:Body xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Fault><env:Code><env:Value>env:Receiver</env:Value><env:Subcode><env:Value>-2053</env:Value></env:Subcode></env:Code><env:Reason><env:Text xml:lang="en">Could not Generate XML Schema</env:Text></env:Reason><env:Detail><Object xmlns="">oDocuments</Object><Object xmlns="">oDocuments</Object><ObjectIndex xmlns="">1</ObjectIndex><Command xmlns="">AddObject</Command><SessionID xmlns="">B0929D7B-9058-484A-8709-PDBCT7914FB9</SessionID></env:Detail></env:Fault></env:Body>
       
      

  • author's profile photo Former Member
    Former Member
    Posted on Jul 01, 2008 at 10:33 AM

    Hi Shangai

    I believe the error here is due to the account No of your default bank is not defined.

    Administration->System Initialization->Company Details->Basic Initailization Tab.

    Regards,

    Syn Qin

    SAP Business One Forums Team

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi syn,

      how to get the business object template for sales order..iam able to get template for business partners but unable to get for sales order.... i have tried all the codings given, by still iam getting a error like

       <?xml version="1.0" encoding="utf-8" ?> 
      - <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
      - <env:Body>
      - <env:Fault>
      - <env:Code>
        <env:Value>env:Receiver</env:Value> 
      - <env:Subcode>
        <env:Value>-1</env:Value> 
        </env:Subcode>
        </env:Code>
      - <env:Reason>
        <env:Text xml:lang="en">General Error</env:Text> 
        </env:Reason>
      - <env:Detail>
        <Command>GetBusinessObjectTemplate</Command> 
        <SessionID>DC703486-75R0-AD4D-97D1-0E80D8195155</SessionID> 
        </env:Detail>
        </env:Fault>
        </env:Body>
        </env:Envelope>
       

      my coding for getting business object template for sales order is...can anybody tell me where iam making the mistake....

       <WebMethod()> Public Function GetBusinessObjectTemplate(ByVal SessionID As String) As Xml.XmlDocument
              Dim n As SBODI_Server.Node
              Dim s, strXML As String
              Dim d As Xml.XmlDocument
       
              d = New Xml.XmlDocument
              n = New SBODI_Server.Node
       
              strXML = "<?xml version=""1.0"" encoding=""UTF-16""?>" & _
              "<env:Envelope xmlns:env=""http://schemas.xmlsoap.org/soap/envelope/"">" & _
              "<env:Header>" & _
              "<SessionID>" & CStr(SessionID) & "</SessionID>" & _
              "</env:Header><env:Body><dis:GetBusinessObjectTemplate xmlns:dis=""http://www.sap.com/SBO/DIS"">" & _
              "<Object>oOrders</Object>" & _
              "</dis:GetBusinessObjectTemplate></env:Body></env:Envelope>"
       
       
               s = n.Interact(strXML)
              d.LoadXml(s)
              Return (RemoveEnv(d))
          End Function
      

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.