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

Can I replace 2 trailers from a file with a single Trailer?


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

New User


Joined: 13 Apr 2005
Posts: 5

PostPosted: Wed Apr 13, 2005 3:00 pm
Reply with quote

Hi,

I have a merged file with some headers,lines and trailers.The trailers appear twice now with two different record counts.
By using JCL Sort, Can I replace 2 trailers with a single Trailer?
The record count of the Single Trailer should be the sum of the existing 2 trailers.

e.g Currently in the existing file" we have the following trailers.

T R32055 040605 000008211
----------data------
T R32055 040605 000003712

In place of this we should have

T R32055 040605 000011933.

Where 000011933 = 000008211 + 000003712

I need an urgent reply.

Thanks,
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Wed Apr 13, 2005 6:09 pm
Reply with quote

Try using the sort sum for the field you desire...
SUM FIELDS=(17,9,CH/PD/BI ETC....)
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Wed Apr 13, 2005 6:48 pm
Reply with quote

Ops... sorry... i made a mistake... icon_redface.gif
use this statement:

SORT FIELDS=(1,16,CH,A)
SUM FIELDS=(17,9),FORMAT=ZD
OUTFIL OUTREC=(1,16,17,9,ZD,M11)

icon_wink.gif
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 Apr 13, 2005 10:33 pm
Reply with quote

LOPA,

You really haven't given enough information to help us give you a solution.

MGIndaco's method is a shot in the dark. It assumes that the data records can be sorted on positions 1-16 (we don't know this), that there are no duplicates among the data records (we don't know this) and that sorting by 1-16 will put the trailer record in the correct place relative to the data records (we don't know this). Also, the OUTFIL statement isn't needed - OPTION ZDPRINT can be used to get the total as 9 printable digits.

You need to show us a more complete example of your input records (what do the data records actually look like) and what you expect the output records to look like (e.g. where do you want the trailer record - before or after the data records).

What identifies a trailer record vs a data record (does the trailer record have a T in position 1 whereas the data record has something else in position 1?).

Also, what is the RECFM and LRECL of the input file.

If you need an urgent reply, you need to suppy enough information so we don't have to guess what you're trying to do.
Back to top
View user's profile Send private message
LOPA

New User


Joined: 13 Apr 2005
Posts: 5

PostPosted: Thu Apr 14, 2005 12:27 pm
Reply with quote

Hi Yaeger,

Thanks for your feedback.Even I was pondering with the same issues.
For a better clarity I am pasting a portion of data here for ur reference.
1st place is "L" for line data. "H" for header and "T" for batch trailer.

AS - IS data(Current data as it looks like today)
--------------
LR32000720134996 000043596315002 EA0
LR32000720134996 00008QF50DB EA0
TR32000040605000226161
HR32000126102457AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000126102457AA 00001CATTH2221SS 0
LR32000126102457AA 00002CATA2K20R 0
HR32000495301678AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000495301678AA 00001SPECBOMLINTERIOR EA0
LR32000184400798AA 00002TR200R 0
LR32000184400798AA 00003DEDUCTTOCLOSEPO 0
HR32000240500397SD NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000240500397SD 00001V07103 EA0
HR32000370403882AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000370403882AA 00001350MCMOKOGUARD600VOLTS TH0
HR32000770500057AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000770500057AA 00001193X224EAG01 EA0
HR32000119207663AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000119207663AA 00001SPECBOMLINTERIOR EA0
LR32000119207663AA 00002SPECBOMLBOX EA0
LR32000119207663AA 00003SPECBOMLFRONT EA0
TR32000040605000779903
---------------------------------------------

TO-BE Data( I wanted the above data to be in the following format)
-------------------------------------------------------------------------------

