BookmarkSubscribeRSS Feed
Saradhadevi
Calcite | Level 5

Hi,

 

I have the below requirement in our project. Please do the needful.

Requirement:

Do FTP connection and retrieve the files from different FTP server.

 

Input:

FTP Credentials (FTP User name, Password, FTP server details) in the mainframe PS file.

 

Process:

Connect with FTP server using the credetials in the input file and Retrieve the files from server using 'FILENAME' statement.
If there is any FTP error, Retry the FTP connection three times or till successful
The error should be written into the error output file and the program should continue for the next server.

 

Output:

Success output file with retrieved data

Error output file with FTP connection error.

 

Issue:

Whenever there is FTP connection error, the program throws error with MAXCC = 8.

 

Expected solution:

Option 1: Overwriting the system return code to JCL.

Option 2: Before foing FTP connection for retrieving, i want to check whether the server is UP or down to avoid the error.

 

Appreciate your help.

 

Thanks in advance,

Saradhadevi. I

2 REPLIES 2
Kurt_Bremser
Super User

To check if a server is up, one usually uses ping. So you will have to look for the MF equivalent of this UNIX-typical utility.

data _null_;
x = system("ping -c1 server_that_is_up");
put x=;
x = system("ping -c1 server_that_is_not_up");
put x=;
run;

would produce this in the log:

16         data _null_;
17         x = system("ping -c1 server_that_is_up");
18         put x=;
19         x = system("ping -c1 server_that_is_not_up");
20         put x=;
21         run;

x=0
x=1
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds

on a UNIX type SAS server.

 

The current state of the SAS session is kept in the automatic macro variable SYSCC. You can check for this state before and after your data step that uses the FTP connection; if necessary, you can set SYSCC back to 0 with a simple

%let syscc=0;
LinusH
Tourmaline | Level 20

I can't see anything in the requirements that would make a SAS session for this beneficial. This could be (better?) handled by OS/ftp commands directly.

Data never sleeps

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 883 views
  • 2 likes
  • 3 in conversation