2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

流通BMSのorder(発注)データを読み込む

Last updated at Posted at 2022-10-17

概要

流通BMSのOrder(発注)データを読み込む処理をやってみた。
注)このプログラムは大まかな処理部分のみを記述しています。

VB.NET
Dim document As New XmlDocument
'読み込むXMLファイルのパスを指定する
document.Load(path)

'orderデータで使われている名前空間を定義する
Dim nm As New XmlNamespaceManager(document.NameTable)
nm.AddNamespace("sh", "http://www.unece.org/cefact/namespaces/StandardBusinessDocumentHeader")
nm.AddNamespace("common", "urn:SecondGenEDI:common:Japan:1")
nm.AddNamespace("order", "urn:SecondGenEDI:order:Japan:1")

'名前空間shのエレメントを参照する例
Dim sh_Sender_Identifier As XmlElement = document.SelectSingleNode("//sh:StandardBusinessDocumentHeader/sh:Sender/sh:Identifier", nm)
Dim sh_Receiver_Identifier As XmlElement = document.SelectSingleNode("//sh:StandardBusinessDocumentHeader/sh:Receiver/sh:Identifier", nm)
Dim sh_InstanceIdentifier As XmlElement = document.SelectSingleNode("//sh:StandardBusinessDocumentHeader/sh:DocumentIdentification/sh:InstanceIdentifier", nm)
Dim sh_Type As XmlElement = document.SelectSingleNode("//sh:StandardBusinessDocumentHeader/sh:DocumentIdentification/sh:Type", nm)
Dim sh_CreationDateAndTime As XmlElement = document.SelectSingleNode("//sh:StandardBusinessDocumentHeader/sh:DocumentIdentification/sh:CreationDateAndTime", nm)

'名前空間orderのエレメントを参照する例
Dim buyerCode As XmlElement = document.SelectSingleNode("//order:listOfOrders/buyer/code", nm)
Dim buyerCode23 As String = buyerCode.InnerText
Dim buyerName As XmlElement = document.SelectSingleNode("//order:listOfOrders/buyer/name", nm)
Dim buyerName25 As String = buyerName.InnerText
Dim buyerNameKana As XmlElement = document.SelectSingleNode("//order:listOfOrders/buyer/name_sbcs", nm)
Dim buyerNameKana26 As String = buyerNameKana.InnerText

'orders(複数伝票)情報を参照する
Dim orders As XmlNodeList = document.SelectNodes("//order:listOfOrders/order", nm)

'orders(複数伝票)内のorder(1伝票)分の処理を行う例
For Each order As XmlElement In orders
    '121 取引番号(発注・返品)= 伝票番号
    Dim tradeNumber121 As String = order.SelectSingleNode("tradeID/tradeNumber").InnerText
    '27 直接納品先コード
    Dim code27 As String = order.SelectSingleNode("parties/shipTo/code").InnerText
    '29 直接納品先名称
    Dim name29 As String = order.SelectSingleNode("parties/shipTo/name").InnerText

    'order(1伝票)内の明細行データを参照する例
    For Each child As XmlElement In order.ChildNodes
        If child.Name = "lineItem" Then
            '123 取引明細番号(発注・返品)= 伝票行番号
            Debug.WriteLine(Integer.Parse(child.SelectSingleNode("lineID/lineNumber").InnerText))
            '73 商品コード(発注用) JANコードをセット
            Debug.WriteLine(child.SelectSingleNode("itemID/orderItemCode").InnerText)
            '77 商品名
            Debug.WriteLine(child.SelectSingleNode("itemID/name").InnerText)
        End If
    Next
Next

nm = Nothing
document = Nothing
2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?