LR32000720134996 000043596315002 EA0
LR32000720134996 00008QF50DB EA0
HR32000126102457AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000126102457AA 00001CATTH2221SS 0
LR32000126102457AA 00002CATA2K20R 0
HR32000495301678AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000495301678AA 00001SPECBOMLINTERIOR EA0
LR32000184400798AA 00002TR200R 0
LR32000184400798AA 00003DEDUCTTOCLOSEPO 0
HR32000240500397SD NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000240500397SD 00001V07103 EA0
HR32000370403882AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000370403882AA 00001350MCMOKOGUARD600VOLTS TH0
HR32000770500057AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000770500057AA 00001193X224EAG01 EA0
HR32000119207663AA NNN1USDP2LVRXPD2 SUPPITIBS@GESUPPLY.COM
LR32000119207663AA 00001SPECBOMLINTERIOR EA0
LR32000119207663AA 00002SPECBOMLBOX EA0
LR32000119207663AA 00003SPECBOMLFRONT EA0
TR32000040605001006064
-------------------------


Hope this clarifies.
Back to top
View user's profile Send private message
MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Thu Apr 14, 2005 1:22 pm
Reply with quote

I'm in accord with you yaeger... I only replied to LOPA the easy way to resolve the problem that was explained in it's shortly version....
The ZDPRINT is only another way to proceed...
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 Apr 14, 2005 10:09 pm
Reply with quote

LOPA,

With z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec, 2004), you can use DFSORT's new IFTHEN and OVERLAY parameters to do what you want with this one pass DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
* Use F sign for summed ZD field.
  OPTION ZDPRINT
* Set seqnum (1,2, ...) in 81-88 for all records except
* T records.  Set 99999999 as seqnum for T records.
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
    IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),OVERLAY=(81:C'99999999'))
* Sort on seqnum.  H and L records will remain in their
* original sequence.  T records will be sorted last.
* Note that T records have dup seqnums (99999999), so they
* will be summed.  All other records have nondup seqnums
* so they won't be summed.
  SORT FIELDS=(81,8,ZD,A)
* Sum on amount in T records.
  SUM FIELDS=(14,9,ZD)
* Remove seqnum.
  OUTREC FIELDS=(1,80)
