View previous topic :: View next topic
|
Author |
Message |
late4tt
New User
Joined: 22 Oct 2023 Posts: 6 Location: US
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
What have you tried yourself to achieve this? |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2146 Location: USA
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
I assume it should be Min/Max, although the sequence seems sorted already. Min/Max makes it more easy to solve. |
|
Back to top |
|
|
late4tt
New User
Joined: 22 Oct 2023 Posts: 6 Location: US
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2146 Location: USA
|
|
|
|
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 |
|
|
|