IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFsort convert from hex/bin to character


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Mon Aug 14, 2006 7:57 pm
Reply with quote

Hi,

I've got the following (MVS) input file record (partial record) and HEX ON
??-
A56
A20

The above field in the record is not defined as HEX or BInary or anything, but take it for granted that this is the field and I want to read in and I would like to output it in Character.
In other words, can I read the 1st byte in and output it as character AA ?
Not sure how you would define it as an input since it looks like a Hex value x'AA'. The file that comes in to me has not standard format when outputing the values. Example: The input may be numeric (i.e. 12345678) and this process will output it as follow:

?? <-- hex value with HEX ON
1357
2468

or if the input was ABC123 then it would output it as

?A
AC2
B13

So I would like to read them in and output them as follow:

12345678
ABC123

Thanks
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Mon Aug 14, 2006 8:18 pm
Reply with quote

The problem is that the input file (field itslef) is no defined as binary or Hex but just Character (i.e. in cobol the input layout is defined as Character) example:

FieldA x(04)

But I read the field 1 byte at a time (i.e. X(01) ) and then look at the 2 bytes (i.e. AA) and then write them out as AA to my output file.
The reason for this is because the file that I am reading in has been created thru a weird system where it outputs the fields (character and numeric) in an unknown format...

Example: Input field is a Serial number ABC123 and any normal person :-) would output it as a x(6) character and off you go. In my case the field is inserted to a file in the following format (unknown and not HEX or BINARY):

AC2
B13

So I want to read this in and output it as ABC123...

I know how to read in a PD or BI format, that is simple, but when it is a single byte you want to read 1 at a time and reformat it from

A
B

TO

AB

That is what I want to know...

Thanks
Back to top
View user's profile Send private message
cheetz007

New User


Joined: 10 Aug 2006
Posts: 23

PostPosted: Mon Aug 14, 2006 8:30 pm
Reply with quote

OK, I get you! Weird!

So, a single record (say ABC123) is x'ABC123' (but not hex!)? Is it possible to have GHI123 or does it stop at the usual hex characters?

Where does this file come from. Presumably whatever creates it also has an algorythm for decoding it?
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Mon Aug 14, 2006 8:48 pm
Reply with quote

Basically, I want to be able to read a sigle byte as an example

Input...................dfsort output
=====...............==========
A............................AA
A

A............................A*
*

A............................A1
1

1............................12
2

etc...

Without any standard format (hex or binary).

I have a cobol program that interprets this thru cobol coding, but I was hoping that I can use DFSORt (short and sweet) to replace the cobol programs.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Aug 14, 2006 9:38 pm
Reply with quote

Yianis,

If I understand what you want correctly, you're presenting it as more complicated than it is. The input is binary. The output you want is hex. You can use the following DFSORT control statements to do this:

Code:

   OPTION COPY
   OUTREC FIELDS=(1,n,HEX) 


where n is the number of bytes you want to convert from binary to hex.
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Mon Aug 14, 2006 11:35 pm
Reply with quote

Hi Frank,

You are absolutely right!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It was a lot more simpler than I made it out to be. I made it more difficult for myself.

You are Amazing !!!

Thanks,

Yianis
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 12:33 am
Reply with quote

I have another question....

I need to add a header and a trailer record too..

Here is what I got so far:

Code:

  SORT FIELDS=COPY                                                     
  INCLUDE COND=(01,02,BI,EQ,X'04')                                     
  OUTFIL OUTREC=(C'IRO',                   
               C'   ',                 
               DATE1,                 
               20,4,HEX,                     
               24,7,HEX,                           
               12,7,HEX,             
               C' ',                     
               34,5,HEX,              * AMOUNT                       
               02,4,BI,                 
               C' ',                 
               427C' '),                                             
  HEADER1=(C'HDR',C'ABCD',C'300',C'CDN',C'WEBIR',                     
         DATE,TIME,76C' '),                                         
  TRAILER1=('TRL',                                                     
          COUNT=(M11,LENGTH=10),                                     
          SUMMED AMOUNT ?????? from input 35,5,hex above                                     
          472C' ')               


First, i need to create my output file as RECFM=FBA why ????
Also, how do I include the summed amount field above
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 15, 2006 1:13 am
Reply with quote

You don't need 76C' ' in HEADER1 or 472C' ' in TRAILER1. DFSORT will pad out the header and trailer with blanks automatically.

Quote:

INCLUDE COND=(01,02,BI,EQ,X'04')


will actually look for X'0400' in 1-2 - is that what you want.

Quote:
First, i need to create my output file as RECFM=FBA why ????


By default, DFSORT uses FBA and ANSI carriage control characters for reports so it can do page ejects, etc. If you want FB and no carriage control characters, just specify REMOVECC on your OUTFIL statement.

