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

How to get details of a record whose position is varying .


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

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Sep 27, 2007 9:36 am
Reply with quote

Hi

The i/p file details are as follows.

Name field is from position 1 - 10
Subject1 from 1 - 10
Subject2 from 15-25
Subject3 from 30-40
Remarks from 50-80(but the data under Remarks doesnt start always from 50 , it keps varying anywhere from 50-80)
Other activities from 1 - 10
Optional subject from 1-20

The i/p file based on the above layout is given below :
Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
Remarks
Good
Name : Anu
Other activities
Painting

Name : Asha
Subject1 Subject2 Subject3
hist science geography
Remarks
Excellent
Name : Asha
Other Activities
Singing
Name : Asha
Optional subject
French


The data under Remarks varies anywhere from 50th col to 80th col(i.e.it's position is not fixed).

Now my requirement is to get the first Name(as Name appears at least twice for each student) and it's corresponding Remarks field. Here the i/p file shows details of two students Anu and Asha. Lets say they are the details of 2 students . For each student , the Name field appears at least twice. (Say for Anu - The second Name field indicates that it's a continuation,similar is the case with the second student i.e Asha where the Name field appears 3 times showing that details of student Asha is continued) . But as per my requirement i need only the first Name for each student and the Remarks field(that comes in 5th line only from the 1st Name field for each student and note that there's no Remarks field for the continued Name fields until a fresh student detail appears) that is present only for the first Name field of each student.

So my o/p should be
Anu - Good
Asha - Excellent

Is this possible through DFSORT ? If so please explain.
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: Thu Sep 27, 2007 8:34 pm
Reply with quote

Some questions:

Do the groups for the same name always appear consecutively?

You say that the name appears at least twice for each student. Can the name appear more than twice for a student?

You say the remarks value record is the 5th record of the group. Is the "Remarks" record always the 4th record of the group? Does "Remarks" in the 4th record of the group always start in position 50 or can it start anywhere in 50-80?

Is the remarks value limited to a certain set of words (e.g. Good, Excellent, etc) or can it be anything? If it's a certain set of words, what are all of the possible values?
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Sep 28, 2007 8:35 am
Reply with quote

Hi Frank

Please find my answers for your questions in blue.

Do the groups for the same name always appear consecutively?

I think you are asking if the data for a student will appear randomly anywhere in the file or will all the information for a student be grouped together.If you meant the same then , yes for the same name the groups will appear consecutively.

You say that the name appears at least twice for each student. Can the name appear more than twice for a student?

Yes it can appear more than twice as shown in the e.g for student Asha.

You say the remarks value record is the 5th record of the group. Is the "Remarks" record always the 4th record of the group -

Yes "Remarks" record if present is the 4th record of the group . For some student this "Remarks" will not appear,in such cases i don't want those student details in my output.

Does "Remarks" in the 4th record of the group always start in position 50 or can it start anywhere in 50-80?

Remarks in 4th record will start from 50 but the value under Remarks can start anywhere between 50-80.

Is the remarks value limited to a certain set of words (e.g. Good, Excellent, etc) or can it be anything? If it's a certain set of words, what are all of the possible values?

No it's not only a set of words but also has sentences like ' You should improve' , 'The performance is fair' 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: Fri Sep 28, 2007 10:17 pm
Reply with quote

I should have asked how

Name field is from position 1 - 10

fits with

Name : Asha

which is 11 characters. I'll assume that the name record has 'Name :' and the actual name is from positions 8-17.

Given that assumption, here's a DFSORT/ICETOOL job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/43)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) -
  WITHEACH WITH(50,7) WITH(11,33) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,6,CH,EQ,C'Name :'),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))
  OUTFIL FNAMES=T1,
    INCLUDE=(89,8,ZD,EQ,+1,OR,89,8,ZD,EQ,+4,OR,89,8,ZD,EQ,+5),
    IFTHEN=(WHEN=(89,8,ZD,EQ,+1),BUILD=(1:8,10,81:81,8)),
    IFTHEN=(WHEN=(89,8,ZD,EQ,+5),
      BUILD=(11:C'-',13:50,31,JFY=(SHIFT=LEFT),81:81,8))
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(50,7,CH,EQ,C'Remarks'),
    BUILD=(1,43)
