We often find ourselves sharing files and information via FTP.
Several applications make FTP areas available to file xml, txt and more.
In the Supply Chain, for example, connections are made available via FTP to perform download and upload of Xml, Txt or Csv files to exchange information to be treated with proprietary ERPs or in agent management processes to synchronize Ftp catalogs, orders and anything else with the tools available to the sales force. In this article we see how to make a transfer FTP, which allows you to quickly send even large files (… giga byte)
This method can be used to perform rescues on an external nas disk, located in your network, transferring * Savf objects from the Ibm-I asp to the Ftp location available. In the example below, we describe how to transfer * Savf objects from Ibm-I to a FTP area of the corporate or external intranet. The same process can be easily replicated to perform sending and receiving functions of any object negotiable with Ftp.
Index
We generate a simple full free rpg application that writes the commands to a temporary source file which we call FTPCMD with FTP member. The application reads the “SALVA_FTP” table which contains the libraries that will be saved as savf.
The written commands are typical of Ftp: user, password, BIN, PUT, GET, QUOTE, ….
CREATE TABLE LIBRERIA.SALVA_FTP ( LIBRARY CHAR (10) CCSID 280 NOT NULL DEFAULT '') RCDFMT SALVA_FTP;
// ************************************************ **** // PGM: FTP01 // command to execute to compile the pgm: // CRTSRCPF FILE (LIBRARY / FTPCMD) RCDLEN (100) MBR (FTP) // ************************************************ **** CTL-Opt OPTION (SRCSTMT: NODEBUGIO) DFTACTGRP (No); dcl-f save_ftp usage (input) rename (save_ftp: save) dcl-f ftpcmd usage (* output) rename (ftpcmd: ftprec); dcl-s userf2 char (10); dcl-s passf2 char (10); dcl-ds CmdRec; srcseq packed (6: 2); SRCDAT packed (6: 0); SRCDTA char (88); END-SD; userf2 = 'qpgmr01'; // user record and password passf2 = 'qpgmr01'; srcdta = userf2 + passf2; srcdat = 0; srcseq = + 1; write ftprec; srcseq = + 1; srcdta = 'BIN'; // BIN record write ftprec; dow not (% eof); read save_ftp; // read table if% eof; leave; endif; srcseq = + 1; srcdta = 'PUT' + 'QGPL /' + // BIN record % TRIM (LIBRARY); write ftprec; enddo; * * INLR = On;
I execute in a clle the commands for updating the tables in the qtemp.
The FTPCMD table will contain the FTP commands generated by the application of the previous point.
The FTPLOG table will contain the log of the executed transactions.
The STRTCPFTP command will be launched with the parameter indicating the FTP location which will be accessed with the user and password memorized by the function described above.
/ * FTP_CL * / PGM PARM (& TGTSYS) / * parameter containing the ftp address of destination ftp.xxxx.xx * / DCL VAR (& TGTSYS) TYPE (* CHAR) LEN (30) DLTF FILE (QTEMP / FTPCMD) MONMSG MSGID (CPF2105) CRTSRCPF FILE (QTEMP / FTPCMD) RCDLEN (100) MBR (FTP) OVRDBF FILE (FTPCMD) TOFILE (QTEMP / FTPCMD) MBR (FTP) CALL PGM (FTP01) DLTF FILE (QTEMP / FTPLOG) MONMSG MSGID (CPF0000) CRTPF FILE (QTEMP / FTPLOG) RCDLEN (132) MBR (FTPLOG) OVRDBF FILE (INPUT) TOFILE (QTEMP / FTPCMD) MBR (FTP) OVRDBF FILE (OUTPUT) TOFILE (QTEMP / FTPLOG) MBR (FTPLOG) STRTCPFTP RMTSYS (& TGTSYS) DLTOVR FILE (* ALL)
And here is the final launch that includes saving the libraries inserted in the table and sending ftp to the savf
/ * SAVE_CL * / PGM DCLF FILE (LIBL / SALVA_FTP) DCL VAR (& LIBRARY) TYPE (CHAR) LEN (10) / ** save libraries on Iseries disk LOOP: RcvF MonMsg MsgId (CPF0864) Exec (GoTo EOF) CRTSAVF FILE (& LIBRARY) MONMSG MSGID (CPF5813 CPF7302) SAVLIB LIB (& LIBRERIA) DEV (SAVF) SAVF (& LIBRARY) + CLEAR (ALL) SAVACT (SYSDFN) DTACPR (MEDIUM) MONMSG MSGID (CPF9812) GOTO CMDLBL (LOOP) EOF: / * ftp of savf on nas * / CALL FTP_CL ('xxx.xxx.xxx.xxx)
Example of the log stored in the table qtemp / ftplog .
…………….>
PUT QGPL / LIBRARY
229 Entering Extended Passive Mode (!!! 24775!).
150 Sending file to member LIBRARY in LIBRARY file in QGPL library.
226 File transfer completed successfully 2
2176 bytes transferred in 0.062 seconds. Transfer speed 354,816 KB / sec.
….
The described technique allows to write fast, structured and brilliant applications to send and receive information via ftp for the IBM-I platform.
If you work with IBM i, I recommend reading this insightful article by Giancarlo Lui: IBM i System Management: Simpler…
In his recent article "RPG Free and option *convert" , Aldo Succi explores the *CONVERT option in the RPG language,…
Updating Java and DCM Certificates for ECB Exchange Rate Retrieval on IBM i In our blog, we have previously discussed…
We are pleased to receive and share this "tip & trick" from Patrick Rizzi, which introduces a technique that allows…
I take inspiration from a response by Michael Mayer on the Midrange.com mailing lists to someone who asked how to…
Businesses are increasingly seeking tools to enhance efficiency, collaboration, and resource management. Enterprise Resource Planning (ERP) systems provide a comprehensive…