#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2011
    Posts
    1
    Rep Power
    0

    XML nodes to an external file


    Hi Is it possible to extract my XML nodes within my arrays to an external file saved on the server as an order response as seen below: Using the array nodes such as PONum and Qty

    Dim rspartarray()
    Dim numLineItems
    Dim CurrentItem
    CurrentItem = 0

    Set ItemNodeLst = objXML.documentElement.selectNodes("//ItemDetail")
    numLineItems = ItemNodeLst.length - 1

    'Array will have format (LineItem, (RsNUM_RFSL_Format, PartMatch, Price, PriceMatch, Qty, DelvDate))
    ReDim rspartarray(numLineItems,6)

    'Iterate through each line Item
    For Each ItemNode In ItemNodeLst

    'Iterate through each element of the line Item, extracting partnumber, price, Quantity and Delivery
    Set ChildLst = ItemNode.ChildNodes
    For Each ItemElement In ChildLst
    if ItemElement.nodeName = "UnitPrice" then
    UnitPrice = ItemElement.text
    elseif ItemElement.nodeName = "RsMaterial" then
    RsNum = ItemElement.text
    elseif ItemElement.nodeName = "OrderQuantity" then
    Qty = ItemElement.text
    elseif ItemElement.nodeName = "DeliveryDate" then
    DelvDate = ItemElement.text
    End If
    Next

    'Enter Part
    RsNUM_RFSL_Format = "RS" + Left(RsNum,3) + "-" + Right(RsNum, Len(RsNum)-3)
    rspartarray(CurrentItem,0) = RsNUM_RFSL_Format

    'Check Part Number is in EFACs
    if FgetPartNums(RsNUM_RFSL_Format) = "NoMatch" then
    rspartarray(CurrentItem,1) = "NoPartMatch"
    else
    rspartarray(CurrentItem,1) = "PartMatch"
    end if

    rspartarray(CurrentItem,2) = UnitPrice
    'Check Prices Match
    rspartarray(CurrentItem,3) = FcheckPrice(RsNUM_RFSL_Format, UnitPrice)
    'Add Qty to Array
    rspartarray(CurrentItem,4) = Qty

    'Add Delivery Date to array
    rspartarray(CurrentItem,5) = DelvDate

    'Response.Write(rspartarray(CurrentItem,0) + "</BR>")
    'Response.Write(rspartarray(CurrentItem,1) + "</BR>")
    'Response.Write(rspartarray(CurrentItem,2) + "</BR>")
    'Response.Write(CStr(rspartarray(CurrentItem,3)) + "</BR>")
    'Response.Write(CStr(rspartarray(CurrentItem,4)) + "</BR>")
    'Response.Write(rspartarray(CurrentItem,5) + "</BR>")
    'Response.Write("Day: " + CSTR(WeekDay(rspartarray(CurrentItem,5))) + "</BR>")
    'Response.Write( CStr(DateAdd("d",-5,rspartarray(CurrentItem,5))) + "</BR>")

    CurrentItem = CurrentItem + 1
    Next

    Session("rspartarray") = rspartarray

    'Redirect if there is a part / price match problem
    for t=0 to uBound(rspartarray)
    if rspartarray(t,1) = "NoPartMatch" then
    FailureReason = "Parts"
    elseif rspartarray(t,3) <> "Match" then
    FailureReason = "Price"
    elseif rspartarray(t,5) = "" then
    FailureReason = "NoDate"
    elseif rspartarray(t,4) = "" then
    FailureReason = "NoQty"
    end if

    if Failurereason <> "" then
    Response.Redirect "rs_order_finished.asp?FailureReason=" & FailureReason & ""
    end if
    next
    Response.Write("Validated Data - Part numbers, Prices, Qty's and Delivery Dates. </BR>")

    'Everything is A-OK, continue with loading the order
    'If 'Enter Order' Button has been pressed
    if Request.Form("insert") = "true" Then

    Call ScomInsertSOCust(BillItem, ShipItem, AckItem, Contact)

    NewSON = FGetSON("RSCO01")

    'partArray Format: (LineItem, (RsNUM_RFSL_Format, PartMatch, Price, PriceMatch, Qty, DelvDate))
    for lineitem=0 to uBound(rspartarray)

    if weekday(rspartarray(lineitem,5)) = 1 then
    pDelvDate = DateAdd("d",-3,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 2 then
    pDelvDate = DateAdd("d",-4,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 3 then
    pDelvDate = DateAdd("d",-5,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 4 then
    pDelvDate = DateAdd("d",-6,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 5 then
    pDelvDate = DateAdd("d",-7,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 6 then
    pDelvDate = DateAdd("d",-8,rspartarray(lineitem,5))
    elseif weekday(rspartarray(lineitem,5)) = 7 then
    pDelvDate = DateAdd("d",-9,rspartarray(lineitem,5))
    end if

    if date() > DateAdd("d",-5,rspartarray(lineitem,5)) then
    Warning = "DatePassed"
    end if

    pPartNum = rspartarray(lineitem,0)
    pPrice = CDBL(rspartarray(lineitem,2))
    pQty = CDBL(rspartarray(lineitem,4))
    NetPrice = pQty*pPrice
    Call SInsertLItem(NewSON, lineitem+1, PONum.value, pPartNum, pQty, NetPrice, 17.5, pPrice, FGetnlCode(rspartarray(lineitem,0)), 1, "", pDelvDate)
    next

    'Update the Customers Outstanding Balance and Insert the shipping line Item
    Call ScomUpdateBalance("RSCO01", POValue)

    if Warning = "DatePassed" then
    Response.Redirect "rs_order_finished.asp?SON="& NewSON &"&Warning="&Warning&""
    else
    Response.Redirect "rs_order_finished.asp?SON="& NewSON &""
    end if

    End if










    %>
    <p>&nbsp;</p>
    <p><strong>Purchase Order Details</strong></p>
    <p>Purchase Order Number: <%=PONum%><BR>
    Puchase Order Value: <%=POValue%> <BR>
    Line Items: <%=uBound(rspartarray)+1%>
    </p>


    <p>
    <table width="600" border="1" cellspacing="0" cellpadding="0">
    <tr>
    <td><strong>Part Number</strong></td>
    <td><strong>Unit Price</strong></td>
    <td><strong>Quantity</strong></td>
    <td><strong>Delivery Date</strong></td>
    </tr>
    <% for lineitem=0 to uBound(rspartarray) %>
    <tr>
    <td><%=rspartarray(lineitem,0)%></td>
    <td><%=rspartarray(lineitem,2)%></td>
    <td><%=rspartarray(lineitem,4)%></td>
    <td><%=DateAdd("d",-5,rspartarray(lineitem,5))%></td>
    </tr>
    <% next %>
    </table>

    My order response needs to be:


    <POConf>
    <PONo/>
    <VendorNo>123456</VendorNo>
    <ItemLine itemno="010" >
    <CustArticleNo>3001733010</CustArticleNo>
    <UOM>PCE</UOM>
    <DeliveryDetails>
    <ScheduledQty>3000</ScheduledQty>
    <Date>2010-03-05</Date>
    </DeliveryDetails>
    </ItemLine>
    </POConf>

    Thanks
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0
    do you really expect folks to plow through all that code in order to volunteer an answer ?

    I suspect with enough coding almost anything is possible

IMN logo majestic logo threadwatch logo seochat tools logo