/*


An example of the output records in OUT would be:

Code:

Anu       - Good             
Asha      - You should improve
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Mon Oct 01, 2007 12:42 pm
Reply with quote

Hi Frank,

The solution you have provided has worked . Could you please explain the syntax
INCLUDE=(89,8,ZD,EQ,+1,OR,89,8,ZD,EQ,+4,OR,89,8,ZD,EQ,+5) .

Also for e.g say if for student Asha i have 2 data under remarks (i.e 'You should improve' and 'God work' ) both are present and i want both in the o/p then how do i get that ?
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 Oct 01, 2007 9:28 pm
Reply with quote

Quote:
The solution you have provided has worked . Could you please explain the syntax
INCLUDE=(89,8,ZD,EQ,+1,OR,89,8,ZD,EQ,+4,OR,89,8,ZD,EQ,+5) .



Code:

  OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))


This gives a sequence number, starting with +1, to each record in a group. So the Name record in each group is +1, the 'Remarks' record in each group is +4 and the remarks value record in each group is +5. The INCLUDE statement uses +1, +4 and +5 to include only those three records from each group.

Quote:
Also for e.g say if for student Asha i have 2 data under remarks (i.e 'You should improve' and 'Good work' ) both are present and i want both in the o/p then how do i get that ?


You mean you have two remark value records? For example:

Code:

Remarks
    You should improve
    Good work


Is it always two, or is it one or two, or is it one to n (what is n), or what? Please describe this part of the requirement completely.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Wed Oct 03, 2007 8:22 am
Reply with quote

Frank,

Thanks for the explanation. That was really helpful. For each student the value under Remarks varies. Say for some it's 1 for some it's 3. So it's from 1 to n as it keeps on varying. In such a situation for each student i want all the values under Reamarks column.
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 Oct 03, 2007 8:45 pm
Reply with quote

Quote:
So it's from 1 to n as it keeps on varying.


What is the maximum for n? If you can't tell me then I can't determine if it's doable with DFSORT.

What would you want the output to look like if the input is:

Code:

Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
                                 Remarks
                                    You should improve
                                         Good work
                                       Try harder
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Oct 04, 2007 8:19 am
Reply with quote

Quote:
What is the maximum for n?


n varies from 1 to 20. Also tell me what max value of n can be accepted by DFSORT.

the o/p should be the same as shown in your previous JCL(the only difference being all the value under Remarks should come in o/p instead of only the first value under Remarks). It should be as follows :

Code:

Anu  - You should improve
          Good work
          Try harder
Asha - You should improve
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: Thu Oct 04, 2007 9:35 pm
Reply with quote

I figured out a way to do it for any number of records under Remarks. Here's the DFSORT/ICETOOL job:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/44)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)                       
SPLICE FROM(T2) TO(T1) ON(81,8,ZD) -             
  WITHALL WITH(50,31) WITH(81,16) USING(CTL2)   
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) -           
  WITHALL WITH(21,76) USING(CTL3)       
/*
//CTL1CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),                 
        IFTHEN=(WHEN=(1,6,CH,EQ,C'Name :'),                         
                OVERLAY=(81:SEQNUM,8,ZD)),                           
        IFTHEN=(WHEN=NONE,                                           
                OVERLAY=(89:SEQNUM,8,ZD,                             
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))       
  OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))                     
  OUTFIL FNAMES=T1,                                                 
    INCLUDE=(89,8,ZD,EQ,+1)                                         
  OUTFIL FNAMES=T2,                                                 
    INCLUDE=(89,8,ZD,GE,+4),                                         
    IFTHEN=(WHEN=(89,8,ZD,EQ,+4),BUILD=(21:50,7,81:81,16)),         
    IFTHEN=(WHEN=NONE,                                               
      BUILD=(50:50,31,JFY=(SHIFT=LEFT),81:81,16))                   
/*
//CTL2CNTL DD *                                                     
  OUTFIL FNAMES=T1,INCLUDE=(21,7,CH,EQ,C'Remarks')                   
/*
//CTL3CNTL DD *                                                 
  OUTFIL FNAMES=OUT,                                           
    IFTHEN=(WHEN=(89,8,ZD,EQ,+5),BUILD=(8,10,C' - ',14:50,31)),
    IFTHEN=(WHEN=NONE,BUILD=(14:50,31))                         
/*       
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Nov 02, 2007 9:50 am
Reply with quote

Thanks Frank.

It worked : icon_smile.gif .
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Thu Dec 13, 2007 12:41 pm
Reply with quote

Hi Frank

If along with the Remarks details i need Subject1 and Subject2 details also then how do i get it. Now my o/p should look like this .

Code:

Anu  - English      You should improve
       maths        Good work
                    Try harder
Asha - Hist         You should improve
       Science
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: Fri Dec 14, 2007 12:15 am
Reply with quote

You've changed the requirement several times now. I've lost track of what the input vs output looks like. Can you please show a good example of the input records and the expected output records.
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Fri Dec 14, 2007 2:02 pm
Reply with quote

Ya sure..The i/p details are as follows .

Name field is from position 1 - 10
Subject1 from 1 - 10
Subject2 from 15-25
Subject3 from 30-40
Remarks from 50-80(but the data under Remarks doesnt start always from 50 , it keps varying anywhere from 50-80)
Other activities from 1 - 10
Optional subject from 1-20


The i/p file based on the above layout is given below :
Name : Anu
Subject1 Subject2 Subject3
Eng maths physics
Remarks
Good work
Try harder
You should improve
Name : Anu
Other activities
Painting

Name : Asha
Subject1 Subject2 Subject3
hist science geography
Remarks
Excellent
Name : Asha
Other Activities
Singing
Name : Asha
Optional subject
French


The data under Remarks varies anywhere from 50th col to 80th col(i.e.it's position is not fixed).

Now my requirement is to get the first Name(as Name appears at least twice for each student) and it's corresponding Remarks field. Here the i/p file shows details of two students Anu and Asha. Lets say they are the details of 2 students . For each student , the Name field appears at least twice. (Say for Anu - The second Name field indicates that it's a continuation,similar is the case with the second student i.e Asha where the Name field appears 3 times showing that details of student Asha is continued) . But as per my requirement i need only the first Name for each student and the Remarks field(that comes in 5th line only from the 1st Name field for each student and note that there's no Remarks field for the continued Name fields until a fresh student detail appears) that is present only for the first Name field of each student.

So my o/p should be

Anu - Good work
- try harder
- You should improve
Asha - Excellent

The JCL you provided (is given below)gave me the above o/p. But now i want the o/p to have the data under subject1 and subject2 for each student along with the above o/p.

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/44)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(T2) TO(T1) ON(81,8,ZD) -
WITHALL WITH(50,31) WITH(81,16) USING(CTL2)
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) -
WITHALL WITH(21,76) USING(CTL3)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'Name :'),
OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=NONE,
OVERLAY=(89:SEQNUM,8,ZD,
81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))
OUTFIL FNAMES=T1,
INCLUDE=(89,8,ZD,EQ,+1)
OUTFIL FNAMES=T2,
INCLUDE=(89,8,ZD,GE,+4),
IFTHEN=(WHEN=(89,8,ZD,EQ,+4),BUILD=(21:50,7,81:81,16)),
IFTHEN=(WHEN=NONE,
BUILD=(50:50,31,JFY=(SHIFT=LEFT),81:81,16))
/*
//CTL2CNTL DD *
OUTFIL FNAMES=T1,INCLUDE=(21,7,CH,EQ,C'Remarks')
/*
//CTL3CNTL DD *
OUTFIL FNAMES=OUT,
IFTHEN=(WHEN=(89,8,ZD,EQ,+5),BUILD=(8,10,C' - ',14:50,31)),
IFTHEN=(WHEN=NONE,BUILD=(14:50,31))
/*
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: Sat Dec 15, 2007 2:35 am
Reply with quote

Here's a DFSORT/ICETOOL job that will do your new requirement:

Code:

//S1    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG  DD SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//T2 DD DSN=&&T2,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//T3 DD DSN=&&T3,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//CON DD DSN=*.T2,VOL=REF=*.T2,DISP=(OLD,PASS)
//    DD DSN=*.T3,VOL=REF=*.T3,DISP=(OLD,PASS)
//T4 DD DSN=&&T4,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(MOD,PASS)
//OUT DD DSN=...  output file (FB/54)
//TOOLIN   DD    *
COPY FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(T4) ON(81,8,ZD) ON(89,8,ZD) KEEPNODUPS -
  WITHALL WITH(31,10)
SPLICE FROM(T4) TO(T1) ON(81,8,ZD) -
  WITHALL WITH(31,10) WITH(50,31) WITH(81,16)
SPLICE FROM(T1) TO(OUT) ON(81,8,ZD) -
  WITHALL WITH(21,76) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(1,6,CH,EQ,C'Name :'),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  OUTREC OVERLAY=(89:SEQNUM,8,ZD,RESTART=(81,8))
  OUTFIL FNAMES=T1,
    INCLUDE=(89,8,ZD,EQ,+1)
  OUTFIL FNAMES=T2,
    INCLUDE=(89,8,ZD,GE,+4),
    IFTHEN=(WHEN=(89,8,ZD,EQ,+4),BUILD=(21:50,7,81:81,16)),
    IFTHEN=(WHEN=NONE,
      BUILD=(50:50,31,JFY=(SHIFT=LEFT),81:81,16))
  OUTFIL FNAMES=T3,
    INCLUDE=(89,8,ZD,EQ,+3),
      BUILD=(31:1,10,81:81,8,89:C'00000005',/,
             31:15,10,81:81,8,89:C'00000006')
/*
//CTL2CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(21,7,CH,EQ,C'Remarks'),
    IFTHEN=(WHEN=(89,8,ZD,EQ,+5),BUILD=(8,10,C' - ',14:31,10,50,31)),
    IFTHEN=(WHEN=NONE,BUILD=(14:31,10,50,31))
/*
Back to top
View user's profile Send private message
Ambili S

Active User


Joined: 06 Sep 2007
Posts: 112
Location: India

PostPosted: Tue Dec 18, 2007 11:03 am
Reply with quote

Frank i tried the JCL but no records were there in o/p datatset.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Dec 18, 2007 8:17 pm
Reply with quote

Hello,

Quote:
Frank i tried the JCL but no records were there in o/p datatset.
You need to post more than this in order for someone to help.

If you post the sysouts info from the execution, it will be a good start.
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 Dec 18, 2007 10:28 pm
Reply with quote

Quote:
Frank i tried the JCL but no records were there in o/p datatset.


That doesn't give me anything to go on.

Here's the input I used for my test.

Code:

Name : Anu                                                             
Subject1      Subject2                  Subject3                       
Eng           maths                      physics                       
                                                 Remarks               
                                                                       
                                                   Another remark       
                                                     A third remark     
Name : Anu                                                             
Other activities                                                       
Painting                                                               
Name : Asha                                                             
Subject1      Subject2                   Subject3                       
hist          science                     geography                     
                                                 Remarks               
                                                   You should improve   
Name : Asha                                                             
Other Activities                                                       
Singing                                                                 
Name : Asha                                                             
Optional subject                                                       
French                                                                 
Comment1                                                               
Comment2                                                               


Here's the output I got for my test:

Code:

Anu        - Eng       Good                 
             maths     Another remark       
                       A third remark       
Asha       - hist      You should improve   
             science                         


I guess you need to tell me what's different in your case. You could use a step like this to display each intermediate output (&&T1, &&T2, &&T3 and &&T4):

Code:

//SHOWT1 EXEC  PGM=ICEMAN                   
//SYSOUT    DD  SYSOUT=*                     
//SORTIN DD DSN=&&T1,DISP=(OLD,PASS)         
//SORTOUT DD SYSOUT=*                       
//SYSIN    DD    *                           
   OPTION COPY
/*


Then you could send me a note offline (yaeger@us.ibm.com) to show me what your input, intermediate output, and final output looks like.
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 Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top