Create a .txt file on AS/400 IFS

65 pts.
Tags:
AS/400
AS/400 Text File
IFS
I have created a file on my AS/400 using CRTPF with a 10 character name. This file is to be sent to another server. The application on the receiving server requires a .txt file with a specific name format. The name is 42 characters in length. How do I do this?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
If you’re using FTP to send it the file can be renamed on the put command:
put /qsys.lib/[library name].lib/[file name].file/[member name].mbr [42 character file name].txt

Discuss This Question: 16  Replies

 
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.
  • ToddN2000
    If your new to IFS then take a look at this site by Scott Klement.
    He provides great in depth information on how to use the IFS.

    135,465 pointsBadges:
    report
  • chasattard
    Thanks for the answers. I neglected to mention that the 42 character name has a date and time stamp in the middle of it which is dynamic. The rest of the name is static. If it wasn't for the date and time it could be done in the ftp script. I don't see anything in ftp where You generate the date/time stamp.
    65 pointsBadges:
    report
  • chasattard
    Thanks for the answers. I neglected to mention that the 42 character name has a date and time stamp in the middle of it which is dynamic. The rest of the name is static. If it wasn't for the date and time it could be done in the ftp script. I don't see anything in ftp where you generate the date/time stamp.
    65 pointsBadges:
    report
  • Splat
    chasattard, you can load the date & time into the name when you build the script.
    12,915 pointsBadges:
    report
  • ToddN2000
    Just add the timestamp to a parameter string for the file name and you should be all set. Post your code if you are still having an issue and we will take a look.
    135,465 pointsBadges:
    report
  • chasattard
    Thanks to you all. Our experience with FTP on the AS/400 has been through basic put/get scripts to/from various servers. Haven't tried loading time stamps into file names or parameter strings within ftp. How do you take an AS/400 physical file named CAPRDLVL and change the name to SHAK-CTXSTA-TST-yyyymmdd-hhmmss-PRODUCTLVL.txt?
    65 pointsBadges:
    report
  • Splat
    How are you building your scripts now?
    12,915 pointsBadges:
    report
  • Splat
    I'd do something like this:

    Source_stmf 	= '/qsys.lib/[library name].lib/CAPRDLVL.file/CAPRDLVL.mbr';
    
    Target_stmf 	= 'SHAK-CTXSTA-TST-'
    	    	+ %char(%Date(): *ISO0)
    		+ '-'                  
    		+ %char(%Time(): *ISO0)
    		+ '-PRODUCTLVL.txt';
    
    Script_record	= 'put '
    		+ %trim(Source_stmf)
    		+ ' '
    		+ %trim(Target_stmf);
    12,915 pointsBadges:
    report
  • chasattard

    Thanks Splat. Here is a typical FTP script that is used on our AS/400.

    etl liz2000
    cd /home/etl/itrack/ecomm/interface/incoming
    ut testdata/cvol CVOL.TMP                    
    >rename CVOL.TMP CVOL.dat                     
    quit

    How would your suggestion look in an actual script?

    65 pointsBadges:
    report
  • Splat
    Something like this:

    put /qsys.lib/[library name].lib/CAPRDLVL.file/CAPRDLVL.mbr SHAK-CTXSTA-TST-[yyyymmdd]-[hhmmss]-PRODUCTLVL.txt

    Excepting the rename command - there's no need to rename the file on the target system if you put it out with the desired name - your statements preceding and following the put command wouldn't change.
    12,915 pointsBadges:
    report
  • ToddN2000
    We FTP using to CL files, one is the program and another with the FTP commands.
    PGM
    ======
    PGM        PARM(&LIBRARY)                                
    DCL        VAR(&LIBRARY) TYPE(*CHAR) LEN(10)             
    CRTSAVF    FILE(QGPL/&LIBRARY)                           
                                                             
    SAVLIB     LIB(&LIBRARY) DEV(*SAVF) SAVF(QGPL/&LIBRARY) +
                 TGTRLS(*CURRENT)                            
                                                             
    OVRDBF     FILE(INPUT) TOFILE(MYSRCLIB/QCLSRC) +        
                 MBR(FTPCMDS)                                
    OVRDBF     FILE(OUTPUT) TOFILE(MYSRCLIB/QCLSRC) MBR(FTP)
                                                             
    FTP        RMTSYS('10.10.10.1')                           
    DLTF       FILE(QGPL/&LIBRARY)                           
                                                             
    ENDPGM 
    
    COMMANDS
    =========
    open TARGET                   
    user USERID  PASSWORD            
    bin                             
    PUT qgpl/sndCPY      qgpl/sndCPY
    close                           
    QUIT
    Something like this may work for you. You could clear the command file and rebuild it line by line in a RPG program using this method. Then run your CL program.
    C/EXEC SQL                                                       
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&OPENSTRING) 
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&LOGINSTRING) 
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&BINSTRING) 
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&FILESTRING) 
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&CLOSESTRING)
      C+ INSERT INTO MYSRCLIB/QCLSRC (FTPCMDS) VALUES(&EXITSTRING)       
      C/END-EXEC
    135,465 pointsBadges:
    report
  • chasattard
    Hi Splat. My problem is how do I imbed the current date/time into the file name. The date/time will be unique each time a file is sent. Your last example shows [YYYYMMDD]-[HHMMSS] in the middle of the filename. Is this a parameter or keyword that retrieves the date/time when the ftp script is run?
    65 pointsBadges:
    report
  • Splat
    chasattard, how are you building the script now?
    12,915 pointsBadges:
    report
  • chasattard
    Thanks to you all. You gave me some good ideas. I ended up creating the FTP script with the appropriate commands and file names using PDM. Then I wrote an RPG program to read the script from the SRCF and update the Date/Time stamp on the TO file in the PUT statement. The RPG program will be run just before the FTP command in a batch CL program. This way the Date/Time stamp will always be current for when the FTP is done.
    65 pointsBadges:
    report
  • Splat
    Glad you found a solution that works for you.
    12,915 pointsBadges:
    report
  • ToddN2000
    Glad we could offer our assistance.
    135,465 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.

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

Following

Share this item with your network: