How to conduct this scenario using DFSORT



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

How to conduct this scenario using DFSORT

Postby Muhammed H » Thu Aug 21, 2014 10:42 pm

Hello There,

I have this scenario which is planned to be covered through a Cobol program. Have been trying to workout the same using DFSORT(PARSE, IFTHEN) but without any success till now.

Scenario: There is this variable length file which contains two types of records indicated through a "Indicator Field". The need is to segregate the two types of record in two different files but the challenge is that the fields before "Indicator Field" may or may not occur which makes deriving of "Indicator Field" quite difficult.

Here is how the file structure looks like.

01 MASTER-RECORD.
05 KEY-FIELD PIC X(10).
05 SEGMENT-BYTE PIC X(01).
05 FIELD-01 PIC X(05) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT01.
05 FIELD-02 PIC X(02) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT02.
--
--
05 FIELD-08 PIC X(08) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT08.
05 X-FIELD-LENGTH PIC 9(02).
05 Y-FIELD-LENGTH PIC 9(02).
05 X-FIELD PIC X(01) OCCURS 0 TO 20 DEPENDING ON X-FIELD-LENGTH.
05 Y-FIELD PIC X(01) OCCURS 0 TO 30 DEPENDING ON Y-FIELD-LENGTH.
05 INDICATOR-FIELD PIC X(01). ===========> Possible values are "E" or Space

Many Thanks,
Muhammed H
Muhammed H
Muhammed H
 
Posts: 8
Joined: Thu Aug 21, 2014 8:38 pm
Location: Bangalore
Has thanked: 0 time
Been thanked: 0 time

Re: How to conduct this scenario using DFSORT

Postby BillyBoyo » Fri Aug 22, 2014 12:18 am

So is INDICATOR-FIELD the last field of the record? Silly idea to put anything after those OCCURS DEPENDING ON.

You simply want to split on the indicator? E to one file, anything else to another?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to conduct this scenario using DFSORT

Postby Muhammed H » Fri Aug 22, 2014 4:22 pm

Yes, unfortunately this "INDICATOR-FIELD" is the last field of the record and I don't have the option of placing it at the start.

Also splitting on the indicator value "E" won't help as fields "X-Field" & "Y-Field" are text field and might contain character "E" which will fail the purpose.
Muhammed H
Muhammed H
 
Posts: 8
Joined: Thu Aug 21, 2014 8:38 pm
Location: Bangalore
Has thanked: 0 time
Been thanked: 0 time

Re: How to conduct this scenario using DFSORT

Postby BillyBoyo » Fri Aug 22, 2014 6:07 pm

Yes, I noticed the text, don't worry :-)

First thing to do is to PARSE with a length of the maximum record-length. You need that, because we're just about to destroy the data...

Then FINDREP to change C' ' (a space) to something else (your choice, except C'E').

Then OVERLAY to put a character at max-rec-length-plus-one. From that point all your records are fixed-length, space-padded and with no spaces in the data.

Then BUILD with JFY and SHIFT=RIGHT, which will jam all the data over to the right of the record. Your E/non-E is now in the position of the original maximum record-length.

Now BUILD with the PARSEd field from earlier, and the indicator.

OUTFIL first-file,INCLUDE= for the C'E', set the indicator to space, and use VLTRIM.

OUTFIL second-file,SAVE,set indicstor to space use VLTRIM.

Should get you close.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to conduct this scenario using DFSORT

Postby Muhammed H » Tue Aug 26, 2014 9:44 pm

Well thanks a lot Bill; your solution ROCKS. Just implemented & tested successfully!!!

Now was just wondering what if that “INDICATOR-FIELD” wasn’t the last field & there were some more variable fields under it.

Is it still possible to cover this with DFSORT?????(I think I am heading toward one ;) )

Do you have a trick (for this scenario) in your bag of wonders???
Muhammed H
Muhammed H
 
