Posted on 2005-04-26 07:19:29-07 by pug
Convert ASCII to EBCDIC on OS390 character set 1047
Hi
I was recently asked to convert Ascii to ebcdic packed for a os390 mainframe, I'm using the packeb function but the client says it is not the desired output. I'm a bit clueless of the mainframe enviroment, if there is someone that can advise.
I wrote a small script just to test the output here goes:...

Difinition & Layout
These are 6 fields of a 97 field layout
--------------------------------------------------------
FLD W 80 A
FLD-1 FLD 2 P VALUE 001 [Pic s9(3) Comp-3]
FLD-2 FLD +02 2 P VALUE 001 [Pic s9(3) Comp-3]
FLD-3 FLD +04 3 P VALUE 00000 [Pic s9(5) Comp-3]
FLD-4 FLD +07 2 P VALUE 000 [Pic s9(3) Comp-3]
FLD-5 FLD +09 3 P VALUE 00000 [Pic s9(5) Comp-3]
FLD-6 FLD +11 5 A VALUE 'FNUT ' [Pic x(5) ]
---------------------------------------------------------
Code

Here is the code I tried. I don't know how to test the output I currently send it to the client,to test it on the mainframe, but if you know of a win32 viewer that I can use to test the output for OS390, will be awsome.
----------------------------------------------------------------
#!c:\perl\bin\perl -w use Convert::IBM390 qw(:all); unless (open(OUTPUT, ">a2e.txt")) { die ("cannot open configuration file \n"); } @var=("001","001","00000","000","00000","FNUT"); foreach(@var) { print $_; } #$template='p1.0 p1.0 p3.0 p1.0 p3.0 E5'; $template='p3 p3 p5 p3 p5 E5'; $ebout = packeb($template, @var); print OUTPUT ($ebout);
------------------------------------------------------------------------

Thank You
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.