LRECL is an attribute of any dataset (not file). LRECL value is set initially at first creation of any dataset, as a constant; it cannot be changed during the life of this dataset, unless the dataset is re-created from scratch.
When dataset has RECFM=VB, it is possible to change the length of each particular record in the range from 5 bytes to its LRECL value.
When dataset has RECFM=FB, then it is not possible to change the size of each particular record, at all.
In order to change the size of particular records with RECFM=VB by SORT utilities, you need to learn something about SORT parameters (if only you plan to do it by yourself):
- PARSE
- BUILD
- SQZ
- FTOV
- VLTRIM
Ok, thank you, my output is VB, how can
I do this truncation at a specific character?
In order to change the size of particular records with RECFM=VB by SORT utilities, first of all you may need to learn something about SORT parameters (if only you plan to do it by yourself):
- PARSE
- BUILD
- SQZ
- FTOV
- VLTRIM
P.S.
There are tons of examples spread across this forum, other internet resources, and available manuals and references on SORT utilities.
Thanks, obviously i tried many times before disturbing You but don't undertand how to use the PARSE option.
If the parameter FIXLEN(don't know the position of the char '$') is omitted the sort ends with syntax error. When FIXLEN=50 is specified it works but the LREC of output file is always 1000 and not 50.
Thanks, obviously i tried many times before disturbing You but don't undertand how to use the PARSE option.
If the parameter FIXLEN(don't know the position of the char '$') is omitted the sort ends with syntax error. When FIXLEN=50 is specified it works but the LREC of output file is always 1000 and not 50.
2) There is no such thing as LREC, there is only LRECL
3) Since you specified explicitly: //SORTOUT DD RECFM=FB, you cannot get anything except RECFM=FB
4) When creating a dataset with RECFM=VB, it is not good idea to give the dataset name DSN=......FB
5) when creating a dataset, it is not good idea to name it as DSNAME=...FILE...
It is about the same as naming a new function as VARIABLE(...), or a new JCL as //SYSOUT JOB ...
6)
Code:
. . . . . . . .
//SORTOUT DD DSN=&SYSUID..TESTDATA.VB,
// DCB=(RECFM=VB,LRECL=1004,BLKSIZE=0),...
//* LRECL=(data size + 4)
. . . . . . . . .
//SYSIN DD *
* Stage1: re-build fixed record 1000 bytes without any garbage after '$'
INREC PARSE=(%1=(ENDBEFR=C'$',FIXLEN=1000)), - cut the garbage
BUILD=(%1) - extended the truncated part to 1000 bytes
SORT FIELDS=COPY
* Stage2: Convert RECFM=FB to RECFM=VB,
* by trimming all trailing spaces (not '$' !!!)
OUTFIL FTOV,VLTRIM=C' '
END
Probably i'm not able to explain...the scope is to obtain a FB file shorter than the input file, not a VB LRECL=1004....for this sample should be a FB with LRECL=50
Input:
Code:
***************************** Top of Data ******************************
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $
YYYYYYYYYYYYYYY $
**************************** Bottom of Data ****************************
Probably i'm not able to explain...the scope is to obtain a FB file shorter than the input file, not a VB LRECL=1004....for this sample should be a FB with LRECL=50
Input:
Code:
***************************** Top of Data ******************************
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX $
YYYYYYYYYYYYYYY $
**************************** Bottom of Data ****************************
You can read ANY FB dataset, and EVERY record will be first extended to the value specified in FIXLEN, and then trimmed to its actual length by VLTRIM parameter.
Try to do at least something by yourself, and learn how to analyze the results, and to make appropriate changes if needed.
Without doing this you'll never be able to develop YOUR OWN product, even a minor one. Just blind copying-and-pasting the results of other's work would not help, unless you start trying, and thinking by your own.
P.S.
Are you sure there are spaces, not X'00' or other unprintable characters in your records?
First of all: VERIFY CAREFULLY YOUR INPUT IN HEX MODE!
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
@calcop69: You should rethink your desired solution. It is of course feasible to solve, but I personally would dislike to have an outcome with every Job run that can be different from the previous ones.
Joined: 15 Aug 2015 Posts: 1337 Location: Bamberg, Germany
@calcop69: You must use FIXLEN=1000 as this is the maximum logical record length w/o RDW. VLTRIM=C' ' will remove the clutter at the end after the parsed field.
What's missing is the fix to write to F(B) dataset once you know the maximum record length after stripping the "$" sign.
I can copy-and-paste my very first response for you.
You still are not able to understand, that your initial plan is absolutely undoable...
Quote:
LRECL is an attribute of any dataset (not file). LRECL value is set initially at first creation of any dataset, as a constant; it cannot be changed during the life of this dataset, unless the dataset is re-created from scratch.
When dataset has RECFM=VB, it is possible to change the length of each particular record in the range from 5 bytes to its LRECL value.
When dataset has RECFM=FB, then it is not possible to change the size of each particular record, at all.
@calcop69: You must use FIXLEN=1000 as this is the maximum logical record length w/o RDW. VLTRIM=C' ' will remove the clutter at the end after the parsed field.
What's missing is the fix to write to F(B) dataset once you know the maximum record length after stripping the "$" sign.
In fact, this is the problem, there isn't any 'garbage' after the char '$' only blanks (X'40')
I need to write a JCL able to write a FB file with LRECL corresponding to the maximum position of the character '$' found in the input file.
Thank You
@calcop69: You must use FIXLEN=1000 as this is the maximum logical record length w/o RDW. VLTRIM=C' ' will remove the clutter at the end after the parsed field.
What's missing is the fix to write to F(B) dataset once you know the maximum record length after stripping the "$" sign.
In fact, this is the problem, there isn't any 'garbage' after the char '$' only blanks (X'40')
I need to write a JCL able to write a FB file with LRECL corresponding to the maximum position of the character '$' found in the input file.
Thank You
Any "undesired blanks" at the end of your data is nothing else but GARBAGE!
You may need:
1) to find the MAXIMUM length of DATA among (thousands?) of your input records.
2) to use any tool for DYNAMIC ALLOCATION of a dataset (not FILE after all!!!!!!!!!) to create new output dataset with just calculated LRECL.
3) this all cannot be done, neither in JCL, nor in SORT. Possible workarounds do not worth this senseless goal. Forget about it.
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
Your desired result could be achieved using SAS, but I'm not sure anything else would work. You would need a SAS job to analyze the input and determine how long the output data set LRECL must be; this job then creates and submits into the internal reader a second job with the needed LRECL coded in it.
Why two jobs? Because when a job is submitted, pretty much the first thing that JES does is run the job through the converter / interpreter (CI). The CI tokenizes the JCL and JES executes the tokenized JCL. Hence it is not possible, under any circumstances, to determine the LRECL of the data set in one step and use that LRECL in the next (or any subsequent) step.
***************************** Top of Data ******************************
XXX XXXXXXX XXXXXXXXXXX XX XXX XXX XXXXXX XXXXX
4EEE4EEEEEEE4EEEEEEEEEEE4EE4EEE4EEE4EEEEEE4EEEEE
077707777777077777777777077077707770777777077777
-----------------------------------------------------------------------
XXXXXX XXXXX
4EEEEEE4EEEEE44444444444444444444444444444444444
077777707777700000000000000000000000000000000000
-----------------------------------------------------------------------
X
E44444444444444444444444444444444444444444444444
700000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
**************************** Bottom of Data ****************************
The last two tricks and gimmicks can work, but the correct and simple (!!! from zOS architecture point of view) problem solving would be: using the attributes RECFM=VB with the same (maximum needed) LRECL for all instances of the output dataset created each time.
This conversion of (RECFM=VB,LRECL=1004) to (RECFM=FB,LRECL=xx) doesn't give any advantages except drawbacks - for future use and maintenance of the system. Also the required disk space would rather increase than decrease, because in average those new "tails of blanks" for each new record RECFM=FB will certainly go beyond the total size of 4-byte RDW fields for all records RECFM=VB.