COBOL

COBOL

COBOL

COBOL is responsible for the efficient, reliable, secure, and unseen day-to-day operations of the world's economy.

 View Only
  • 1.  utf-8 file from mainframe to USS

    Posted Mon January 29, 2018 10:25 AM

    Hello,

    I hope somebody can help me out, I have a dataset on the mainframe (an unload from a DB2 system table), the file is VB utf-8.

    The file is needed on USS so I transferred it, but no matter what I tried sofar,  when transferred the file on USS is one long record where I expected a file with multiple records like it was before transfer.

    I tried OCOPY,  OPUT, ICEGENER, BPXCOPY and FTD but the results are all the same, a file with one long record on USS.

    I'm probably missing something but what is the way to do this right.

     

    Thanks in advance,

    Iwan Mensink

     

    Iwan_Mensink


  • 2.  Re: utf-8 file from mainframe to USS

    Posted Wed January 31, 2018 01:28 PM

    I'm not sure I understand the question. 

     

    You have a dataset on z/OS, an unloaded DB2 system table, in UTF-8 format.  You are trying to transfer it into the USS file system on the same system, or to a different system?  What are you using to open/process the dataset in USS?

     

    All that said, z/OS utilities don't natively handle UTF-8 encoded files, though some things, like the ISPF editor, can cope with them.  So none of the tools you're trying to use are going to be able to translate the raw unicode data into something you can directly read in the file system.  You might be able to use one of the tools described here:  http://www.longpelaexpertise.com.au/ezine/LostinTranslation3.php.  You could try, for example, using ICONV to convert the DB2 system table to EBCDIC or ASCII, and then use one of the transfer commands to move it into the file system.  But you may need to write a program if you want to both do the conversion and preserve the line breaks.

     

    This might do what you want:  iconv  -s -t IBM-1047 -f UTF-8 <(cat //\'DATASET.PREFIX\(MEMBER\)\').  But without more detail, it's hard to know.

    Kevin McKenzie


  • 3.  Re: utf-8 file from mainframe to USS

    Posted Thu February 01, 2018 06:10 AM

    Hi Kevin,

    Thanks for your response, it was indeed a dataset on z/OS, an unloaded DB2 system table, in UTF-8 format and I was trying to transfer it into USS on the same system.

     

    Yesterday a collegue discussed the subject with an other collegue and he came with the tip that worked for me.

    Yesterdayevening, I tried using "BPXBATCH SH cp -F crlf" and this gave me the file with records I wanted. 

     

    Your question about what I'm using for opening the dataset is relevant btw. I'm using IDz to open the resultset on uss, the default text-editor showed me the file with records, but from the second line all starting with a "%" , when using UDLIST (z/OS UNIX Directory List), the %-signs are not there. So it seems the default editor is messing things up.

    Thanks again for your response, because I was already wrestling with this problem for some time.

    Kind regards,

    Iwan Mensink    

     

     

    Iwan_Mensink


  • 4.  Re: utf-8 file from mainframe to USS

    Posted Thu February 01, 2018 03:55 PM

    Hi,

    What cp -F crtl does is to copy the records as text, remove all the trailing blanks (0x40)s and add 0x0d,0x25  at the end.

    0x0d is "\r" (carriage return) in ascii as well as in ebcdic.

    0x25 is "\n" (line feed) in ebcdic, "%" is 0x25 converted from ascii to ebcdic (again!).

    your editor convert the file to ebcdic that is why you see %

    That means using cp -F crtl is wrong, because the original data is not ebcdic.

    Assuming your file is in VB and you don't have a compiler, here is what you can do:

    1. ftp with this options

    • binary
    • quote site rdw

    • get '//FULLY.QUALIFY.DSNAME' ./local.tmp

    local.tmp will be a binary file with rdw information at the begining of each record.

    2. convert with this rexx code.

    • ./conv.rexx ./local.tmp ./output.txt

    This discards the rdw and add a 0x0a at the end of each record.

    /* rexx */parse arg fi fou=charin(fi, , 1)rdw=0len = 0call charout fo,,1do while length(u) = 1  select    when rdw = 0 then do ;      len = c2d(u) ; rdw = 1 ;    end    when rdw = 1 then do ;      len = len + c2d(u) ; rdw = 2 ;    end    when rdw = 2 then do ;      if (c2d(u) != 0) then do ;        say "rdw of "fi" is broken" ; exit 1;      end ; rdw = 3 ;    end    when rdw = 3 then do ;      if (c2d(u) != 0) then do ;        say "rdw of "fi" is broken" ; exit 1 ;      end ;      len = len - 4 ; rdw = -1 ;    end    otherwise      if (len > 0) then do;        err = charout(fo, u)  ; len = len - 1 ;        if len = 0 then do  ;          rdw = 0 ; err = charout(fo, d2c(10)) ;        end      end  end  if err != 0 then do; say fo " write error" ; exit 1 ; end  u=charin(fi, , 1)end
    ccw


  • 5.  Re: utf-8 file from mainframe to USS

    Posted Fri March 23, 2018 12:12 PM

    When you need to process UTF-8 data, first convert the data to UTF-16 in a national data item. After processing the national data, convert it back to UTF-8 for output. For the conversions, use the intrinsic functions NATIONAL-OF and DISPLAY-OF, respectively. Use code page 1208 for UTF-8 data. You need to do two steps to convert ASCII or EBCDIC data to UTF-8: 1. Use the function NATIONAL-OF to convert the ASCII or EBCDIC string to a national (UTF-16) string. 2. Use the function DISPLAY-OF to convert the national string to UTF-8. .. ShowBox VidMate Mobdro 

    athman


  • 6.  Re: utf-8 file from mainframe to USS

    Posted Mon March 26, 2018 02:47 AM

    Thanks for your answer Athman,

    I do know when working with UTF8 in cobol I need to convert it to UTF-16, the problem was that I had a valid dataset  in UTF8 on MVS and I wasn't able to transfer it to USS in the way I wanted. For my problem using "BPXBATCH SH cp -F crlf" did the trick. As you can read in the answer of cww this will not always be the solution and there is more to say about the transfer but in my situation it worked fine.   

    Iwan_Mensink