Quote:
SUMMED AMOUNT ?????? from input 35,5,hex above

Also, how do I include the summed amount field above


Do you mean the 34,5,HEX field?

This DFSORT job will do what I think you're asking for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file  (FB/?)
//SORTOUT DD DSN=...  output file (FB/500)
//SYSIN    DD    *
  SORT FIELDS=COPY
  INCLUDE COND=(01,02,BI,EQ,X'04')
  OUTREC FIELDS=(C'IRO',
               C'   ',
               DATE1,
               20,4,HEX,
               24,7,HEX,
               12,7,HEX,
               C' ',
               34,5,HEX,              * AMOUNT
               02,4,BI,
               500:X)
  OUTFIL REMOVECC,
    HEADER1=(C'HDR',C'ABCD',C'300',C'CDN',C'WEBIR',
         DATE,TIME),
    TRAILER1=('TRL',
          COUNT=(M11,LENGTH=10),
          TOT=(52,10,ZD,M11,LENGTH=10))
/*
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 5:45 pm
Reply with quote

Hi Frank,

Thanks again...

Here is the code:
Code:
SORT FIELDS=COPY                                                     
INCLUDE COND=(01,02,BI,EQ,X'04')                                     
OUTREC FIELDS=(C'IRO',                   
               C'   ',                 
               DATE1,                                   
               20,4,HEX,                     
               24,7,HEX,                             
               12,7,HEX,                         
               C' ',                     
               34,5,HEX,                                     
               02,4,BI,                 
               C' ',                 
               500:X)                                                 
OUTFIL REMOVECC,                                                     
HEADER1=(C'HDR',                                                     
         C'ABCD',                                                     
         C'300',                                                     
         C'CDN',                                                     
         C'WEBIR',                                                   
         DATE,                         
         TIME),                                 
TRAILER1=('TRL',                                                     
          COUNT=(M11,LENGTH=10),                                     
          TOT=(52,10,ZD,M11,LENGTH=15))           



and here is a sample record (LRECL=257):

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
----+----F----+----F----+----F----+----F----+----F----+----F----+----F----+----
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 ------------------------------------------------------------------------------
..9......k???????- .?v.....???......?.....?.{?"`...?????????????????????????
00F22010395AAAAAA6A5640AA20011AAA00030291301180CA77000AAAAAAAAAAAAAAAAAAAAAAAAA
409AA060228AAAAA03A2004A560015AAA00745CFF00F60800F9003AAAAAAAAAAAAAAAAAAAAAAAAA


I just want the '04' records from the file in the 1st byte. This file contains 3 different record formats and I only want the '04' detail records. I guess I just got lucky that the 1st 2 bytes happen to be x'0400', but waht I really want is just the x'04' in the first byte.


Also, in the HEADER1 section, I need the date & time format the same as in the OUTREC FIELDS sections (i.e. YYYYMMDD & HHMMSS. When I change the value from DATE to DATE1, it doesn' like it.

Yianis
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 6:55 pm
Reply with quote

I searched for some documenation on the Date/Time formats and I found the DATENS=(4MD) will output it as YYYYMMDD and the TIMENS=(24) will output it as HHMMSS.


I just realized (duh!!!) that I had INCLUDE COND=(01,02,BI,EQ,X'04')...thinking that I was looking at 1 byte. I realized now what you meant earlier about looking at 2 bytes. My bad..changed it to INCLUDE COND=(01,01,BI,EQ,X'04')

Thanks again... You (Frank) are truly a good resource :-)
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 15, 2006 8:19 pm
Reply with quote

Glad I could help.
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 8:42 pm
Reply with quote

Another question related to the above...

When I use the

Code:
20,4,HEX,
in the outrec fields, it outputs it to 8 bytes. Example: 12345678 (output), but I would like to output it as 1234-5678

I want to put a dash in the middle. Is there a way to do that in the same statement (some editing/formating)?
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 15, 2006 9:19 pm
Reply with quote

You can make the following changes:

Code:

  OUTREC FIELDS=(C'IRO',
...
             20,4,HEX,X,   <------------ Add X
...
  OUTFIL REMOVECC,
    OVERLAY=(15:15,8,ZD,EDIT=(TTTT-TTTT)),  <----- add OVERLAY
    ...
          TOT=(53,10,ZD,M11,LENGTH=10))  <--- 52 -> 53
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 10:11 pm
Reply with quote

Wow, DFSORT has come along way .... I haven't used it for a while and it was basically more for simple extracts and the odd remove duplicates...but it's a lot more than that....Love It ... Will use it or at least try to use it for everything possible.

Thanks !!!!
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 11:09 pm
Reply with quote

Hi Frank,

I have another question... I first tried ti check out on this forum to see if it's there or even some pdf manuals, but I'm a bit tired looking and I will ask you...

I need to update the above to do the following:

There are some header records in my input file and 1 of them have a date field that I need to use to populate the date field in my output.

The current logic :

Code:
OUTREC FIELDS=(C'IRO',                   
               C'   ',                 
               DATE1,
           etc...


I use the DATE1 to output the system date, but I need to read it in from my input file on a header record..

Sample file:

Code:

.L 06/05/06./?.. DKNIN..2006/06/05.............................................
.L 05/08/05./... DKNIN..2005/05/08.............................................
.L 05/08/05./..? DKNIN..2005/05/08.............................................
.L 05/08/05./..? DKNIN..2005/05/08.............................................
.C 05/10/06./..? DKNIN..2006/05/10.............................................
.C 05/10/06./..? DKNIN..2006/05/10.............................................
.F 07/11/05./... DKNIN..2005/07/11.............................................
.I 06/14/06./?.. DKNIN..2006/06/14.............................................
.H 05/15/06./..? DKNIN..2006/05/15.............................................
.I 06/29/06./?.? DKNIN..2006/06/29.............................................
..9......k???????- .?v.....???......?.....?.{?"`...?????????????????????????
..9......k-??????.??- .?v....???...n?.?.....?.{?"`...?????????????????????????


Now I need to read the first record and take the date field 06/05/06 and use that date to populate in place of the DATE1 I had above and in the YYYYMMDD format.

Also,


I need to replace all 'A' with ' ' (blanks) in the input fields defined in the outrec 20,4,HEX & 24,7,HEX

Thanks
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 11:28 pm
Reply with quote

Oh, I did try it in a following step, that is, I created the file first using the code above, and then I used the output file as input to the following step and coded it as follows and it works, but I was just wondering if there is a better way:

Code:
 SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=(24,14,CH,EQ,C'AAAAAAAAAAAAAA'),OVERLAY=(24:14X)),
        IFTHEN=(WHEN=(25,13,CH,EQ,C'AAAAAAAAAAAAA'),OVERLAY=(25:13X)),
....etc
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 15, 2006 11:29 pm
Reply with quote

Quote:
I first tried ti check out on this forum to see if it's there or even some pdf manuals, but I'm a bit tired looking and I will ask you...


The DFSORT books are available online in pdf and BookManager form from:

Use [URL] BBCode for External Links

When you run your jobs, do you get ICE (e.g. ICE000I) messages or WER messages?
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 11:40 pm
Reply with quote

I get ICExxxxx
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Aug 15, 2006 11:43 pm
Reply with quote

Ok, then you're using DFSORT. (Not sure why you mentioned Syncsort in one of your posts, but I corrected it.)

I'll take a look at your new requirements after lunch. If you have anything to add in the meantime, go ahead.
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Tue Aug 15, 2006 11:53 pm
Reply with quote

Hi Frank,

My mistake on Syncsort....

All I did is created another step further to replace the 'A' with ' ' but still working on the Header date field. The 'A' replacing starts from position 25 thru 57 ( I mentioned above 2 fields but I had to add another field since then.

Have a great lunch...

Code:

SORT FIELDS=COPY                                               
OUTREC IFTHEN=(WHEN=(24,1,CH,EQ,C'A'),OVERLAY=(24:X),HIT=NEXT),
       IFTHEN=(WHEN=(25,1,CH,EQ,C'A'),OVERLAY=(25:X),HIT=NEXT),
       IFTHEN=(WHEN=(26,1,CH,EQ,C'A'),OVERLAY=(26:X),HIT=NEXT),
       IFTHEN=(WHEN=(27,1,CH,EQ,C'A'),OVERLAY=(27:X),HIT=NEXT),
       IFTHEN=(WHEN=(28,1,CH,EQ,C'A'),OVERLAY=(28:X),HIT=NEXT),
       IFTHEN=(WHEN=(29,1,CH,EQ,C'A'),OVERLAY=(29:X),HIT=NEXT),
       IFTHEN=(WHEN=(30,1,CH,EQ,C'A'),OVERLAY=(30:X),HIT=NEXT),
       IFTHEN=(WHEN=(31,1,CH,EQ,C'A'),OVERLAY=(31:X),HIT=NEXT),
       IFTHEN=(WHEN=(32,1,CH,EQ,C'A'),OVERLAY=(32:X),HIT=NEXT),
       IFTHEN=(WHEN=(33,1,CH,EQ,C'A'),OVERLAY=(33:X),HIT=NEXT),
       IFTHEN=(WHEN=(34,1,CH,EQ,C'A'),OVERLAY=(34:X),HIT=NEXT),
       IFTHEN=(WHEN=(35,1,CH,EQ,C'A'),OVERLAY=(35:X),HIT=NEXT),
       IFTHEN=(WHEN=(36,1,CH,EQ,C'A'),OVERLAY=(36:X),HIT=NEXT),
       IFTHEN=(WHEN=(37,1,CH,EQ,C'A'),OVERLAY=(37:X),HIT=NEXT),
       IFTHEN=(WHEN=(38,1,CH,EQ,C'A'),OVERLAY=(38:X),HIT=NEXT),
       IFTHEN=(WHEN=(39,1,CH,EQ,C'A'),OVERLAY=(39:X),HIT=NEXT),
       IFTHEN=(WHEN=(40,1,CH,EQ,C'A'),OVERLAY=(40:X),HIT=NEXT),
       IFTHEN=(WHEN=(41,1,CH,EQ,C'A'),OVERLAY=(41:X),HIT=NEXT),
       IFTHEN=(WHEN=(42,1,CH,EQ,C'A'),OVERLAY=(42:X),HIT=NEXT),
       IFTHEN=(WHEN=(43,1,CH,EQ,C'A'),OVERLAY=(43:X),HIT=NEXT),
       IFTHEN=(WHEN=(44,1,CH,EQ,C'A'),OVERLAY=(44:X),HIT=NEXT),
       IFTHEN=(WHEN=(45,1,CH,EQ,C'A'),OVERLAY=(45:X),HIT=NEXT),
       IFTHEN=(WHEN=(46,1,CH,EQ,C'A'),OVERLAY=(46:X),HIT=NEXT),
       IFTHEN=(WHEN=(47,1,CH,EQ,C'A'),OVERLAY=(47:X),HIT=NEXT),
       IFTHEN=(WHEN=(48,1,CH,EQ,C'A'),OVERLAY=(48:X),HIT=NEXT),
       IFTHEN=(WHEN=(49,1,CH,EQ,C'A'),OVERLAY=(49:X),HIT=NEXT),
       IFTHEN=(WHEN=(50,1,CH,EQ,C'A'),OVERLAY=(50:X),HIT=NEXT),
       IFTHEN=(WHEN=(51,1,CH,EQ,C'A'),OVERLAY=(51:X),HIT=NEXT),
       IFTHEN=(WHEN=(52,1,CH,EQ,C'A'),OVERLAY=(52:X),HIT=NEXT),
       IFTHEN=(WHEN=(53,1,CH,EQ,C'A'),OVERLAY=(53:X),HIT=NEXT),
       IFTHEN=(WHEN=(54,1,CH,EQ,C'A'),OVERLAY=(54:X),HIT=NEXT),
       IFTHEN=(WHEN=(55,1,CH,EQ,C'A'),OVERLAY=(55:X),HIT=NEXT),
       IFTHEN=(WHEN=(56,1,CH,EQ,C'A'),OVERLAY=(56:X),HIT=NEXT),
       IFTHEN=(WHEN=(57,1,CH,EQ,C'A'),OVERLAY=(57:X),HIT=NEXT)
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Aug 16, 2006 4:13 am
Reply with quote

You can use these DFSORT steps to get the date from file1 and use it in file2:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file with date (FB)
//SORTOUT DD DSN=&&S1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN    DD    *
* Create DFSORT symbol as:
* MYDATE,'yy/mm/dd'
  OPTION COPY,STOPAFT=1
  OUTREC BUILD=(C'MYDATE,''',4,8,C'''',80:X)
/*
//S2    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  ...
  OUTREC FIELDS=(C'IRO',
                 C'   ',
                 MYDATE,
                 ...
/*



You don't need all those IFTHENs to replace each 'A' in a field with a blank. Instead, you can use DFSORT's TRAN=ALTSEQ feature as follows:

Code:

   ALTSEQ CODE=(C140)
   OUTREC ...
   ...
   p,m,TRAN=ALTSEQ,
   ...


where p is the starting position and m is the length.

For more information on using TRAN=ALTSEQ, see the "Change all zeros in your records to spaces" Smart DFSORT Trick at:

www.ibm.com/servers/storage/support/software/sort/mvs/tricks/index.html

To learn more about all the things you can do with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
yianis

New User


Joined: 14 Aug 2006
Posts: 45

PostPosted: Wed Aug 16, 2006 5:31 pm
Reply with quote

Thanks... works like a charm !!!
Back to top
View user's profile Send private message
cheetz007

New User


Joined: 10 Aug 2006
Posts: 23

PostPosted: Wed Aug 23, 2006 2:21 am
Reply with quote

Frank - you ARE the DFSORT man! Can't argue with that.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
Search our Forums:

Back to Top