Search390.com
Developer Tip
May 9, 2001

========================================================
What do you like? Networks? Computer Games? Downloads?  How about
Free Stuff? 
Search390.com can get you FREE info on the topics that interest you
most - and there are so many to choose from! We'll find related news,
information and special offers and deliver them directly to your
e-mailbox, all at no charge! Sign up here today
http://search390.techtarget.com/postmasterDirect/
========================================================
TODAY'S DEVELOPER TIP:

OOP ACK ACK Fttttttpppppppppppppppppppppp!!!!!!!!!
Jim Keohane - - - with apologies to Bill the Cat

IBM's older OS/390 FTP clients, if EXIT option specified, originally
returned a 5 digit non-zero value to caller in the event of an error.
If FTP was invoked in a CLIST you could test LASTCC. If your program
linked to FTP then it could examing register 15 on return for the 5
digit value.

The format was XXYYY where XX indicated which subcommand (GET, PUT,
etc.) and YYY was reply code from remote server or zero.

This led to some confusion when FTP was invoked from batch where
condition code must be 0-4095. Any returned value from FTP higher
than 4095 was adjusted modulo 4096 (divide by 4096 and take
remainder). Your JESLOG showed COND CODE was 2424 yet FTP OUTPUT said
27000 (where 27 = PUT and 000 meant no server reply). It's easier to
visualize if you take 27000 as hex (6978) and then convert the 3
rightmost hex digits (698) into decimal (2424).

IBM *fixed* this by doing its own MODULO 4096 before returning the
value. Now you got the same meaningless 2424 in all cases.

The very latest FTP client returned 1 through 16 as Client error
codes. More confusion. APAR PQ20356 addressed by adding
CLIENTERRCODES option:

CLIENTERRCODES TRUE - Convert FTP return codes into a set of codes
defined in the "FTP Client Error Codes" section of the User's Guide. 

CLIENTERRCODES FALSE - Convert an FTP return code to the remainder of
dividing the return code by 4096 to ensure a code in the range of
0-4095. This is the  default and is the same behavior of the previous
levels of the MVS FTP client.
However, some nostalgics yearned for the old five digits so they code
programmatically interrogate FTP failures. Below is a simple approach
that involves a COBOL frontend that dynamically invokes FTP, restores
the original 5 digit return value and then decides what RETURN-CODE
to actually use.

       ID DIVISION.
       PROGRAM-ID. FTPFRONT.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  FTP              PIC X(8) VALUE 'FTP'.
       01  FIVE-DIGITS      PIC 99999.
       01  FILLER REDEFINES FIVE-DIGITS.
           05  SUB-COMMAND  PIC 99.
           88  SUB-OK       VALUE 1 THRU 67, 99.
           05  SERVER-REPLY PIC 999.
           88  SERVER-OK    VALUE 000.
           88  SERVER-NG    VALUE 421, 415, 426, 450, 451, 452,
                                  500, 501, 502, 503, 504, 530,
                                  531, 532, 550, 551, 552, 553.
       LINKAGE SECTION.
       01  CALLER-PARM      PIC X.
       PROCEDURE DIVISION USING CALLER-PARM.
           CALL FTP USING CALLER-PARM.
           IF RETURN-CODE IS ZERO THEN GOBACK.
           MOVE RETURN-CODE TO FIVE-DIGITS.
           PERFORM UNTIL SUB-OK AND (SERVER-OK OR SERVER-NG)
              ADD 4096 TO FIVE-DIGITS
           END-PERFORM
           DISPLAY 'SUB=' SUB-COMMAND ', SERVER-REPLY=' SERVER-REPLY.
           MOVE 4 TO RETURN-CODE.
           IF FIVE-DIGITS = 27000 THEN MOVE 8 TO RETURN-CODE.
           IF FIVE-DIGITS = 10000 THEN MOVE 12 TO RETURN-CODE.
           IF SUB-COMMAND = 27 AND NOT SERVER-OK THEN
               MOVE 16 TO RETURN-CODE.
           GOBACK.

//TEST EXEC PGM=FRONTFTP,PARM='xxx.xxx.xxx.xxx ( EXIT'
//OUTPUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//INPUT DD *
userid
password
put your.local.file the.remote.file
quit
//
The above examples assume you specified EXIT (not EXIT=nnn) in JCL
PARM. It also assumes you are either running older FTP client or that
you have set CLIENTERRCODES FALSE and PQ20356 is on.

You may wish to review the FTP specifications, RFC959, at
http://www.ietf.org/rfc/rfc959.txt. FTP server replies, along with
subcommand codes, can be interrogated for useful information.

About the author: Jim Keohane ([EMAIL PROTECTED]) is
president of New York consulting company Multi-Platforms, Inc. His
company specializes in commercial software development/consulting
with emphasis on cross-platform and performance issues. 

=======================================================================
DID YOU LIKE THIS TIP? 

Why not let us know? Email your comments to
mailto:[EMAIL PROTECTED], or you can rate this tip by scrolling to
the bottom of
http://www.search390.com/tip/1,289483,sid10_gci550566,00.html
Or submit a tip of your own by contacting us at
mailto:[EMAIL PROTECTED]
=======================================================================

=======================================================================
ASK THE EXPERTS

Do you have programming-related questions?  
If so, ask an expert. Search390 has two programming experts available
to answer your questions, so ask away!  Go to
http://search390.techtarget.com/ateQuestion/0,289624,sid10_tax285034,00.html
=======================================================================

=======================================================================
DISCUSSION FORUMS

If you like our Developer tips, be sure to check out our Developer
Forum.  Share your thoughts and knowledge with your peers, or learn
something new today.   
http://search390.discussions.techtarget.com/WebX?50@@.ee83ff7


========================================================
For a list of the latest tips on Search390.com, go to
http://search390.techtarget.com/tipsIndex/0,289482,sid10_tax286020,00.html
 
What technical issues are important to you? Do you have an idea or a
tip you'd like to share with other S/390 pros? Let us know. E-mail us
at mailto:[EMAIL PROTECTED].
========================================================

========================================================
The Learning Zone Featured Book
========================================================
An Introduction to Object COBOL
Author: E. Reed Doke, Bill C. Hardgrave
Summary: With its use of straightforward language and real-world
examples, An Introduction to Object COBOL is a concise and accessible
introduction to using Object COBOL. You'll discover how object
technology is applied and how the resulting Object COBOL code is
constructed. All of the programs included in the text can be
downloaded from the Wiley web site (http://www.wiley.com/college/).
You are encouraged to execute and experiment with them. As you work
with these programs and follow the related case study, you will gain
important experience in using Object COBOL in a business environment.
http://www.digitalguru.com/dgstore/product.asp?isbn=0471183466&ac_id=54

========================================================
Disclaimer: Our tips exchange is a forum for you to share technical
advice and expertise with your peers and to learn from other IT
professionals. Techtarget.com provides the infrastructure to
facilitate this sharing of information. However, we can't guarantee
the accuracy and validity of the material submitted. You agree that
your use of the ask the expert services and your reliance on any
questions, answers, information or other materials received through
the web site will be at your own risk.
========================================================
To Remove your email address from the distribution list for this
specific newsletter "Reply" to this message with REMOVE in the
subject line. You will receive an email confirming that you have been
removed. To Remove yourself from additional distribution lists or to
update your preferences, go to the search390.com registration page
at:
http://search390.techtarget.com/register

Reply via email to