CPYFRMIMPF with variable file name?

10 pts.
Tags:
AS/400
CPYFRMIMPF
variable file name
I have a network directory of random named text files to cpy to db2 and process via scheduled intervals (for real-time air data in our travel system)... what is the best way to go about this?

Software/Hardware used:
Amadeus, iSeries

Answer Wiki

Thanks. We'll let you know when a new response is added.

You can purchase a good package that would do the monitoring for you and then initiate whatever process that you want to do on the AS400 or other server. I highly recommend GoAnywhere from Linoma Software.
We used to have a process that would kick off every 5 minutes and create FTP commands on the fly. The first one would do an LS command to create a list of the files on the server. Then we read that in to determine what files are currently on the server and then create another FTP process to pull the file, process it and then delete it from the server.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    If all you want to do is grab a list of streamfiles from some directory, then review this code:
    pgm
    
    
       dcl   &dtaqe         *char      512
       dcl   &lendtaqe      *dec         5
       dcl   &lprvdtaqe     *dec         5
    
    /* Run Qshell to set current directory and list to data queue... */
    
       qsh         cmd( 'cd jtest; ls -F | dataq -w /qsys.lib/mylib.lib/qshls.dtaq' )
    
    /* Loop through data queue... */
    
    Nxt_dtaqe:
    
       call       QRCVDTAQ   ( +
                               'QSHLS     '           +
                               '*LIBL     '           +
                               &lendtaqe              +
                               &dtaqe                 +
                               x'00000F'              +
                             )
    
    /* IF no entry, dump for review and exit... */
    
       if   ( &lendtaqe *eq 0 )        do
          dmpclpgm
          return
       enddo
    
    /* ELSE save this "length" for review and loop back... */
    /* SndMsg all non-directories to MyMsgQ... */
    
       else  do
          if ( %sst( &dtaqe &lendtaqe 1 ) *ne '/' )  +
             sndmsg   %sst( &dtaqe 1 &lendtaqe )  MyMsgQ
          chgvar      &lprvdtaqe         &lendtaqe
          goto Nxt_dtaqe
       enddo
    
    
    endpgm
    That's a very simplified program that uses Qshell and a data queue to build a list of files in a directory. It is purely for illustration and needs both some explanation and some changes. First, you need to create a data queue. You could create it in the program, but it requires a little care. For example:
    CRTDTAQ DTAQ(QTEMP/QSHLS)
            MAXLEN(512)
            AUTORCL(*YES)
    It's pretty tricky creating something in QTEMP and getting Qshell to find it because the Qshell functions run in a different job. So you need to create your data queue in a permanent library. And if you have multiple jobs running, you need them to use different data queues. Perhaps best is to use RTVJOBA NBR() and construct a name from the job number. In any case, the QSH command string needs to reference the same data queue in the same library as your CL uses when it calls QRCVDTAQ to receive the entries. Next, I coded the -F switch after the ls utility. That causes directories, executables and symbolic links to get an extra character on the end of the name. In my example, I check the last character for a forward-slash since that would indicate a "directory". (See ls documentation for other characters. I don't know what all you need.) I'm simply sending names of everything but directories to "MyMsgQ". You'll want to do some kind of processing at that point when you get a streamfile name. The QSH command should have some comments here. First, it has a simple command to set a current directory for the Qshell session -- cd jtest. I used jtest because it was a subdirectory that I already had in my user current directory. You'll use whatever directory path is appropriate for your job. Then, there's a semi-colon (";") to separate the next command. Finally, the last QSH command is a compound command that has the ls and dataq utilities. The ls utility lists the current directory. The pipe (vertical bar "|") symbol takes the output from ls and 'pipes' it into the dataq utility. The dataq utility takes each line from las and sends it to my data queue. When the QSH function finishes, I loop through the entries. Each entry is processed until I reach an entry with zero length. The DMPCLPGM command and the CHGVAR for &lprvdtaqe at the end don't serve any purpose except to provide minor debugging. Note that the CHGVAR simply preserves the 'length' of the very last item pulled from the queue so that it shows in the dump. It's very trivial code. It can use some error handling and needs to manipulate creation of the data queue. And when it creates the data queue, it needs to concatenate that name into the QSH command string. (But that's just normal character handling in a CL variable.) See if it sparks any thoughts. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following