Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting files that contain binary lenght-fields to ASCII

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
MichaelKBS

New User


Joined: 10 Jan 2006
Posts: 24
Location: Germany

PostPosted: Fri Jan 30, 2009 9:45 pm    Post subject: Converting files that contain binary lenght-fields to ASCII
Reply with quote

In my shop we have to convert our files from EBCDIC to ASCII regarding of binary length-fields that must not be converted. This works fine with DFSORT and ALTSEQ CODE=(..,..,...) using OUTREC FIELDS.

f.e.: OUTREC FIELDS=(1,4,
5,76,TRAN=ALTSEQ)
means that position 1-4 is not to be converted while 5-76 is to be converted to ASCII.

NOW MY QUESTION:
-----------------------
Some of our files contain binary lengths in variable positions framed by x'FF' (=High Value, appears as '.')
That looks like:
Harry*Hirsch.0009.Something.000C.123456789012
Florence*Fisher.000D.SomethingElse.000E.12345678911234

Is it possible to convert these records and preserve the length-fields?

Thank you for your answers!
Mike
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Jan 30, 2009 10:01 pm    Post subject:
Reply with quote

It's not clear what you mean. When you say you have binary lengths in variable positions framed by X'FF', do you mean something like:

X'FF0003FF' for a 3-byte length? Or do you mean something else?

Or do you just mean you have X'FF' bytes as delimiters between the fields?

Please show an example of the input records in hex that shows what the input records really look like, and what you want for output.
Back to top
View user's profile Send private message
MichaelKBS

New User


Joined: 10 Jan 2006
Posts: 24
Location: Germany

PostPosted: Sat Jan 31, 2009 5:00 pm    Post subject:
Reply with quote

Frank Yaeger wrote:
It's not clear what you mean. When you say you have binary lengths in variable positions framed by X'FF', do you mean something like:

X'FF0003FF' for a 3-byte length? Or do you mean something else?

Or do you just mean you have X'FF' bytes as delimiters between the fields?

Please show an example of the input records in hex that shows what the input records really look like, and what you want for output.



Hi Frank,

the data in our file is compressed by a program to decrease the usage of storage. For instance: 10 spaces are compressed to 1 preceeded by a length-field X'FF000AFF'.

The X'FF'-bytes are only used as begin and end delimiters to identify the length-fiedls in the records.

That means when X'FF000AFF' appears, the first X'FF' tells us, that now a binary length-field begins. The actual length is X'000A'. The second X'FF' indicates the end of the length-field.
Cause the length-fields are not at fixed positions, they are in between x'FF'-bytes to be easily identified. These X'FF....FF'-fields must not be converted to ASCII by ALTSEQ=TRAN, otherwise we would loose the lengh-information.

What I need is something like:

OUTREC FIELDS (1,4,
5,ALTSEQ=TRAN)
but: without translating the X'FF....FF'- fields!

The problem is, I can't give fixed positions for them. They can stand on various positions.
Can we combine PARSE-Option with ALTSEQ=TRAN ?
Back to top
View user's profile Send private message
MichaelKBS

New User


Joined: 10 Jan 2006
Posts: 24
Location: Germany

PostPosted: Sat Jan 31, 2009 5:22 pm    Post subject:
Reply with quote

This is how the conversion is to be made:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----10---+----11---+----12---+----13---+...

Input data:

1 : ----ebcdic-code----FF0003FF--------ebcdic-code-------FF003AFF--ebcdic-code...
2 : -------ebcdic-code--------FF0003FF----ebcdic-code---FF003AFFebcdic-codeFF0011FF-------------ebcdic-code-------------
3 : ...


Output data:

1 : -----ascii-code-----FF0003FF--------ascii-code---------FF003AFF--ascii-code...
2 : --------ascii-code---------FF0003FF-----ascii-code----FF003AFF-ascii-code-FF0011FF-------------ascii-code-------------
3 : ...
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Sat Jan 31, 2009 9:57 pm    Post subject:
Reply with quote

If the values between X'FF' pairs are NOT found in any of the EBCDIC values, then you could just not change those values with ALTSEQ. For example, if the largest repetition factor is 20, so the X'FF' fields vary from X'FF0001FF' to X'FF0014FF', and X'00'-X'14' and X'FF' do NOT appear in the ebcdic values, then you could use TRAN=ALTSEQ on the entire record providing you didn't change X'00'-X'14' and X'FF' with the ALTSEQ table.

Otherwise, you'd have to PARSE the record to separate the fields so you'd have to know the maximum number of separate fields in a record and the maximum length of a field. Then you'd have to use IFTHEN clauses to find the resulting fields that don't start with X'FF' and use TRAN=ALTSEQ on them. Then you'd have to SQZ the fields back together again. This could be quite tricky depending on what the ebcdic fields actually look like (for example, whether or not they have blanks that need to be kept), the maximum number of fields per record, the maximum length of each field, etc. You might actually be better off writing a program or exit with appropriate logic in this case.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Sat Jan 31, 2009 10:26 pm    Post subject: Reply to: Converting files that contain binary lenght-fields
Reply with quote

supposing you are going to transfer things to a different platform
it would be better to remember the issue of endiannes ( for the halfword representing a length )
not always what You see is what You get

here is a c snippet to show the endianness
Code:

// endian.c
//
// test to show "endian-ness".
//

#include <stdio.h>

int main(int argc, char *argv[]) {
    int i;
    union {
        unsigned short int bin;
        unsigned char hex[2];
    } halfword;

    union   {
      unsigned int bin;
        unsigned char hex[4];
    } fullword;

    halfword.bin = 0x1234;
    printf("halfword.bin = %04x,     ", halfword.bin);
    printf("halfword.hex = %02x%02x\n", halfword.hex[0], halfword.hex[1]);

    fullword.bin = 0x12345678;
    printf("fullword.bin = %08x, fullword.hex = ", fullword.bin);
    for (i = 0; i < 4; i++) {
        printf("%02x", fullword.hex[i]);
    }
    printf("\n");

    if (halfword.hex[0] == 0x34) {
        printf("Your machine is little endian. (e.g., x86....)\n");
    }
    else {
        printf("Your machine is big    endian. (e.g., S370...)\n");
    }

    return 0;
}


Back to top
View user's profile Send private message
MichaelKBS

New User


Joined: 10 Jan 2006
Posts: 24
Location: Germany

PostPosted: Mon Feb 02, 2009 1:43 am    Post subject:
Reply with quote

Thank you Frank and Enrico,
my problem seems to be a bit too special for DFSORT. I think I'm going to try with REXX's translate function. However, I love using DFSORT for it's so damn fast working and a very powerful tool.

Regards,

Michael
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Feb 02, 2009 3:46 am    Post subject:
Reply with quote

Hello,

Quote:
it's so damn fast working


If the file contains a high volume of data, you will most likely not be happy with the performance of rexx. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm
No new posts DFSORT MUL FIELDS tspr52 DFSORT/ICETOOL 16 Fri Mar 03, 2017 11:53 pm
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
No new posts Sort two file having same field, one ... himanshu malik DFSORT/ICETOOL 7 Thu Feb 02, 2017 10:09 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us