Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EBCDIC to ASCII conversion 1

Status
Not open for further replies.

tampakenny

Programmer
Mar 6, 2003
3
US
I'm running on a z/OS mf and trying to do a simple EBCDIC to ASCII conversion. I need an ASCII input file to create a self-decrypting archive in PGP on the mainframe for later FTP and use on a Windows platform. I can FTP the process input to the server in ASCII mode, then back to the mf in binary mode and that accomplishes the goal, but isn't exactly the best solution. I've tried setting a Special-Names alphabet clause to standard-1 and adding code-set to the FD. It compiles, but doesn't run (it gets an open error on the output). All the program does is read the input record, and immediately write the output record from the input area. Does anybody have, or know where to link to, some simple COBOL examples of a process that will do this, including the DD's from the jcl? Other suggestions included ALTSEQ in sort, or REXX translate, neither of which was particularly palatable based on the setup of each hex value and it's counterpart.
 
Apparently the file must be assigned to mag tape :-(

Glenn
 
I think the mag tape is what was causing the problem. I was getting an IEC141I 013-70. It's a small dasd file and I was hoping for some standard IBM utility, programming function, something I could use to do a quick E to A conversion of a dasd file. I may have to track the file back upstream somewhere. If it's original source was a server, I'll just send it up binary and render this whole conversion research moot. Thanks for the response.
 
Since this is a COBOL forum, perhaps a COBOL solution would be an appropriate answer.

Write a COBOL program to copy the file, specfying that the output file is ASCII.
 
Webrabbit -

I tried that. My original post dealt with setting up an alphabet clause in the special-names area, then adding a code-set line to the FD in a COBOL program. That was failing, hence my post to the COBOL forum. A COBOL solution would be wonderful, but ALAS, it looks as though one doesn't fit my particular needs. Thanks anyway.
 
When we want to make ASCII files we just write what we want to a temporary file VSAM no key then run a program that transfers it to the transfer file area and use FTP to send it. We have also written jobs that run in the background that use the utilities that FTP files directly to a server when we run the checks.

We generally use utilities from Barnard Software for the FTP Package.

If you write the temporary file with no packed fields it is a pretty simple job to ftp an ASCII only file which is not a Comma Separated Variable length file but pure ASCII.

We also use a package on our mainframe from a company Near Princeton, NJ, called Decision Analyzer. It can querry a database or a VSAM Keyed file/files and save it as a Excel or CSV or text file.

There are other products that may do much the same thing like easy trieve (Spell). Why reinvent the wheel.

If you do not like my post feel free to point out your opinion or my errors.
 
tampakenny,
Here's a little snippet I use. Started out as Unisys mainframe code, now use it in Microfocus. It's flipped around backwards right now(CONVERTS ASCII TO EBCDIC). All you need to do is comment/uncomment the "CODE-SET IS" in the FD's to make it go the other way.

Code:
 PROGRAM-ID.  EBCASC.                                  
*CONVERT BETWEEN ASCII AND EBCDIC                      
 ENVIRONMENT DIVISION.                                 
 CONFIGURATION SECTION.                                
 SPECIAL-NAMES.                                        
     ALPHABET EBC IS EBCDIC.                           
 INPUT-OUTPUT SECTION.                                 
 FILE-CONTROL.                                         
     SELECT IN-FILE                                    
         ASSIGN TO "C:\INFILE.TXT"                     
         ORGANIZATION IS LINE SEQUENTIAL.              
     SELECT OUT-FILE                                   
         ASSIGN TO "C:\OUTFILE.TXT"                    
         ORGANIZATION IS LINE SEQUENTIAL.              
 DATA DIVISION.                                        
 FILE SECTION.                                         
 FD IN-FILE                                            
*    CODE-SET IS EBC                                   
 .                                                     
 01  IN-REC      PIC X(60).                            
 FD OUT-FILE                                           
     CODE-SET IS EBC                                   
 .                                                     
 01  OUT-REC      PiC X(60).                           
 WORKING-STORAGE SECTION.                              
 01  IN-FILE-EOF                 PIC X(01) VALUE "N".  
 PROCEDURE DIVISION.                                   
 BEGINNING.                                            
     OPEN INPUT  IN-FILE                               
          OUTPUT OUT-FILE.                             
     PERFORM READ-IN-FILE.                             
     PERFORM PROC-IN-FILE                              
       UNTIL IN-FILE-EOF = "Y".                        
     CLOSE IN-FILE.                                    
     CLOSE OUT-FILE.                                   
     STOP RUN.                                         
 READ-IN-FILE.                                         
     READ IN-FILE                                      
       AT END MOVE "Y" TO IN-FILE-EOF.                 
 PROC-IN-FILE.                                         
     MOVE IN-REC TO OUT-REC.                           
     WRITE OUT-REC.                                    
     PERFORM READ-IN-FILE.

Tranman
 
It is true that (on z/OS or OS/390 or even MVS) that to use the CODE-SET phrase for "file" converion, you must be using TAPE files (and DCB=OPTCD=Q).

However, to do EBCDIC/ASCII (or vice versa) "data" conversion (that you can then write to a disk file, see:




Bill Klein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top