View previous topic :: View next topic
|
Author |
Message |
Parvinder Singh
New User
Joined: 06 Sep 2011 Posts: 6 Location: india
|
|
|
|
Hi,
I have a varialbe record lenght file , i want to trim the trailing spaces for the records , do we have any function available in PL/1 which trims the trailing spaces? Function 'TRIM' is availble in E-PL/1 any similr kind of function in PL/1 for vaiable records? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Maybe a backwards "DO" loop, using SUBSTR until the 'nth' byte does not equal a space?
There are more advanced PL/I folks around so perhaps, wait for their replies. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Parvinder Singh wrote: |
Hi,
I have a varialbe record lenght file , i want to trim the trailing spaces for the records , do we have any function available in PL/1 which trims the trailing spaces? Function 'TRIM' is availble in E-PL/1 any similr kind of function in PL/1 for vaiable records? |
What compiler are you using? Version number, please. |
|
Back to top |
|
|
Parvinder Singh
New User
Joined: 06 Sep 2011 Posts: 6 Location: india
|
|
|
|
Hi,
Ther PL/1 compiler is Ver 1 Rel 1 Mod 1. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Hmmm. For MVS V1.1.1, I can't think of a better suggestion than Mr. O'Boyle's, although Mr. Prins might be able to do so. I do, however, suggest that your shop seriously consider upgrading; that compiler has been out of support for about three years. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this trimming also adjust the vli (record length indicator)
and rewrite the record.
all this trimming of trailing spaces...why is it?
are they not part of the last field?
are they being added due to poor/bad/incorrect ftp commands?
i have never seen the need to remove the trailing spaces.
and please, do not give me any crap about saving dasd.
either the spaces belong,
or they were incorrectly added during the creation of the file.
fix the creation process. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
I had assumed, perhaps incorrectly, that his situation was about like this;
Code: |
dcl (this, that) char (8),
the_other_thing char (64),
record char (80) var;
:
:
record = trim(this || that || the_other_thing);
write file (foo) from (record); |
|
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1315 Location: Vilnius, Lithuania
|
|
|
|
Akatsukami wrote: |
I had assumed, perhaps incorrectly, that his situation was about like this;
Code: |
dcl (this, that) char (8),
the_other_thing char (64),
record char (80) var;
:
:
record = trim(this || that || the_other_thing);
write file (foo) from (record); |
|
That's most likely the scenario, and if we're dealing with really long records (XML?, VB 27994), the savings of trimming the training spaces may be significant.
Sadly, as you are using a version of PL/I that is well past its sell-by date, only Bill's solution would be possible, but it would, if the records are long and there can be large amounts of blanks, use CPU like there is no tomorrow, and there is very little you can do about this, unless you are willing to go for rather esoteric tricks like overlaying the string with an array of FIXED BIN (31)'s and checking those for 1,077,952,576, which would give you a four-fold increase in speed. |
|
Back to top |
|
|
Parvinder Singh
New User
Joined: 06 Sep 2011 Posts: 6 Location: india
|
|
|
|
Hi Prino,
Yes, I am dealing with really long XML records :-) (VB,30000).
I will use Bill's solution and will work with project team and will definetly try to see if we can upgrade the compiler version.
@all ,Thanks a lot for your valuable time and suggestions. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
When the cpu needed to support this is unacceptable, you need to understand and try the method Prino provided. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1315 Location: Vilnius, Lithuania
|
|
|
|
There is an even "better" and more esoteric method, but to know if that can be used, you need to tell us how many records you are producing and the average length of those records. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If CPU is a problem for Bill's method, wouldn't it be a problem for any "trim" as well?
Isn't an LRECL of 30000 a bit wasteful in itself? Leaving 26000 bytes per track unused.
Isn't the best answer going to be for the creator of the data not to put the trailing blanks on?
Are your records fixed-length? And you want variable? If yes, you could, as an interim, put it through a Sort step, FTOV with VLTRIM. |
|
Back to top |
|
|
|