text file to iSeries spooled file

pts.
Tags:
tips and tricks
Tools
What's the best way to duplicate a windows text file, containing page break characters, into a iSeries spooled file. I'm not familiar with RPG so if I can accomplish this using CL command and queries that would be great. I have software that processes spooled file reports so I'd like to try this with an external text file. Thanks,

Answer Wiki

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

My first thought would be to import file to iSeries & then query the file. You would have to recreate page breaks.

Another possibility would be to create an AFP printer (IBM 4028) that prints to a file instead of a device. Print the text file using the AFP printer to a shared folder on the iSeries. Create a physical file (CRTPF FILE(LIB/FILNAME) RCDLEN(256) MAXMBRS(xxx) LVLCHK(*NO)). Next copy the doc from from the folder to a physical file (CPYFRMPCD FROMFLR(FOLDERNAME) TOFILE(LIB/FILNAME) FROMDOC(DOCNAME.PRN) TRNTBLE(*NONE) TRNFMT(*TEXT)). Now you have a physical file that you could try to create a spooled file from. Or you could create an overlay from here, I’m not sure what the results would be with a multi-page file CRTOVL OVL(LIB/OVLNAME) FILE(LIB/FILNAME) DATATYPE(*AFPDS).

Not sure if this solves your problem or not but hopefully it will give you a start.

Discuss This Question: 5  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.

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
    I think it would depend on how the user will be involved. For example, you could create a printer share that is associated with an AS/400 printer/outq. The user might simply print the file from Windows and the spooled file would end up in the AS/400 outq. AS/400 printers can be shared through Windows Network Neighborhood. Or, because user spaces and IFS streamfiles are effectively the same object types (as far as many functions are concerned), it's pretty easy to copy IFS streamfiles into user spaces; the user space content can then be accessed directly through a CL program by user space APIs. Or perhaps various QShell utilities would be more useful. Can you elaborate on the procedure that the user will go through?
    125,585 pointsBadges:
    report
  • DietmarTodtenhoefer
    another option will be to FTP the text file to a Printer File: The iSeries FTP server permits a client to write to a printer file. Here's how it works. First, create a program-described printer file. crtprtf mylib/myprtf outq(myoutq) . . . Second, use the put subcommand in an FTP client to write to the printer file. The following command prints file data.txt, which is in the temp directory of the client machine, on the iSeries. put /temp/data.txt mylib/myprtf
    0 pointsBadges:
    report
  • Pmaurice32
    Thanks for your feedback. I'm basically testing this spooled file with Robot REPORTS to see if it could burst properly in their application. Here's what I did but it's still not perfect. My CL program looks like this: PGM CPYFRMPCD FROMFLR(AM2000) TOFILE(GARAA06) + FROMDOC(GARAA06.001) TRNTBL(*DFT) + TRNFMT(*TEXT) OVRPRTF FILE(QPQXPRTF) PAGESIZE(66 134) LPI(6) + CPI(16.7) OVRFLW(66) OUTQ(REPTEST) STRQMQRY QMQRY(FLAT) OUTPUT(*PRINT) DATETIME(*NO) + PAGNBR(*NO) DLTOVR FILE(QPQXPRTF) ENDPGM My 'FLAT' query is basically a 'select all' on PF GARAA06. I still have a couple of small issues, one being the page break which is not a biggie but the other is that the field name of my PF appears on the spooled file and this is giving me grief. I'll double check with the vendor. Thanks, Pauline
    0 pointsBadges:
    report
  • TomLiotta
    I'm a little confused. Why would you have printer-control characters in the document? That is, I'm aware that such characters are placed in documents by various PC applications, but those wouldn't normally be documents that would be expected in an OS/400 output queue -- they'd be expected to be sent as text to an ASCII printer. Perhaps that's all you want. Create a printer file of DEVTYPE(*USERASCII) and just use CPYF. That's probably pretty simplistic, but I don't have a printer I can do any testing with. Nor am I yet completely clear on exactly what you need. Your attempt with STRQMQRY gives a clue. If that's the route you want to go and it _almost_ works for you, consider creating a *QMFORM object to customize the headings. I'm not sure they can be _completely_ eliminated. Still, I'd probably go with QShell utilities for this. You might want to review the pr utility. This is specifically designed to "PRint" files. For example: ==> sbmjob cmd(QSH CMD('pr myfile.txt')) ...would print the contents of myfile.txt to printer file QPRINT on my system. Normally, pr will output to 'standard output' which would be a terminal display. By submitting to batch, standard output is automatically routed to a printer file. Other methods can be used to control output, but this provides a trivial example. If the job contains an override such as: ==> ovrprtf QPRINT devtype(*USRASCII) ...you might get some direct response from the embedded control characters. Again, I don't have a suitable device. Beyond that, if you don't actually want those control characters to really be in control, other QShell utilities such as grep and sed can be used to detect the characters in the input stream and insert what's needed in the output. It should be possible to create a generic QShell script that could handle any similar input file. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    After some communication, I think I understand the issue. You will be receiving PC documents that will have form-feed characters embedded. You have no control over this; you're essentially stuck with it. You currently have a test document that should work out to 5 pages, i.e., the document contains some lines, then a form-feed character, more lines, another form-feed character, etc., with at least four form-feeds that should result in five sections and each section should have a page break. All of this would work fine if routed to a PC printer. You want the document to print on an AS/400 system printer so that its form looks like it would on the PC printer. Specifically, you want the pages to break every time a form-feed appears. (Because sections might be longer than 66 lines, sections _might_ be more than single pages. Additional page breaks are okay as long as the form-feeds cause their breaks also.) With that all in mind, consider what happens when you use CPYSPLF to copy a spooled file to a physical file. The printed data occupies the right-most portion of the records. The left-most positions get printer-control characters placed in them. If you run CPYSPLF and specify the CTLCHAR(*FCFC) parameter option, just the single left-most character position is used for control characters. That would be very close to what would happen if you copied your text file into a physical file and had the data moved one position to the right. Of course, that would have all blanks in the control character position, so not very useful. But how about an SQL statement that output all normal printlines as a single space concatenated to the data, which would shift the data one position to the right, and all form-feed lines as having a character '1' in position 1 with the rest of the line blank? Once that was done, you could use CPYF to put your new file to an outq as in: ===> ovrprtf QPRINT ctlchar(*FCFC) ===> cpyf NEWFILE QPRINT The output should be spooled at that point. The tricky part might be in the SQL, especially if the text document is in ASCII. Do you want ASCII or EBCDIC output? 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