Hi team,
I would appreciate your ideas on how I could update the very last character of the last record in a FB(80) dataset.
This dataset is the result of a split of a larger one, with each chunk having approx. 1/2 a million records, all of the same layout. For this reason, I cannot use 'IFTRAIL=' as there is nothing to identify the last record as a trail. And the last chunk contains an unknown number of remaining records. Each chunk has to replace its last character to a special one indicating the end of the dataset!
I am thinking of using (another) SUBSET to isolate the last record, update it, using OVERLAY or FINDREP, and then concatenate to the original-1 record set, but since this is a repetitive process that splits the dataset in multiple ones, and the last will have an unknown number of records, this gets a bit more complcated.
I wonder if there would be a simple method to update the last char of the last record, whitout using SUBSET.
Thank you
GG
Update Last Char in last Record of a Dataset
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Update Last Char in last Record of a Dataset
Why do you need a special indicator to tell a properly written program that EOF has been reached? Why does the usual method of determining EOF not work?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Posts: 34
- Joined: Wed Apr 04, 2018 8:13 pm
- Skillset: z/OS, REXX, DB2, CICS, MQ, ISPF, DFSMS
- Referer: google
- Location: London, UK
Re: Update Last Char in last Record of a Dataset
It is a dataset that will be xlated to ASCII. Every record finishes with x'1E' but this char has to be substituted with x'1D' for the last char of the last record.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Update Last Char in last Record of a Dataset
None of standard utilities do have an option to know in advance: if there are no more records in the dataset (e.g. to check if the current record is the last one, or not?)
For each task an appropriate tool needs to be chosen. In this case, the existing "IBM UTILITIES & TOOLS ‹ DFSORT/ICETOOL/ICEGENER" is not good choice.
The most simple way is REXX
For each task an appropriate tool needs to be chosen. In this case, the existing "IBM UTILITIES & TOOLS ‹ DFSORT/ICETOOL/ICEGENER" is not good choice.
The most simple way is REXX
Code: Select all
/* REXX */
FIXUNIX:
"NEWSTACK"
"EXECIO * DISKR INDD (FINIS"
"EXECIO 0 DISKW OUTDD (OPEN"
Do iRec = 1 By 1 While Queued() > 0
Parse Pull NewRecord
If Queued() = 0 Then Do /* last record detected! */
LastChar = Right( NewRecord, 1 )
If LastChar = '1E'x Then /* remove '1E'x before appending '1D'x */
NewRecord = Left( NewRecord, Length(NewRecord) - 1 )
NewRecord = NewRecord || '1D'x /* append to the last record only */
End
Push NewRecord
"EXECIO 1 DISKW OUTDD"
End iRec
"EXECIO 0 DISKW OUTDD (FINIS"
"DELSTACK"
Return 0
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 34
- Joined: Wed Apr 04, 2018 8:13 pm
- Skillset: z/OS, REXX, DB2, CICS, MQ, ISPF, DFSMS
- Referer: google
- Location: London, UK
Re: Update Last Char in last Record of a Dataset
Thanks Sergey,
I have already done it with REXX. I only wanted to avoid REXX, as the rest of the gang here do not feel comfortable with REXX. That's why I am trying to use as much SORT as possible.
Thanks for confirming that there is no easy way to do it with SORT alone, without spliting the dataset with SUBSET.
I really appreciate your time,
Thanks again
GG
I have already done it with REXX. I only wanted to avoid REXX, as the rest of the gang here do not feel comfortable with REXX. That's why I am trying to use as much SORT as possible.
Thanks for confirming that there is no easy way to do it with SORT alone, without spliting the dataset with SUBSET.
I really appreciate your time,
Thanks again
GG
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Update Last Char in last Record of a Dataset
The example above is a classic way of any sequential dataset processing.
In this particular case, when we know for sure that only one single record needs to be processed, the REXX code can be significantly simplified:
In this particular case, when we know for sure that only one single record needs to be processed, the REXX code can be significantly simplified:
Code: Select all
/* REXX */
FIXUNIX:
"NEWSTACK"
"EXECIO * DISKR INDD (FINIS" /* read the whole dataset into program stack */
TotalRecords = Queued()
If TotalRecords > 0 Then Do /* non-empty input? */
"EXECIO" (TotalRecords - 1) "DISKW OUTDD (OPEN" /* write back all except the last record */
Parse Pull LastRecord
LastChar = Right( LastRecord, 1 )
If LastChar = '1E'x Then /* remove '1E'x before appending '1D'x */
LastRecord = Left( LastRecord, Length(LastRecord) - 1 )
LastRecord = LastRecord || '1D'x /* append to the last record only */
Push LastRecord
"EXECIO 1 DISKW OUTDD" /* re-write last record */
End
"EXECIO 0 DISKW OUTDD (FINIS" /* close the output, either empty or not */
"DELSTACK"
Return 0
Javas and Pythons come and go, but JCL and SORT stay forever.
- prino
- Posts: 641
- Joined: Wed Mar 11, 2009 12:22 am
- Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
- Referer: Google
- Location: Vilnius, Lithuania
- Contact:
Re: Update Last Char in last Record of a Dataset
Add a sequence number in SORT, sort descending, change the first record, resort ascending stripping off the sequence number. Just about as (in)efficient as a REXX execio of the entire dataset of half-a-million 80 byte records.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
robert.ah.prins @ the.17+Gb.Google thingy
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Update Last Char in last Record of a Dataset
prino wrote:Add a sequence number in SORT, sort descending, change the first record, resort ascending stripping off the sequence number. Just about as (in)efficient as a REXX execio of the entire dataset of half-a-million 80 byte records.
Any person who has ever dealt with millions-record datasets would not ask such questions at the Beginners Forum.
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: Update Last Char in last Record of a Dataset
And yet it was stated in the original post that the dataset held more than .5 million records so Prino's point is valid and I, as an 'expert' ie >40 years experience, would post my sort queries in this forum because I am not an expert on sort beyond the basics.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: Update Last Char in last Record of a Dataset
NicC wrote:And yet it was stated in the original post that the dataset held more than .5 million records so Prino's point is valid and I, as an 'expert' ie >40 years experience, would post my sort queries in this forum because I am not an expert on sort beyond the basics.
Prino's solution:
1) re-sort the numbered huge input in reverse order, and
2) update its first record, and
3) re-sort it back to the original order
- seems to be even more suicidal than simple REXX-EXECIO...
If needed, SORT tools can be used like this.
At least - only two sequential scans, without re-ordering...
Code: Select all
//*============================================================
//* MODIFY LAST RECORD ONLY
//*============================================================
//SORTGRP EXEC PGM=ICETOOL
//*
//SYMNAMES DD DCB=(RECFM=FB,LRECL=80),
// SPACE=(TRK,1)
//*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//*
//SORTIN DD *
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
NEED TO CHANGE THIS RECORD --->$
//*
//*------------------------------------------------------------
//TOOLIN DD *
COPY FROM(SORTIN) TO(SYMNAMES) USING(S001)
COPY FROM(SORTIN) TO(SORTOUT) USING(S002)
//*
//*--------------------------------------------------------------
//S001CNTL DD *
OUTFIL FNAMES=(COUNT@,SYMNAMES),
REMOVECC,NODETAIL,
TRAILER1=('$lastnum,',COUNT=(ZD,LENGTH=10),80:X)
//*--------------------------------------------------------------
//S002CNTL DD *
INREC BUILD=(1,80,SEQNUM,4,BI)
OUTREC IFTHEN=(WHEN=(81,4,BI,EQ,$lastnum),
FINDREP=(INOUT=(X'1E',X'1D',
C'$',C'@')))
OUTFIL BUILD=(1,80)
//*
//*--------------------------------------------------------------
//COUNT@ DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//*
//*==============================================================
Code: Select all
********************************* TOP OF DATA ******
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
no need to change --->$
NEED TO CHANGE THIS RECORD --->@
******************************** BOTTOM OF DATA ****
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 1799
-
by sergeyken
View the latest post
Fri Mar 26, 2021 11:59 pm
-
-
remove leading special chars, space & trailing special char
by srihemz » Tue Jun 30, 2020 8:06 pm » in DFSORT/ICETOOL/ICEGENER - 2
- 3874
-
by sergeyken
View the latest post
Wed Jul 01, 2020 4:55 pm
-
-
-
Copy partial record after a string in a record using SORT.
by Esmayeelhusen » Thu May 04, 2023 3:03 pm » in DFSORT/ICETOOL/ICEGENER - 16
- 4288
-
by Esmayeelhusen
View the latest post
Mon May 22, 2023 3:50 pm
-
-
- 3
- 6824
-
by sergeyken
View the latest post
Sun May 01, 2022 11:26 pm
-
-
PCOMM 64-bit Automation Macro failing to update WindowsTitle
by suriPCOMM » Tue Aug 31, 2021 5:33 am » in Simulators & Emulators - 0
- 7985
-
by suriPCOMM
View the latest post
Tue Aug 31, 2021 5:33 am
-