Posts: 8
Joined: Thu Aug 21, 2014 8:38 pm
Location: Bangalore
Has thanked: 0 time
Been thanked: 0 time

Re: How to conduct this scenario using DFSORT

Postby BillyBoyo » Wed Aug 27, 2014 12:43 am

It may still be possible as a general solution with a number of IFTHENs which "de-code" the positions. Whether there is a "short" solution depends entirely on the actual case. If the number of possibilities for the ODO is limited (like your example where there were only eight possible) there may be a PARSE solution (with multiple PARSEs, and ADDPOS) but we need to see the actual situation you have when you arriver there,

So, that's a guarded "probably" :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to conduct this scenario using DFSORT

Postby Muhammed H » Tue Sep 02, 2014 10:12 pm

Run against Live file failed.
There are couple of records defying my earlier layout where “Indicator-Field” isn’t the last field hence voiding the initial solution perceived considering it to be last field.


New Layout is below(My bad for overlooking this earlier).

Is it possible to make length option in sort card to refer to a specific position in file? (Probably not) I am not able to over come this limitation of specifying a numeric integer value for the length option in sort card. Is there any way to de-code length of the variable fields?

01 MASTER-RECORD.
05 KEY-FIELD PIC X(10).
05 SEGMENT-BYTE PIC X(01).
05 FIELD-01 PIC X(05) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT01.
05 FIELD-02 PIC X(02) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT02.
--
--
05 FIELD-08 PIC X(08) OCCURS 0 TO 1 DEPENDING ON SEGMENT-BYTE-BIT08.
05 X-FIELD-LENGTH PIC 9(02).
05 Y-FIELD-LENGTH PIC 9(02).
05 X-FIELD PIC X(01) OCCURS 0 TO 20 DEPENDING ON X-FIELD-LENGTH.
05 Y-FIELD PIC X(01) OCCURS 0 TO 30 DEPENDING ON Y-FIELD-LENGTH.
05 INDICATOR-FIELD PIC X(01). ==============================> Possible values are "E" or Space
05 PREV-KEY-FIELD PIC X(10).
05 PREV-SEGMENT-BYTE PIC X(01).
05 PREV-FIELD-01 PIC X(05) OCCURS 0 TO 1 DEPENDING ON PREV-SEGMENT-BYTE-BIT01.
05 PREV-FIELD-02 PIC X(02) OCCURS 0 TO 1 DEPENDING ON PREV-SEGMENT-BYTE-BIT02.
--
--
05 PREV-FIELD-08 PIC X(08) OCCURS 0 TO 1 DEPENDING ON PREV-SEGMENT-BYTE-BIT08.
05 PREV-X-FIELD-LENGTH PIC 9(02).
05 PREV-Y-FIELD-LENGTH PIC 9(02).
05 PREV-X-FIELD PIC X(01) OCCURS 0 TO 20 DEPENDING ON PREV-X-FIELD-LENGTH.
05 PREV-Y-FIELD PIC X(01) OCCURS 0 TO 30 DEPENDING ON PREV-Y-FIELD-LENGTH.


Code'd, for what is was worth
Muhammed H
Muhammed H
 
Posts: 8
Joined: Thu Aug 21, 2014 8:38 pm
Location: Bangalore
Has thanked: 0 time
Been thanked: 0 time

Re: How to conduct this scenario using DFSORT

Postby BillyBoyo » Wed Sep 03, 2014 12:25 am

You have 58 possible starting-positions for your indicator. You also have eight possible starting-positions for your lengths. It can be done with a lot of code. Perhaps 66 IFTHEN=WHEN=(logical expression, and HIT=NEXT

I'll have to have a think about something more convenient. May not be possible...
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: How to conduct this scenario using DFSORT

Postby BillyBoyo » Wed Sep 03, 2014 2:46 pm

Sorry, not come up with anything that doesn't involve a lot of code.

COBOL is going to be much easier.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post