How to transfer file to FTP server

By | June 6, 2020

Sometimes, it might happen that we need to transfer a file to the FTP server. The below piece of code will transfer the file to FTP.



It is the FTP server address on which the files will be transferred.


 It is the Username and Password of the defined FTP server.


 It s the path of the WinSCP software that we are using to connect to the FTP.


 It is the path of the file that needs to be transferred to the FTP.


 It is a temporary path at which a bat file will be created which will run eventually in order to transfer the file to FTP.


 It is the command to open the FTP.


 It will get the Path on FTP where the file will be transferred.


 It will get the file that needs to be transferred from its original location i.e. YC_PTHREQ


Now, when you run this piece of code a bat file will be created at the path defined in the variable “PATH”.

Wrseq WRET(0)+WRET(1)+WRET(2)+WRET(3)+WRET(4)  Using [FACS]

This line of code will run the command to open the path on FTP defined in WRET(1) , get the file from its original location and then transfer it to the FTP and after that close the FTP in the bat file.

STAT = delFile(PATH+’\RGET’ + ZGETTIME + ‘.bat’ )

This line of code will delete the bat file once the file is transferred to the FTP successfully.

Code to transfer file to FTP server

About Us

Greytrix – a globally recognized Premier Sage Gold Development Partner is a one-stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third-party add-on development and implementation expertise.

Greytrix caters to a wide range of Sage X3 (Sage Enterprise Management) offerings – a Sage Business Cloud Solution. Our unique GUMU™ integrations include Sage X3 for Sage and Magento eCommerce along with Implementation and Technical Support worldwide for Sage X3 (Sage Enterprise Management). Currently we are Sage X3 Implementation Partner in East Africa, Middles East, Australia, Asia. We also offer best-in-class Sage X3 customization and development services, integrated applications such as POS | WMS | Payment Gateway | Shipping System | Business Intelligence | eCommerce and have developed add-ons such as Catch – Weight  and Letter of Credit for Sage X3 to Sage business partners, end users and Sage PSG worldwide.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage X3 – Sage CRM integration also listed on Sage Marketplace; GUMU™ integration for Sage X3 – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information on Sage X3 Integration and Services, please contact us at We will be glad to assist you.