How to write privious record in current position



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

How to write privious record in current position

Postby Mayank[123] » Mon Oct 15, 2012 3:52 pm

Hi,

I have 1 input file as

Sno  Subject     roll-Number   Name
1     English     100      ABC
2     Maths     100       ABC
3     Science     100           ABC
4     Computer    100           ABC 
5     English     200      DEF
6     English     300      GHI
7     Maths     300       GHI
8     Science     400           JKL
9     Computer    500           MNO 
10    English     500      MNO


sorted roll-number wise

now i just to print data as

Sno  Subject     roll-Number   Name    Privious Roll-number
1     English     100      ABC   ___(Space)   
2     Maths     100       ABC     100
3     Science     100           ABC     100
4     Computer    100           ABC     100
5     English     200      DEF     100
6     English     300      GHI     200
7     Maths     300       GHI     300
8     Science     400           JKL     300
9     Computer    500           MNO     400
10    English     500      MNO     500


how I can do this using DFSort.

Code'd - de-mangling not attempted
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write privious record in current position

 

Re: How to write privious record in current position

Postby BillyBoyo » Mon Oct 15, 2012 4:45 pm

When presenting information, please use the Code tags to preserve spacing, and the Preview button to ensure that you post looks how you want.

Is this an exercise, or a business requirement? Can you show the ICE201I message from any sort step that you have?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to write privious record in current position

Postby Mayank[123] » Mon Oct 15, 2012 4:52 pm

Yes it's a business requirement and i can see ICE201I MSG

ICE201I H RECORD TYPE IS F - DATA STARTS IN POSITION 1
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write privious record in current position

Postby BillyBoyo » Mon Oct 15, 2012 5:12 pm

OK, you're pretty up-to-date. Have a look at the manual for WHEN=GROUP and PUSH. PUSH is the way to get data from a record which defines the start of a GROUP to the following records that are part of the group. For your case, define your GROUP with RECORDS=2.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to write privious record in current position

Postby Mayank[123] » Mon Oct 15, 2012 5:15 pm

Hi,

I have 1 input file as
Sno    Subject     roll-Number        Name
1       English        100            ABC
2       Maths          100            ABC
3       Science        100            ABC
4       Computer       100            ABC 
5       English        200            DEF
6       English        300            GHI
7       Maths          300            GHI
8       Science        400            JKL
9       Computer       500            MNO 
10      English        500            MNO


sorted roll-number wise
now i just wanna print data as

Sno  Subject     roll-Number   Name    Privious Roll-number
1     English         100      ABC     ___(Space)   
2     Maths           100      ABC     100
3     Science         100      ABC     100
4     Computer        100      ABC     100
5     English         200      DEF     100
6     English         300      GHI     200
7     Maths           300      GHI     300
8     Science         400      JKL     300
9     Computer        500      MNO     400
10    English         500      MNO     500

how I can do this using DFSort.
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write privious record in current position

Postby Mayank[123] » Mon Oct 15, 2012 5:16 pm

ok i will try...
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write privious record in current position

Postby BillyBoyo » Mon Oct 15, 2012 5:41 pm

If you get stuck, show us what you've done, someone will be able to help.

If you get your results, show us what you've done, as it may help someone with a similar requirement.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to write privious record in current position

Postby Mayank[123] » Mon Oct 15, 2012 5:47 pm

//SYSOUT   DD  SYSOUT=*
//SORTOUT  DD  SYSOUT=*
//SORTIN   DD  *
1ENGLISH 100ABC
2MATHS   100ABC
3SCIENCE 100ABC
4COMPUTER100ABC
5ENGLISH 200DEF
6ENGLISH 300GHI
7MATHS   300GHI
8SCIENCE 400JKL
9COMPUTER500MNO
//SYSIN    DD  *
    SORT FIELDS=COPY
    OUTREC IFTHEN=(WHEN=GROUP,
              RECORDS=2,
              PUSH=(16:10,3))
//*


and output come like --> (incorrect)

1ENGLISH 100ABC100
2MATHS   100ABC100
3SCIENCE 100ABC100
4COMPUTER100ABC100
5ENGLISH 200DEF200
6ENGLISH 300GHI200
7MATHS   300GHI300
8SCIENCE 400JKL300
9COMPUTER500MNO500


I think, there should be any other condition also...
Mayank[123]
 
Posts: 14
Joined: Thu Oct 11, 2012 11:58 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to write privious record in current position

Postby BillyBoyo » Mon Oct 15, 2012 9:24 pm

Yes, you need something else. I was trying to get you to think a bit more.

Sort solutions are not like other program solutions, because the only "storage" you have for "saving" things you need later is on the record, and only PUSH can, within one file, get data from one record to another.

There is another way to look at your problem. If records are "grouped" by Roll Number, you want the previous roll number for the change of group, for "non-change-of-group" records, the roll number is equal to the previous anyway.

If you have a look at the two solutions from our sister site, here:

http://ibmmainframes.com/about58064.html#291631

You'll maybe get some ideas.

It is a non-trivial thing you are after. I want you to understand what you end up with.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: How to write privious record in current position

Postby skolusu » Mon Oct 15, 2012 10:05 pm

Mayank[123] ,

Use the following DFSORT JCL which will give you the desired results
//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTOUT  DD  SYSOUT=*                                               
//SORTIN   DD  *                                                     
1ENGLISH 100ABC                                                       
2MATHS   100ABC                                                       
3SCIENCE 100ABC                                                       
4COMPUTER100ABC                                                       
5ENGLISH 200DEF                                                       
6ENGLISH 300GHI                                                       
7MATHS   300GHI                                                       
8SCIENCE 400JKL                                                       
9COMPUTER500MNO                                                       
//SYSIN    DD  *                                                     
  SORT FIELDS=COPY                                                   
  OUTREC IFOUTLEN=80,                                                 
  IFTHEN=(WHEN=GROUP,RECORDS=2,PUSH=(81:SEQ=1)),                     
  IFTHEN=(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,1),PUSH=(82:10,3),RECORDS=2), 
  IFTHEN=(WHEN=GROUP,BEGIN=(81,1,ZD,EQ,2),PUSH=(85:10,3),RECORDS=2), 
  IFTHEN=(WHEN=(81,1,ZD,EQ,1),OVERLAY=(16:85,3)),                     
  IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(16:82,3))                     
//*


The output from this job is
1ENGLISH 100ABC     
2MATHS   100ABC100 
3SCIENCE 100ABC100 
4COMPUTER100ABC100 
5ENGLISH 200DEF100 
6ENGLISH 300GHI200 
7MATHS   300GHI300 
8SCIENCE 400JKL300 
9COMPUTER500MNO400 
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post