How can I get a file on the AS/400 into an XML document on the IFS?
|Abstract:||How can I get a file on the AS/400 into an XML document on the IFS?|
|Submitted By:||LANSA Services|
I have a file on the AS400 that I need to get into an XML document on the IFS so I can FTP it out.
Currently my RDML function is loading the file data into a list named #LIST_SEND. The XSL I've created is named BW_ORD_SEND_OUT.
Below are pieces of my RDML code
USE BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_LOAD SERVICE(XMLCLIENT)') TO_GET(#S_JSMSTS #S_JSMMSG) EXECUTE SUBROUTINE(CHECK_STS) CHANGE FIELD(#S_JSMCMD) TO('LOAD METHOD(*STORAGE) SERVICE_LIST(CUSTID,PRODID,FIRSTN,LASTN,PASSWD,ACTDAT)') USE BUILTIN(JSM_COMMAND) WITH_ARGS(#S_JSMCMD) TO_GET(#S_JSMSTS #S_JSMMSG #LIST_SEND) EXECUTE SUBROUTINE(CHECK_STS) CHANGE FIELD(#S_JSMCMD) TO('TRANSFORM XSL(BW_ORD_SEND_OUT)') USE BUILTIN(JSM_COMMAND) WITH_ARGS(#S_JSMCMD) TO_GET(#S_JSMSTS #S_JSMMSG) EXECUTE SUBROUTINE(CHECK_STS) CHANGE FIELD(#S_JSMCMD) TO('STORE NAME(/main/bworder.xml) OBJECT(*TRANSFORM)') USE BUILTIN(JSM_COMMAND) WITH_ARGS(#S_JSMCMD) TO_GET(#S_JSMSTS #S_JSMMSG) EXECUTE SUBROUTINE(CHECK_STS)
Note: There are two names for each service. One is the Java Class name and the other is the service keyword name ( SERVICE_LOAD SERVICE(XMLCLIENT).
Your intention is to assemble some data from AS/400 files and then create and XML document and dispatch it using FTP. The service which you require is the FILECLIENT (5.8 XMLFileService) and not the XMLCLIENT (5.2 XMLParserService). XMLCLIENT allows only the reading of data in an XML document and does not provide for the creation of an XML document. The FILECLIENT service allows for both reading in the values of the document and creating an XML document. When you have created the document, you then will have use the FTPCLIENT (5.3 FTPService) service to send the file via FTP. The XMLClient works on a programming model which is different from the FILECLIENT. With the XMLClient, you traverse the XML root/node structure or XSL. With the FILECLIENT you just use the stylesheet approach.
For your purposes, in the XMLCLIENT service, you will need to use the SEND command (which really doesn't send the document but does transform the database information into the output XML document ) and then the WRITE command which actually puts the document out to the IFS. Then for FTPing you will have to use several commands to manage the FTP connection.
So a terse outline of the JSM commands required are as follows:
JSM_OPEN SERVICE_LOAD SERVICE(FILECLIENT) * RDML commands to read in data into fields and into the working list SEND XSL(stylesheet) SERVICE_LIST(list of working list fields) WRITE FILE(name_and_location_of_LOCAL_file) SERVICE_UNLOAD SERVICE_LOAD SERVICE(FTPCLIENT) CONNECT HOST(xxx.xxx.xxx.xxx:21) LOGIN USER(xxxxxxxxx) PASSWORD(XXXXXXXXX) CHGDIR PATH(xxxx/xxxx/xxxx) BINARY PUT FROM(LOCAL_file) TO(remote_file_name) DATALINK(*PASV) // passive * If behind firewall QUIT CLOSE SERVICE_UNLOAD JSM_CLOSE
This is a basic sketch of the process. Your needs may vary depending on your requirements. Examples showing RDML code form are provided in APPENDIX B (of the LANSA Integrator documentation).