Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Split a record into two records

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Sat May 17, 2008 1:15 pm    Post subject: Split a record into two records
Reply with quote

Hi,

I want to split a single record into two records. I will explain you clearly with an example.

Input file is FB and LRECL is 80

My input will be as follows which is sorted on SEQ_ID and TRAN_ID:
Code:

SEQ_ID AMOUNT TRAN_ID PRI_CUS SEC_CUS   
SEQ11  10000  T10001  2000011 3000221   
SEQ32  3000   T30021  2011000 1800111   
SEQ45  23400  T43000  2001000           


For the first record the prim cust number is less than sec cust. So the prim cust record should come first and then sec cust.

For the second record the prim cust number is greater than sec customer. So the sec cust record should come first and then prim cust.

For the third record as no sec cust number is there only the prim cust should be written.

Always the prim cust will have value.

My output file will be as follows which is FB and LRECL is 60:
Code:

SEQ_ID AMOUNT TRAN_ID CUST_ID
SEQ11  10000  T10001  2000011
SEQ11  10000  T10001  3000221
SEQ32  3000   T30021  1800111
SEQ32  3000   T30021  2011000
SEQ45  23400  T43000  2001000


How this can be done.
Back to top
View user's profile Send private message

Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Sat May 17, 2008 8:26 pm    Post subject:
Reply with quote

Assuming each of your fields to be of length 5 and no spaces in between these 5 FIELDS (SEQ_ID, AMOUNT, TRAN_ID, PRI_CUS and SEC_CUS )
You can customize below jcl to include spaces between these fields.

Code:
//STEP1 EXEC PGM=SORT
//SORTIN    DD  DSN=INPUTFIILE,(LENGTH=25,FB)
//OUT1       DD   DSN=&&T1,LRECL=20,DISP=(NEW,PASS)...
//OUT2       DD   DSN=&&T2,LRECL=20,DISP=(NEW,PASS)...
//SORTOUT DD  DUMMY
//SYSIN      DD  *
   OPTION COPY
   OUTFIL  FNAMES=OUT1,OUTREC=(1,20)
   OUTFIL  FNAMES=OUT2,OMIT=(21,5,EQ,C' '),OUTREC=(1,15,21,5) 
/*
//STEP2   EXEC PGM=ICETOOL
//IN1         DD   DSN=&&T1,LRECL=20,DISP=(OLD,DELETE)...
//IN2         DD   DSN=&&T2,LRECL=20,DISP=(OLD,DELETE)...
//TEMP      DD    DSN=&&TEMP,LRECL=20,DISP=(MOD,PASS)...
//OUTPUT    DD  DSN=HLQ.YOUR.OUTPUT,DISP=(NEW,CATLG),
//SORTOUT DD  DUMMY
//SYSIN      DD  *
   COPY FROM(IN1) TO(TEMP)
   COPY FROM(IN2) TO(TEMP)
   COPY FROM(TEMP) TO(OUTPUT) USING(CTL1)
/*
//CTL1CNTL DD  *
  SORT FIELDS=(1,20,CH,A)
/*

In first step, first 4 fields SEQ_ID, AMOUNT, TRAN_ID and PRI_CUS from all the records are written to &&T1 temporary dataset. Also all the records in the input file which do not have spaces in fifth field (col21-25 i.e secondary customer), first three fields SEQ_ID, AMOUNT , TRAN_ID (these together occupy col1-15) and fifth field SEC_CUS (col 21-25) are extracted from these records and &&T2 file is created.

In the second step, &&t1 and &&t2 are merged and sorted to give data in OUTPUT file HLQ.YOUR.OUTPUT.

Hope this helps.


-Ajay
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sat May 17, 2008 9:02 pm    Post subject:
Reply with quote

Bhaskar,

Ajay's "solution" is ridiculously inefficient. You don't need four passes over the data to do what you want - you can do it in one pass with the following DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
SEQ11  10000  T10001  2000011 3000221
SEQ32  3000   T30021  2011000 1800111
SEQ45  23400  T43000  2001000
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL IFOUTLEN=60,
    IFTHEN=(WHEN=(31,1,CH,EQ,C' '),
      BUILD=(1,29)),
    IFTHEN=(WHEN=(23,7,ZD,LE,31,7,ZD),
      BUILD=(1,29,/,1,22,31,7)),
    IFTHEN=(WHEN=(23,7,ZD,GT,31,7,ZD),
      BUILD=(1,22,31,7,/,1,29))
/*
Back to top
View user's profile Send private message
Ajay Baghel

Active User


Joined: 25 Apr 2007
Posts: 205
Location: Bangalore

PostPosted: Sat May 17, 2008 9:26 pm    Post subject:
Reply with quote

Hi Frank,

I never used the '/' operator and it did not cross my mind.

Please let me know if i am right,

Quote:
BUILD=(1,29,/,1,22,31,7)


causes two o/p records to be written from one input record:
1) col1 to 29 to be written to first output record.
2) col1-22 followed by col 31-37 to second o/p record.

Yes, my solution is less efficient as compared since it requires more no of passes. But it does the job.


Thanks,
Ajay
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Sat May 17, 2008 11:54 pm    Post subject:
Reply with quote

Hello,

Quote:
Yes, my solution is less efficient as compared since it requires more no of passes. But it does the job.
Most organizations would not find this an acceptable answer for a Production solution.

For a one-time situation, maybe, but not as a philosophy.

/rant on
This is one of the major issues facing management today. There are far too many "developers" who have no idea how to do their job properly, so anything that happens to run to end-of-job is promoted and used. It is creating a performance and maintenance nightmare.
/rant off
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Sun May 18, 2008 9:06 pm    Post subject:
Reply with quote

Ajay,

Yes, that's what the BUILD statement does and IFOUTLEN=60 ensures that the output records are padded on the right with blanks to 60 bytes.

Quote:
Yes, my solution is less efficient as compared since it requires more no of passes. But it does the job.


Actually, your "solution" doesn't even do the job! It has many problems. STEP1 is missing the required //SYSOUT DD statement. STEP2 is missing the required //TOOLMSG, //DFSMSG and //TOOLIN statements. The OMIT operand has a syntax error (missing format in OMIT). So as shown your job wouldn't even complete successfully.

If it did complete, it would give an output LRECL of 20 when the OP asked for 60.

I don't even see what you're trying to do - it doesn't seem to make any sense given that there was supposed to be a comparison between the two ZD fields and you don't have any such comparison.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Mon May 19, 2008 2:09 am    Post subject: Reply to: Split a record into two records
Reply with quote

Ahhh - the best of both worlds. . . icon_confused.gif

Not only can this type of "solution" cause the purchase of more/faster expensive hardware, it also provides the wrong answer icon_rolleyes.gif

And the population is growing. . .

d
Back to top
View user's profile Send private message
bhaskar_kanteti

Active User


Joined: 01 Feb 2007
Posts: 113
Location: India

PostPosted: Mon May 19, 2008 8:21 pm    Post subject: Reply to: Split a record into two records
Reply with quote

Hi Frank,

Thanks for providing a simple solution.
Thank you so much.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us