PARSE and use "length of" field as FIXLEN



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

PARSE and use "length of" field as FIXLEN

Postby Domingo » Mon Nov 28, 2011 8:51 pm

Hi all,

My question is how to use the field “length of” included in a record to extract the ensuing “length of” bytes.

We have an input file (FB) with the following “copy”:

01 to 0020 fixed structure
21 to 1000 variable structures as:

- Field Code: packed decimal: 3 bytes
- Data Length: binary: 2 bytes
- Data: depending on Data length bytes

The input fields are not in an specific order, and probably some of them will not appear.

I.e.

Field X’00001C’ means “Name”, max length 20 bytes, not always filled (first record, 4 bytes, second record 10 bytes).
Field X’00002C’ means “Surname”, max length 20 bytes, not always filled (first record, 7 bytes, second record 15 bytes).

****** ***************************** Top of Data ******************************
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000001 20111125700500000000     01223984     NAME     SURNAME                  
FFFFFFFFFFFFFFFFFFFF00300FFFFFFFF00100DCDC00200EEDDCDC444444444444444444
2011112570050000000000C080122398400C00514500C072495145000000000000000000
------------------------------------------------------------------------------
000002 20111125700500000000     LARGE SURNAME     LARGE NAME                  
FFFFFFFFFFFFFFFFFFFF00200DCDCC4EEDDCDC00100DCDCC4DCDC4444444444444444444
2011112570050000000000C0D319750249514500C0A31975051450000000000000000000
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************


We need to create an output file with Fixed part and only “name”, ”surname” fields, and full length.

****** ***************************** Top of Data ******************************
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000001 20111125700500000000NAME                SURNAME                        
       FFFFFFFFFFFFFFFFFFFFDCDC4444444444444444EEDDCDC4444444444444444444444444
       201111257005000000005145000000000000000024951450000000000000000000000000
------------------------------------------------------------------------------
000002 20111125700500000000LARGE NAME          LARGE SURNAME                  
       FFFFFFFFFFFFFFFFFFFFDCDCC4DCDC4444444444DCDCC4EEDDCDC4444444444444444444
       201111257005000000003197505145000000000031975024951450000000000000000000
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************

I tried to use PARSE to find out the fields I’m interested in, but using FIXLEN as a fixed length of 20 bytes, my output creates “rubbish” bytes just extracting 20 bytes from end of “Field code”,

****** ***************************** Top of Data ******************************
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
000001 20111125700500000000  NAME     SURNAME    SURNAME     012239            
       FFFFFFFFFFFFFFFFFFFF00DCDC00200EEDDCDC0000EEDDCDC00300FFFFFF444444444444
       2011112570050000000004514500C0724951450007249514500C07012239000000000000
------------------------------------------------------------------------------
000002 20111125700500000000  LARGE NAME          LARGE SURNAME                
       FFFFFFFFFFFFFFFFFFFF00DCDCC4DCDC4444444400DCDCC4EEDDCDC00100444444444444
       201111257005000000000A3197505145000000000D319750249514500C0A000000000000
------------------------------------------------------------------------------
****** **************************** Bottom of Data ****************************


Thank you in advance

Domingo Fernández.
Domingo
 
Posts: 2
Joined: Mon Nov 28, 2011 5:41 pm
Has thanked: 0 time
Been thanked: 0 time

Re: PARSE and use "length of" field as FIXLEN

 

Re: PARSE and use "length of" field as FIXLEN

Postby Frank Yaeger » Tue Nov 29, 2011 12:46 am

DFSORT does NOT have any built-in functions for handling embedded dynamic lengths.

I'd suggest you write a program or exit with the needed logic to do what you want.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: PARSE and use "length of" field as FIXLEN

Postby Domingo » Tue Nov 29, 2011 1:08 am

Thank you very much Frank.

I've discover lot of utilities with DFSORT in order to replace a basic COBOL program reviewing this forum, they will be very helpful in the future.
Domingo
 
Posts: 2
Joined: Mon Nov 28, 2011 5:41 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post