40 pts.
 How to convert RPG to a .txt file
How do you take a regular source member and convert it a .txt file?

Software/Hardware used:
ASKED: August 31, 2009  9:38 PM
UPDATED: September 3, 2009  3:00 PM

Answer Wiki:
From STRPDM, select option 6 to print then open the spooled ouptut with iSeries Nav. It will be opened with Notepad as .TXT file and from there you can save, print, email, etc.
Last Wiki Answer Submitted:  August 31, 2009  11:49 pm  by  Whatis23   5,665 pts.
All Answer Wiki Contributors:  Whatis23   5,665 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I am familiar with your solution – but it’s not the one I was looking for – the .TXT should only contain source records – not records that contain page headers/footers

I want to loop through a source file and for each member get a .TXT member created on my PC in a pre-defined path. If there was some way I could use the API that Client Access uses to “Receive file from Host”

The solution I seek is only temporary – so any 3rd party utility with a free trial would work for me

 40 pts.

 

You could download each source member to a text file via the iSeries Access file transfer function, or you could copy the source file member to an ASCII text file in the IFS via the CPYTOIMPF command. If you use CPYTOIMPF, it would be easier to automate in a CL program.

 4,275 pts.

 

You can create a CL program to read the member list for the source file. FOr each member name, use either the CPYTOPCD command – which will create a copy of the source member’s DATA field as a PC TEXT document in a subfolder under QDLS, or the CPYTOSTMF command, which will create a very similar file in ANY folder in the IFS.

For example, the two commands below show how to create a TEXT file for a source member using both commands:

CPYTOPCD FROMFILE(TGSMSRCTRI/QRPGLESRC) TOFLR(BLECMD) FROMMBR(WIRCSVF)

- creates a file called WIRCSVF in ASCII TEXT format in folder QDLS/BLECMD

CPYTOSTMF FROMMBR(‘QSYS.LIB/TGSMSRCTRI.LIB/QRPGLESRC.FILE/WIRCSVF.MBR’) TOSTMF(‘/blecmd/wircsvf.txt’) STMFOPT(*REPLACE) STMFCODPAG(*STDASCII)

- creates a file called WIRCSVF.TXT in Standard ASCII TEXT format in IFS folder (root/) BLECMD.

Note that if you use some special characters in your source (such as dollar or pound-sterling signs), these might not translate the way you expect.

The resulting files will NOT contain the SRCDAT and SRCSEQ fields – only the SRCDTA field from the source member.

Regards,

Sloopy

 2,195 pts.

 

You could ftp the source members from the system to the your PC. You don’t have to do any special program and you can name the source member with an extension of txt.

 1,145 pts.

 

Hi,

We created an PDM option to that for us:

Option . . . . . . . . : ST

Command . . . . . . . . : CPYTOSTMF FROMMBR(‘/qsys.lib/&l.lib/&f.file/&n.mb
r’) TOSTMF(‘/tmp/&n.&t’) STMFOPT(*REPLACE) STMFCODPAG(*PCASCII) ENDLINFMT(*CRLF)

And just use ST on each source to convert.

Wilson

 2,385 pts.

 

I once stumbled upon a PC BAT file called GETALLSRC. It uses FTP from PC to get source files from your iSeries.

@ECHO OFF
IF %1.==. GOTO problem
IF %2.==. GOTO problem
IF %3.==. GOTO problem
IF %4.==. GOTO problem
IF %5.==. GOTO problem
cls
ping %3 -n 2 | find /i “reply” >nul && goto getfils
echo System does not exist on the network! & goto End
:getfils
cls
F:
cd
cd sources
md %3
cd %3
md %4
cd %4
md %5
cd %5
rename *.txt *.MBR
ECHO open %3 >FTPSRC.TXT
ECHO user %1 >>FTPSRC.TXT
ECHO %2 >>FTPSRC.TXT
ECHO ascii >>FTPSRC.TXT
ECHO PROMPT >>FTPSRC.TXT
ECHO QUOTE SITE NAMEFMT 1 >>FTPSRC.TXT
ECHO MGET /QSYS.LIB/%4.LIB/%5.FILE/*.MBR >>FTPSRC.TXT
ECHO quit >>FTPSRC.TXT
ftp -n -s:FTPSRC.TXT
DEL FTPSRC.TXT
rename *.MBR *.txt
GOTO END
:problem
cls
ECHO —————————————————–
ECHO Type in : GETALLSRC USER PASSWORD SYSTEM LIBRARY FILE
ECHO —————————————————–
ECHO USER = user profile to use for FTP
ECHO PASSWORD = password for user profile to use for FTP
ECHO SYSTEM = name of the system you wish to FTP from
ECHO LIBRARY = name of the library you wish to FTP from
ECHO FILE = name of the file you wish to FTP from
:END

 2,250 pts.

 

I think WilsonAlano’s solution is fine (see above). I use this cmd (option ‘SF’ for StreamFile) in PDM (slightly different to Wilson’s):

CPYTOSTMF FROMMBR('/qsys.lib/&l.lib/&f.file/&n.mbr')
          TOSTMF('/temp/&n.&s')                     
          CVTDTA(*NONE)                             
          STMFCCSID(*PCASCII)                       
          ENDLINFMT(*CR)                            

With this option ‘ST’ in my PDM + cmd13 (dup option) I moved 500+ sourcemembers to the IFS in a split of a second.

Sample codestring that was executed from my ‘SF’-option:

CPYTOSTMF FROMMBR('/qsys.lib/mylib.lib/QALLSRC.file/A_1.mbr')
          TOSTMF('/temp/A_1.txt')
          CVTDTA(*NONE)
          STMFCCSID(*PCASCII)
          ENDLINFMT(*CR)
 2,540 pts.

 

Open WDSc.
Add the source member to an iSeries Project.
Export the source member to your local hard drive.

 1,130 pts.