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

Sort First/last record of a subset then adding to a Dataset


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

New User


Joined: 22 Oct 2023
Posts: 6
Location: US

PostPosted: Tue Oct 24, 2023 11:40 pm
Reply with quote

My requirement is to:
- Identify the first and last account number record from a report dataset (postioin 23,11) and append the first/last account number to an existing dataset (FB) containing 1 record with LRECL=225

Code:
INPUT
Code:

----+----1----+----2----+----3----+----4----+----5----+----
  ### - NAME ### A MM/DD/CCYY            REPORT NAME       
 RELATED  RELATED       RELATED     RELATED   RELATED   REL
   DP       S  ###    XXXXXXX9511       X      ##  31     
   DP       S  ###    XXXXXXX9547       X      ##  31     
   DP       S  ###    XXXXXXX9574       X      ##  31     
   DP       S  ###    XXXXXXX9590       X      ##  31     
  ### - NAME ### A MM/DD/CCYY            REPORT NAME       
 RELATED  RELATED       RELATED     RELATED   RELATED   REL
   DP       S  ###    XXXXXXX9591       X      ##  ##     
   DP       S  ###    XXXXXXX9652       X      ##  ##     
   DP       S  ###    XXXXXXX9720       X      ##  ##     
   DP       S  ###    XXXXXXX9873       X      ##  ##     
 REPORT TOTAL: 00000000000000


The output dataset
Code:

Code:

OUTPUT (Appended to an existing dataset at position 201
....DATA FOR 200|XXXXXXX9511 XXXXXXX9873
                 |Position 201 - First Account
                             | Position 213 - Last Account




Thank you again in advance
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Wed Oct 25, 2023 10:45 pm
Reply with quote

What have you tried yourself to achieve this?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Thu Oct 26, 2023 11:43 am
Reply with quote

Hint: Use INCLUDE COND=(..) to filter for account numbers only. In OUTFIL's TRAILER1, use MIN=() MAX=() functions. All in all it's about five lines of SORT code.

Code:
****** **************************** Datenanfang ***
000001 ....DATA FOR 200|XXXXXXX9511 XXXXXXX9873   
****** **************************** Datenende *****
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Thu Oct 26, 2023 8:10 pm
Reply with quote

late4tt wrote:
Code:

OUTPUT (Appended to an existing dataset at position 201
....DATA FOR 200|XXXXXXX9511 XXXXXXX9873
                 |Position 201 - First Account
                             | Position 213 - Last Account


I repeat for the third time:

Datasets consist of the sequence of records. There is no such thing as "dataset at position 201".
There are such things as: Record 1, Record 100, Record 123456, etc.

It also remains unclear, after all requests you to clarify this: what do you really need:
first/last accounts in the order they are listed,
or
min/max account NUMBERS?
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Thu Oct 26, 2023 10:02 pm
Reply with quote

I assume it should be Min/Max, although the sequence seems sorted already. Min/Max makes it more easy to solve.
Back to top
View user's profile Send private message
late4tt

New User


Joined: 22 Oct 2023
Posts: 6
Location: US

PostPosted: Mon Oct 30, 2023 7:51 pm
Reply with quote

Joerg.Findeisen wrote:
I assume it should be Min/Max, although the sequence seems sorted already. Min/Max makes it more easy to solve.


Joerg,

You are correct the dataset is sorted in account number order, so min / max will work. (Thanks for the idea)

I've been able to pull the MIN/MAX account numbers using this code to write to a new dataset:
Code:
//TOOLIN   DD    *                                 
SORT FROM(IN) TO(T1) USING(CTL1)                   
/*                                                 
//CTL1CNTL DD *                                     
 SORT FIELDS=(23,11,ZD,A)                           
 INCLUDE COND=(23,11,ZD,EQ,NUM)                     
 OUTFIL FNAMES=OUT,NODETAIL,REMOVECC,               
   TRAILER1=(3:MIN=(23,11,ZD,M1,LENGTH=12),         
             15:MAX=(23,11,ZD,M1,LENGTH=12))       
/*                                                 
Gives me a new dataset with the correct min/max (first/last) information:
  xxxxxxx9511  xxxxxxx9591


I'm struggling with appending the account numbers to an existing dataset instead of creating a new one. The existing dataset is FB225 and contains 1 record with addition data I need in the first 200 bytes.


Code:
=COLS>    9----+----0----+----1----+----2----+
******    ***************************** Top of Data **
000001    ----data---**minacct** **maxacct**         
******    **************************** Bottom of Data


There's a lot to learn and you guys are really helpful, as I learn best from examples.

I appreciate your help
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Mon Oct 30, 2023 8:02 pm
Reply with quote

You want to append the Data to an existing record in your output DSN, that is a different issue. A quick thought on this is a two step solution, or using the Ultimate JOINKEYS.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2023
Location: USA

PostPosted: Mon Oct 30, 2023 8:22 pm
Reply with quote

late4tt wrote:

I'm struggling with appending the account numbers to an existing dataset instead of creating a new one. The existing dataset is FB225 and contains 1 record with addition data I need in the first 200 bytes.

I have tried to explain at least three times, that there is no such thing in this world as "adding the new data to any position within a dataset".

Please, remember:
Quote:
A DATASET is combined of RECORDS.
A FILE is combined of BYTES.


Please, do not mix two different entities.
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 Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
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
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top