Page 1 of 1

FTP: convert dataset to UTF-8

PostPosted: Wed Jan 20, 2016 4:25 pm
by davidinmotion
I need to convert a Host dataset from EBCDIC to UTF-8, and transfer it to my PC.
is there any jcl, I can put into the FTP step to convert the dataset while transfering to the PC?

i work on IBM ZOS, Complete

Here is the JCL for my usual FTP Host to PC:

//FTP EXEC PGM=FTP,PARM='(EXIT'                   
//SYSTCPD  DD DSN=SYS1.TCPPARMS(TCPDATA),DISP=SHR   
//SYSFTPD  DD *                                     
TRAILINGBLANKS TRUE                                 
SBDATACONN TCPIP.STANDARD.GERSOND                   
//SYSPRINT DD SYSOUT=*                             
//OUTPUT   DD SYSOUT=*                             
//INPUT DD DSN=Library(Member with server login data),DISP=SHR       
//      DD *                                       
ascii                                               
CD ..                                               
CD /Directory/folder                                   
PUT 'Dataset01' Textfile01.TXT

I found something like:

quote site en=mbcs mb=(utf-8,utf-8)
quote site unicodefilesystembom=never


but dont know if this works for what I want to do, and dont know where to place these two statements.

can anyone help?

[coded for you]

Re: FTP: convert dataset to UTF-8

PostPosted: Wed Jan 20, 2016 6:10 pm
by prino
Given the right host and PC code pages, your FTP should do a one-to-one translation of EBCDIC to ASCII, and there are about a zillion tools to convert ASCII to UTF.

Re: FTP: convert dataset to UTF-8

PostPosted: Wed Jan 20, 2016 6:24 pm
by davidinmotion
OK, the thing is, I need to convert the dataset within the JCL because this schould be part of an automatic host-batch-process. I have also an Natural program that does the conversion but I just wondered if I could do this without an extra step and the Natural program or other tool? Just if there is a JCL for the conversion, it would be great if you could post an example!

Re: FTP: convert dataset to UTF-8

PostPosted: Wed Jan 20, 2016 6:35 pm
by Robert Sample
You are asking at the wrong place. FTP in JCL is CLIENT FTP, so you need to find out if the server you are using supports EBCDIC to UTF-8 translation (and if so, how). Unless you are sending to another mainframe, z/OS will NOT be involved in the translation when it is done in the FTP.

You could transfer the data set to a Unix file and use iconv on the Unix file to convert from IBM-1047 to UTF-8, then FTP the converted Unix file directly from Unix to the server.

Re: FTP: convert dataset to UTF-8

PostPosted: Fri Jan 22, 2016 6:14 pm
by davidinmotion
Thank you, I did it like you suggested above and now it works!

copy to unix file:

//COPY01  EXEC PGM=IEBGENER,REGION=1M         
//SYSPRINT DD SYSOUT=*                       
//SYSUT1 DD DSN=Dataset,DISP=SHR     
//SYSUT2    DD PATH='/srv/directory/file',           
//          PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
//          PATHMODE=(SIRWXU,SIRWXG,SIRWXO), 
//          FILEDATA=TEXT                     
//SYSIN    DD DUMMY   


conversion with iconv:

//CONV01   EXEC PGM=BPXBATCH,                                     
// PARM='SH iconv -f IBM-1047 -t UTF8 /srv/directory/file > /srv/directory/fileNew


//*******************************************************         
//* RUN BPXBATCH TO CKSUM PASSED FILE *                           
//*******************************************************         
//BPXBATCH EXEC PGM=BPXBATCH,                                     
// PARM='SH cksum /srv/directory/fileNew'                                   
//STDOUT DD PATH='/srv/directory/cksmout.fileNew',PATHOPTS=(OWRONLY,OCREAT),
// PATHDISP=(KEEP,DELETE),PATHMODE=(SIWUSR,SIXUSR,SIRUSR),       
// FILEDATA=TEXT,LRECL=27994,RECFM=VB,BLKSIZE=27998


copy converted unix file back to Host dataset:

//COPY02    EXEC PGM=COZBATCH
//SYSPRINT DD SYSOUT=*       
//STDIN    DD *             
cp -B  /srv/directory/fileNew Ö       
 "//'OutputDataset'"       
//SYSOUT   DD SYSOUT=*


And then just the usual FTP to PC '

{coded for you - please do your own next time}

Re: FTP: convert dataset to UTF-8

PostPosted: Fri Jan 22, 2016 6:30 pm
by Robert Sample
Glad to hear you got it working.