/*


If you have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). If you can't get it installed, you can use this DFSORT/ICETOOL job instead:

Code:

//S2    EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//*** Use MOD for OUT
//OUT DD DISP=MOD,DSN=...  output file
// DISP=(MOD,PASS)
//TOOLIN   DD    *
   COPY FROM(IN) USING(CTL1)
   SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
* IN->OUT:  Copy all records except T records.
   OUTFIL FNAMES=OUT,OMIT=(1,1,CH,EQ,C'T')
* IN->T1:  Copy all T records.
   OUTFIL FNAMES=T1,SAVE
/*
//CTL2CNTL DD *
* Use F sign for summed ZD field.
   OPTION ZDPRINT
* Sort on 'T'.
   SORT FIELDS=(1,1,CH,A)
* Sum on amount in T records.
   SUM FIELDS=(14,9,ZD)
/*
Back to top
View user's profile Send private message
LOPA

New User


Joined: 13 Apr 2005
Posts: 5

PostPosted: Mon Apr 18, 2005 7:11 pm
Reply with quote

Hi Frank,

Cann't I use any other option here?
I don't have this utilities ICETOOL and ICEMAN in my system.
Please do let me know asap.

Thanks,
Lopa
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 Apr 18, 2005 8:39 pm
Reply with quote

Quote:
I don't have this utilities ICETOOL and ICEMAN in my system.


Do you mean you don't have DFSORT? Because if you have DFSORT, you have ICEMAN and ICETOOL. If you don't have DFSORT, then I can't help you.
Back to top
View user's profile Send private message
brain_s390

New User


Joined: 06 May 2005
Posts: 58
Location: Mumbai

PostPosted: Sat May 21, 2005 4:47 pm
Reply with quote

Hey Frank,

I tried your code..It worked fine however the OUT file only contains trailer record.If we want all records with trailer in the last then what will be the solution ?
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 May 21, 2005 9:48 pm
Reply with quote

brain,

The S1 and S2 jobs I showed do give ALL of the records for LOPA's situation.

If you only got the trailer record, then something is different for your situation (e.g. different input record setup or RECFM or LRECL or ...).

You'd need to show me an example of YOUR input records, the job YOU used, YOUR output records, and the SYSOUT (S1) messages or TOOLMSG and DFSMSG (S2) messages YOU got in order for me to show you how to modify the job for YOUR situation. Feel free to send me the information offline (yaeger@us.ibm.com). Please put "DFSORT" somewhere in your Subject line to catch my attention.
Back to top
View user's profile Send private message
LOPA

New User


Joined: 13 Apr 2005
Posts: 5

PostPosted: Thu May 26, 2005 4:14 pm
Reply with quote

Hi Brain,

This is Lopa here once again.

Now I have one more problem.
Following is the sample of a Dataset sorted by "2nd to 7th Place"(inclusive of 2nd and 7th)

--------------------------------------------------------------------------
LR32000760230180 00010235A2508AD01
LR32000760230180 00011235A2507EB01
TR32000052405000988495
HR32000126102457AA NNN1USDP2LVRXPD2
LR32000126102457AA 00001CATTH2221SS
LR32000119207663AA 00001SPECBOMLINTER
LR32000119207663AA 00002SPECBOMLBOX
LR32000119207663AA 00003SPECBOMLFRONT
BR32055052405SUPPITIBS@GESUPPLY.COM

----------------------------------------------------------------------------

I want the data to look like

-------------------------------------------------------------------

LR32000760230180 00010235A2508AD01
LR32000760230180 00011235A2507EB01
HR32000126102457AA NNN1USDP2LVRXPD2
LR32000126102457AA 00001CATTH2221SS
LR32000119207663AA 00001SPECBOMLINTERIOR
LR32000119207663AA 00002SPECBOMLBOX
LR32000119207663AA 00003SPECBOMLFRONT
TR32000052405000988495
BR32055052405SUPPITIBS@GESUPPLY.COM

--------------------------------------------------------------------

Can I do that in using DFSORT ?
Please do let me know what we need to do for that


Thanks,
Lopa
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 May 26, 2005 7:58 pm
Reply with quote

It's not clear to me what it is you're trying to do. You need to explain the "rules" you want to use for sorting the records.
Back to top
View user's profile Send private message
LOPA

New User


Joined: 13 Apr 2005
Posts: 5

PostPosted: Fri May 27, 2005 5:24 pm
Reply with quote

I want the Trailer to Appear at the end of all the BUC Codes (here it is R32000)and before the Batch header of the next BUC Code (here it is R32055)

All the records are sorted by this BUC code now. Which is of 6 characters.
i.e. R32000 , R32055 etc.

Let me know your suggestion.

Thanks,
Lopa
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 May 27, 2005 8:41 pm
Reply with quote

Here's a DFSORT job that will do what you asked for. You'll need z/OS DFSORT V1R5 PTF UQ95214 or DFSORT R14 PTF UQ95213 (Dec,
2004) in order to use DFSORT's new IFTHEN and OVERLAY functions. Only DFSORT has these functions, so if you don't have DFSORT, you won't be able to use them. If you do have DFSORT, but you don't have the Dec, 2004 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the Dec, 2004 PTF, see:

Use [URL] BBCode for External Links

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
* Put '1' in 81 for trailer record.
* Put '0' in 81 for all other records.
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'0')),
       IFTHEN=(WHEN=(1,2,CH,EQ,C'TR'),OVERLAY=(81:C'1'))
  OPTION EQUALS
* Sort on BUC and then on '0' or '1' in 81.
  SORT FIELDS=(3,5,CH,A,81,1,CH,A)
* Remove '0' or '1' from 81.
  OUTREC FIELDS=(1,80)
/*

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 FTP VB File from Mainframe retaining ... JCL & VSAM 4
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top