Copy link to clipboard
Copied
We have an online store and when orders are placed we need to be able to post that order data somewhere so that our Manufacturing Software can import that order.
One of the EDI people told me that, if I could write a service, they could "watch" a folder for updates and then import all the order information.
I'm not sure where to start with this.
Basically, they need an xml or csv to import that contains ONLY the orders from one prescribed time or, perhaps, as each order comes in.
I Use SQL Server 2008.
Any help would be VERY welcome.
I'm looking for direction and possibly some "how toos"
Are there some products that might help me with this?
Thanks.
Copy link to clipboard
Copied
You don't mention what scripting language you are using, but you should be able to write an xml or csv file easily using any language. When the order comes in just write the detail in a uniquely named file in the file system so that the EDI can pick it up.
Copy link to clipboard
Copied
Classic (yes, I know...) ASP VBScript.
Writing services is so new to me; what I think I need is an quick outline of the process (if there is one).
If this would help, I've been playing around with Visual Studio and .net but I'm not all that comfortable with the tools.
I'm always working on learning the wrong thing...I spent the last year trying to work with ActionScript and then Steve Jobs tried to kill Flash with the iPad...I know it's not dead but it was certainly a shot across the bow.
I've been reading about services and rss feeds and xml for a long time and I've just not spent the time on that side of things...until now, I've not needed it.
Just so you understand where I'm coming from, I'm more of a Designer pretending to be a Programmer (out of necessity). I'm a one-man-shop so I have to do it all...Anyways...I say all of this only to inspire sympathy... ![]()
Thanks for your help.
Copy link to clipboard
Copied
>Writing services is so new to me;
>what I think I need is an quick outline
>of the process (if there is one).
Why do you need to create a service? If the EDI folks are monitoring a folder, then you need to write a file. With ASP, you use the FileSystemObject. It's very simple and straightforward to create, delete, append text, ect. Here are some links to get you started.
http://www.w3schools.com/asp/asp_ref_filesystem.asp
http://www.w3schools.com/asp/asp_ref_textstream.asp
http://msdn.microsoft.com/en-us/library/d6dw7aeh%28VS.85%29.aspx
Copy link to clipboard
Copied
I've played with fso but I'm not all that flexible with it.
I would prefer to "publish" xml. Do you see an easy way to do this?
Copy link to clipboard
Copied
<%@LANGUAGE="VBSCRIPT"%>
rs_cmd.ActiveConnection = MM_connShnta_STRING
<!--#include file="../Connections/conn.asp" -->
<%
Dim rs__MMColParam
rs__MMColParam = "8556"
If (Request("MM_EmptyValue") <> "") Then
rs__MMColParam = Request("MM_EmptyValue")
End If
%>
<%
Dim rs
Dim rs_cmd
Dim rs_numRows
Set rs_cmd = Server.CreateObject ("ADODB.Command")rs_cmd.CommandText = "SELECT * FROM dbo.Orders WHERE invoice = ?"
rs_cmd.Prepared = true
rs_cmd.Parameters.Append rs_cmd.CreateParameter("param1", 5, 1, -1, rs__MMColParam) ' adDouble
Set rs= rs_cmd.Execute
rs_numRows = 0
%>
<HTML>
<BODY>
<!-- SaveXmlString.asp -->
<%
If IsEmpty(Request("strXml")) Then
Msg = "Please enter a brief XML string, such as '<root/>'."
Else
Dim str, xmldoc
Set xmldoc = CreateObject("Msxml2.DOMDocument.6.0")
xmldoc.loadXML Request("strXml")
If xmlDoc.parseError.errorCode <> 0 Then
Msg = "The string you entered was not well-formed XML. " & _
xmlDoc.parseError.reason
Else
Response.Write("< ?xml version="1.0 " encoding= " utf-8 " ? >")
xmldoc.save(Server.MapPath(rs.Fields.Item("invoice").Value & ".xml"))
str = Request("strXml")
str = Replace(str, Chr(38),"&", 1, -1, 1)"
str = Replace(str, Chr(34),""", 1, -1, 1)
str = Replace(str, Chr(46),".", 1, -1, 1)
str = Replace(str, Chr(60),"<", 1, -1, 1)
str = Replace(str, Chr(62),">", 1, -1, 1)
Msg = "<P>Your XML string:<BR>" & str & _
"<BR>has been saved to the server as <B>" & rs.Fields.Item("invoice").Value & ".xml</B>.</P>"
End If
End If
%>
<FORM METHOD="POST" ACTION="epicor_test03.asp">
<PRE>
<%= Msg %><BR>
<INPUT TYPE="TEXT" NAME="strXml" SIZE=75
VALUE="<%= Request("strXml")%>"><BR>
<INPUT TYPE="Submit" VALUE="Submit">
</PRE>
</FORM>
</BODY>
</HTML>
<%
rs.Close()
Set rs = Nothing
%>
Copy link to clipboard
Copied
\The above code starts to do what i want. I'm pulling in a recordset and the order information. That's all now available to me to put into an xml file. The problem that I'm having is knowing how to use MSXML to write the xml upon entering the page and doing it without sending a form.
Again, perhaps MSXML is overkill.
With the FSO (FileSystemObject), I was having problems creating a file that looked like xml.
Any ideas?
Copy link to clipboard
Copied
It's been a long time since I've used MSXML. See if this helps: http://www.freevbcode.com/ShowCode.Asp?ID=1919
You should be able to use that routine to format and save the xml file. Just use a loop to iterate through the RS and populate the nodes with dynamic content.
Your original post mentioned writing a CSV file. If that's still an option, that would be simple to implement.
Copy link to clipboard
Copied
I'm really close now.
<?xml version="1.0" encoding="utf-8"?>
Using the fso, I'm trying to write the xml header but asp throws up an error. I can get past the error by encode the special characters but that just writes the name code ...
Copy link to clipboard
Copied
What recommendations would you make about securing an xml file?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more