Converting 'occurs depending on' VB record to fixed format



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Converting 'occurs depending on' VB record to fixed format

Postby sinksort » Tue Oct 18, 2011 7:54 pm

Hi, I'm hoping for some syncsort help with the following scenario

Input file is variable-length with two 'occurs depending on' segments like this:
01  VARIABLE-RECORD.
    02  RECORD-KEY.
        03  RECORD-KEY-VALUE-1           PIC X(10).
        03  RECORD-KEY-VALUE-2           PIC 9(10).
    02  OCCUR-COUNTS.
        03  RECURRING-SEG-1-CT           PIC S9(3)V COMP-3.
        03  RECURRING-SEG-2-CT           PIC S9(3)V COMP-3.
    02  RECURRING-SEG-1.
        03  RECURRING-SEG-1-DATA OCCURS 0 TO 48 TIMES
            DEPENDING ON RECURRING-SEG-1-CT.
            04  FIELD-1                  PIC X(10).
            04  FIELD-2                  PIC X(8).
            04  FIELD-3                  PIC S9(9)    COMP-3.
    02  RECURRING-SEG-2.
        03  RECURRING-SEG-2-DATA OCCURS 0 TO 48 TIMES
            DEPENDING ON RECURRING-SEG-2-CT.
            04  FIELD-4                  PIC X(10).
            04  FIELD-5                  PIC X(8).
            04  FIELD-6                  PIC S9(9)    COMP-3.
 


I am attempting to convert this variable-lenth input into a fixed-length output file. The output file needs to have enough space for 48 occurrences of both segments...if there are less than 48 then that area should be filled with spaces. The end result is a fixed file with the segments in fixed positions within the record. Like this:

01  VARIABLE-RECORD.
    02  RECORD-KEY.
        03  RECORD-KEY-VALUE-1           PIC X(10).
        03  RECORD-KEY-VALUE-2           PIC 9(10).
    02  OCCUR-COUNTS.
        03  RECURRING-SEG-1-CT           PIC S9(3)V COMP-3.
        03  RECURRING-SEG-2-CT           PIC S9(3)V COMP-3.
    02  RECURRING-SEG-1.
        03  RECURRING-SEG-1-DATA OCCURS 48 TIMES.
            04  FIELD-1                  PIC X(10).
            04  FIELD-2                  PIC X(8).
            04  FIELD-3                  PIC S9(9)    COMP-3.
    02  RECURRING-SEG-2.
        03  RECURRING-SEG-2-DATA OCCURS 48 TIMES.
            04  FIELD-4                  PIC X(10).
            04  FIELD-5                  PIC X(8).
            04  FIELD-6                  PIC S9(9)    COMP-3.


My approach was to write a syncsort to dynamically calculate the offsets in the input file based on the values in RECURRING-SEG-1-CT and RECURRING-SEG-2-CT, multiplied by the length of each segment. Here's what I've got:

