midrange.com code scratchpad
Name:
Create FTP Script (generic)
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
02/26/2008 06:07:18 pm
IP:
Logged
Description:
Creates a generic FTP command file. Called once for each command line in the FTP script. The member must exist.
Code:
  1.       /TITLE Create FTP Script (generic)
  2.      H Copyright('© Copyright Stewart Enterprises, Inc., 2003')                 Copyright statement
  3.      H Option( *SRCSTMT : *NODEBUGIO )
  4.      H Dftactgrp(*NO) Actgrp(*CALLER)
  5.       *****************************************************************
  6.       *                                                               *
  7.       *                  STEWART ENTERPRISES, INC.                    *
  8.       *             CORPORATE ACCOUNTS RECEIVABLE SYSTEM              *
  9.       *                                                               *
  10.       *  Program Name:         ARU912                                 *
  11.       *                                                               *
  12.       *  Program Description:  Create FTP Script (generic)            *
  13.       *                                                               *
  14.       *  This program developed By Stewart Enterprises, Inc.          *
  15.       *  1333 S. Clearview Parkway, Jefferson, LA  70121              *
  16.       *  Copyright 2003                                               *
  17.       *                                                               *
  18.       *  AUTHOR: F. Lapeyre                   03/03/2003              *
  19.       *                                                               *
  20.       *  This program will build an FTP script. It will write one     *
  21.       *  record to the output file each time it is called. The        *
  22.       *  FTP commands are passed in to the program as a string        *
  23.       *  parameter, along with the file, library, and member to       *
  24.       *  write.  All parameters are required unless PASS = 'L'.       *
  25.       *                                                               *
  26.       *****************************************************************
  27.       *                 M O D I F I C A T I O N S                     *
  28.       *****************************************************************
  29.       *   DATE     NAME            DESCRIPTION
  30.       *****************************************************************
  31.       * XX/XX/XX   X. XXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  32.       *                            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  33.       /EJECT
  34.       *****************************************************************
  35.       *             F I L E   S P E C I F I C A T I O N S             *
  36.       *****************************************************************
  37.      FQftpsrc   O    E             Disk    Rename(Qftpsrc:Ftpcmd) Usropn
  38.      F                                     Extfile(Ftpfile) Extmbr(P_Member)
  39.  
  40.       /EJECT
  41.       *****************************************************************
  42.       *                      D E F I N I T I O N S                    *
  43.       *****************************************************************
  44.  
  45.       * Program Status Data Structure
  46.      D                SDS
  47.      D Pgm                           10
  48.      D Status                         5
  49.      D Msgid                  40     46
  50.      D Lib                    81     90
  51.      D Filerr                201    208
  52.      D Namjob                244    253
  53.      D User                          10
  54.      D Numjob                         6  0
  55.      D Sbmdat                         6  0
  56.      D Excdat                         6  0
  57.      D Exctim                         6  0
  58.      D Cmpdat                         6  0
  59.      D Cmptim                         6  0
  60.      D Srcfil                304    313
  61.      D Srclib                        10
  62.      D Srcmbr                        10
  63.  
  64.       * Stand Alone Fields
  65.      D Command_String  S           3000A   Varying
  66.      D Ftpfile         S             21A
  67.      D P_Command       S             80A
  68.      D P_File          S             10A
  69.      D P_Library       S             10A
  70.      D P_Member        S             10A
  71.      D Page_Msg        S            150A   Inz
  72.      D Pass            S              1A
  73.      D Workdate        S               D
  74.  
  75.       * Named constants
  76.      D Quote           C                   ''''
  77.  
  78.       * QCMDEXC prototype
  79.      D Runcmd          PR                  Extpgm('QCMDEXC')
  80.      D  Cmdstr                     3000A   Const Options(*VARSIZE)
  81.      D  Cmdlen                       15P 5 Const
  82.      D  Cmddbcs                       3A   Const Options(*NOPASS)
  83.  
  84.       *  Prototype for Aru912
  85.      D Aru912          PR
  86.      D Pass_                          1
  87.      D P_Library_                    10
  88.      D P_File_                       10
  89.      D P_Member_                     10
  90.      D P_Command_                    80
  91.  
  92.       *  *ENTRY Interface for Main Procedure
  93.      D Aru912          PI
  94.      D Pass                           1
  95.      D P_Library                     10
  96.      D P_File                        10
  97.      D P_Member                      10
  98.      D P_Command                     80
  99.       /EJECT
  100.       *****************************************************************
  101.       *                        P A R A M E T E R S                    *
  102.       *****************************************************************
  103.  
  104.       /EJECT
  105.       *****************************************************************
  106.       *                   M A I N L I N E   C O D E                   *
  107.       *****************************************************************
  108.  
  109.       /Free
  110.        Select;
  111.      
  112.          // Pass = 'L' - close file and exit.
  113.        When Pass = 'L';
  114.          If %OPEN(Qftpsrc);
  115.            Close Qftpsrc;
  116.          Endif;
  117.          *INLR = *ON;
  118.          Return;
  119.      
  120.          // Pass <> 'L'
  121.        When Pass <> 'L' And %PARMS = 5;
  122.      
  123.          // Open the FTP command file.
  124.          If Not %OPEN(Qftpsrc);
  125.      
  126.        // Override to the library and file passed in as parameters (member is specified
  127.            // on the EXTMBR keyword in the F-specs).
  128.        // If the library was passed in, use the fully qualified name for the file.
  129.            If (P_Library = *BLANKS);
  130.              Ftpfile = %TRIM(P_File);
  131.            Else;
  132.              Ftpfile = %TRIM(P_Library) + '/' + %TRIM(P_File);
  133.            Endif;
  134.      
  135.          // Attempt to open the FTP command file. If we can't, then send a pager
  136.            // message to the programmer and exit.
  137.            // (Substitute your paging utility here!! )
  138.            Open(E) Qftpsrc;
  139.      
  140.            If %ERROR;
  141.              Page_Msg = 'Unable to open FTP command' + ' file for AS/400 job ' +
  142.              %EDITC(Numjob:'X') + '/' + %TRIM(User) + '/' + %TRIM(Namjob) +
  143.              '. Check job log.';
  144.             Command_String = 'LXIPAG/SNDPAGMSG MSG(' + Quote + %TRIM(Page_Msg) +
  145.              Quote + ') TOUSERS((PROGRAMMER AR))';
  146.              Runcmd(Command_String : %LEN(%TRIMR(Command_String)));
  147.              Pass = 'E';
  148.              *INLR = *ON;
  149.              Return;
  150.            Endif;
  151.      
  152.          Endif;
  153.      
  154.          // Write source record, after incrementing sequence number.
  155.        // Calling program is responsible for passing the commands in the correct case.
  156.          Workdate = %DATE;
  157.       /End-Free
  158.      C     *YMD          Move      Workdate      Srcdat
  159.       /Free
  160.          Srcseq = Srcseq + 1.00;
  161.          Srcdta = %TRIM(P_Command);
  162.          Write Ftpcmd;
  163.      
  164.        Endsl;
  165.      
  166.        Return;
  167.       /End-Free
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css