//SYSIN DD *
  SORT FIELDS=COPY
  OUTFIL FNAMES=FIXDFILE,
     BUILD=(1:1,24,
           25:25,(+23,MUL,(21,2,PD))
         1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
/*


It's not working and i'm looking for some help! Getting a syntax error from syncsort:

SYSIN :
  SORT FIELDS=COPY                                                   
  OUTFIL FNAMES=FIXDFILE,                                             
     BUILD=(1:1,24,                                                 
                   *
           25:25,(+23,MUL,(21,2,PD))
         1128:(+24,ADD,(+23,MUL,(21,2,PD))),(+23,MUL,(23,2,PD)))
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000


Any suggestions or help is greatly appreciated!!!!
sinksort
 
Posts: 5
Joined: Tue Oct 18, 2011 7:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Converting 'occurs depending on' VB record to fixed format

 

Re: Converting 'occurs depending on' VB record to fixed form

Postby BillyBoyo » Tue Oct 18, 2011 8:34 pm

I'm not sure if you can do it in SyncSort easily, but you can in Cobol. How about doing the conversion there?

If suppose if you have to do it in SyncSort, I don't know if your outlined method would work, otherwise it would be a huge bunch of selections.

To proceed with the SORT, try a really simple case first so you know whether it will work or not.

I'd go for Cobol, but let us know of progress and result if you stick with the SORT.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Converting 'occurs depending on' VB record to fixed form

Postby sinksort » Tue Oct 18, 2011 10:04 pm

Yes, COBOL would be an option but we're trying to avoid that...hoping to use syncsort instead.

I can't find anything in syncsort doc that says you can't do computations in outrec/build statements...but that seems to be where it is choking. The syntax looks correct so it may just be a limitation. I wanted to post on the forums in case I'm doing something incorrect. Or, better yet, if there is another syncsort approach I should be considering.

Thought about PARSE but there's no delimiters or characters I can gear off within the re-occurring segments.
sinksort
 
Posts: 5
Joined: Tue Oct 18, 2011 7:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Converting 'occurs depending on' VB record to fixed form

Postby dick scherrer » Tue Oct 18, 2011 10:51 pm

Hello and welcome to the forum,

Hopefully, this is not to make coding easier for people who have not learned how to code properly. . .

If you already have a working variable length file, that may save considerable space. One of the files i inherited used to take more than a full 3390 as fb; as vb, we save more than 40% of the space. . .

As a simple test, you might use the sort to COPY the file and specify the new dcb attributes in the output file DD rather than automatically using the input dcb. I can't test this just now, but i suspect it would be rather easy for you as you already have all of the pieces :)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Converting 'occurs depending on' VB record to fixed form

Postby sinksort » Tue Oct 18, 2011 11:40 pm

Actually, this is the second step in a SORT flow; in the first step I am separating the record types and CONVERTing to fixed format. So the file i'm reading into the sort is already fixed...but the offsets for the recurring segments are not. In the second pass, I was planning to shift them into their appropriate fixed positions.

The reason for fixed format is more of a financial one...the file is ultimately consumed by ETL into warehouse and the ETL tool can't handle VB files (or OCCURS DEPENDING ON) without making a substantial investment in upgrades. So syncsort is option 'b'. Cobol is our last resort or option 'c'..,..
sinksort
 
Posts: 5
Joined: Tue Oct 18, 2011 7:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Converting 'occurs depending on' VB record to fixed form

Postby dick scherrer » Wed Oct 19, 2011 12:10 am

Hello,

So the file i'm reading into the sort is already fixed...but the offsets for the recurring segments are not. In the second pass, I was planning to shift them into their appropriate fixed positions.
It will help us help you if you post a bit of sample data (not many records and not even the ful width - just enough to show your requirement) and the output you want from the sample data.

Syncsort will reformat one data format to the other (unless there is something i don't yet understand).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Converting 'occurs depending on' VB record to fixed form

Postby sinksort » Wed Oct 19, 2011 1:41 am

OK. I'll simplify the layout a little, to make it easier to make up sample data ;)

Consider the following VB layout:
01  VARIABLE-RECORD.
    02  RECORD-KEY.
        03  RECORD-KEY-VALUE-1           PIC 9(5).
    02  OCCUR-COUNTS.
        03  RECURRING-SEG-1-CT           PIC 9(2).
        03  RECURRING-SEG-2-CT           PIC 9(2).
    02  RECURRING-SEG-1.
        03  RECURRING-SEG-1-DATA OCCURS 0 TO 10 TIMES
            DEPENDING ON RECURRING-SEG-1-CT.
            04  FIELD-1                  PIC X(1).
    02  RECURRING-SEG-2.
        03  RECURRING-SEG-2-DATA OCCURS 0 TO 10 TIMES
            DEPENDING ON RECURRING-SEG-2-CT.
            04  FIELD-2                  PIC X(1).


I would like to conver the record to a fixed layout as such:
01  FIXED-RECORD.
    02  RECORD-KEY.
        03  RECORD-KEY-VALUE-1           PIC 9(5).
    02  OCCUR-COUNTS.
        03  RECURRING-SEG-1-CT           PIC 9(2).
        03  RECURRING-SEG-2-CT           PIC 9(2).
    02  RECURRING-SEG-1.
        03  RECURRING-SEG-1-DATA OCCURS 10 TIMES.
            04  FIELD-1                  PIC X(1).
    02  RECURRING-SEG-2.
        03  RECURRING-SEG-2-DATA OCCURS 10 TIMES.
            04  FIELD-2                  PIC X(1).


So, the input dataset below:
111110203AABBB
222220102CDD
333330001E
444440400FFFF


Would look like this:
111110203AA        BBB
222220102C         DD
333330001          E
444440400FFFF
sinksort
 
Posts: 5
Joined: Tue Oct 18, 2011 7:17 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Converting 'occurs depending on' VB record to fixed form

Postby dick scherrer » Wed Oct 19, 2011 2:28 am

Hello,

Suggest you re-consider the COBOL solution. . . Tell them some "old guys" recommend this.

From what you've shown, i suspect "coding" this in sort control statements will be more cumbersome (and less maintainable) than the very simple COBOL code. . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post