Re: Calculate deltas using DFSORT

2022-09-03 Thread Paul Gilmartin
On Wed, 31 Aug 2022 16:35:27 +, Sri h Kolusu wrote:
>...
>>>The DFSORT manual (and others) should not attempt to explain regular 
>>>expressions.  They should defer to citing a single publication with such an 
>>>explanation.
>
>I completely agree, however each component within IBM is implementing a 
>regular expression flavor. Different regular expression flavors are not fully 
>compatible with each other. So it is difficult to have 1 central publication.
> 
I'm surprised, skeptical even, that DFSORT implements regular expressions 
entirely with
fresh code rather than employing available library functions such as regcomp() 
with a
brief description of how arguments to regcomp() depend on options in DFSORT 
commands.

An exemplar of what I consider wise design and documentation is REXX BPXWUNIX:
Parameters
cmd
The shell command that you want to run. The shell is run as /bin/sh -c 
followed by
the string that you specify as the command. If a login shell is requested, 
the shell
is run passing a single argument similar to the sh -Lc command.
...
It makes no attempt to describe the syntax of shell commands, which are 
described
in another publication (which it fails to cite.)


>Locale is NOT supported with regular expressions and it is documented here
>
>https://www.ibm.com/docs/en/zos/2.5.0?topic=expressions-regular-application-notes
>
The following existing DFSORT functions are not compatible when used with 
Regular expressions:
Locale

Ouch!

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Paul Gilmartin
On Wed, 31 Aug 2022 13:30:14 -0500, Walt Farrell wrote:
>
>But, whose "tradition"? PERL, PCRE, Python, Boost, ...
>
Don't overlook .

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Paul Gilmartin
On Wed, 31 Aug 2022 13:30:14 -0500, Walt Farrell wrote:
>
>>But it might be proper to emphasize any difference between DFSORT's use of
>>reg-ex and traditional beliefs.
>
>But, whose "tradition"? PERL, PCRE, Python, Boost, ...
>
>Does the DFSORT documentation name a standard that they've implemented?
>
Several.  "The great thing about standards ...".  From the Guide:
Regular expressions
This support is based on the following Standards /Extensions:
• XPG4 (X/Open Common Applications Environment Specification, System Interfaces 
and Headers, Issue 4.)
• XPG4.2 (X/Open Common Applications Environment Specification, System 
Interfaces and Headers, Issue 4, Version 2.)
• Single UNIX Specification, Version 3 (IEEE Std 1003.1-2001.)
• z/OS UNIX (functions that provide z/OS UNIX support beyond the defined 
standards.)
Two versions of regular expressions are supported:
• Basic Regular expressions (BRE)
• Extended Regular expressions (ERE)

I don't see where the Guide tells how the programmer may choose between BRE and 
ERE.
(But it does provide the REH extension.)

They didn't mention XLC/C++, probably the underlying support.

-- 
Thanks,
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Walt Farrell
On Wed, 31 Aug 2022 11:13:57 -0500, Paul Gilmartin  wrote:


>>In any case, "[^abc]" does not match "wombat". It matches only a single 
>>character of a string. So, it might match the "w" in "wombat", or the "o", or 
>>the "m", or the "t", depending on other details of the input string being 
>>processed, and the application doing the processing.
>> 
>Absent an anchor ("^" and/or "$") a pattern can be matched anywhere in a 
>subject.

Good point. Thanks.

>
>>I agree with your comment (which I omitted from my quote) that the DFSORT 
>>books should not try to explain reg-ex processing, unless they have written 
>>their own processor instead of reusing someone else's.
>>
>+1
>But it might be proper to emphasize any difference between DFSORT's use of
>reg-ex and traditional beliefs.

But, whose "tradition"? PERL, PCRE, Python, Boost, ...

Does the DFSORT documentation name a standard that they've implemented?

-- 
Walt

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Walt Farrell
On Wed, 31 Aug 2022 16:35:27 +, Sri h Kolusu  wrote:


>>>The DFSORT manual (and others) should not attempt to explain regular 
>>>expressions.  They should defer to citing a single publication with such an 
>>>explanation.
>
>I completely agree, however each component within IBM is implementing a 
>regular expression flavor. Different regular expression flavors are not fully 
>compatible with each other. So it is difficult to have 1 central publication.

Perhaps, if you're implementing a specific, standard reg-ex flavor (e.g., PERL, 
or PCRE, or one of the Boost libraries) you could consider just pointing to the 
standard documentation. You would then only need to document exceptions to the 
standard behavior.

-- 
Walt

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Seymour J Metz
"Give a man a fish and you feed him for a day. Teach him to fish and you feed 
him for life."

An explanation is better than an example in the long run, although ideally you 
get both.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of Tom 
Brennan [t...@tombrennansoftware.com]
Sent: Wednesday, August 31, 2022 12:38 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Calculate deltas using DFSORT

But with DFSORT I don't need to know the syntax at all.  I can post a
note here describing what I'm trying to do along with some data samples,
and like the elves who make shoes, complete JCL and SYSIN will magically
appear the next morning.

On 8/30/2022 5:02 PM, Paul Gilmartin wrote:

> The DFSORT command syntax is dreadful -- too positional.  It's
> hard to read ...,keyword,value,keyword,value,...
> Considerably better would be ,keyword(value), or ,keyword=value,...
> I suppose the design is OK to programmers versed in it, but it
> repels the novice.  It may be easy for a computer to parse,
> but silicon is now cheaper than carbon.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Seymour J Metz
The not character for character classes in Unix regexen is Caret (^) rather 
than Logical Not (¬). I believes that this stems from an era when ASCII was in 
a state of flux and one code point could be either ^ or ¬.

And, yes, [^string] matches a single character not containing an character in 
string. Contrast with

 [^string]?
 [^string]*
 [^string]+

--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of 
Paul Gilmartin [042bfe9c879d-dmarc-requ...@listserv.ua.edu]
Sent: Wednesday, August 31, 2022 11:03 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Calculate deltas using DFSORT

On Wed, 31 Aug 2022 05:55:46 -0500, Mario Bezzi wrote:

>Sri Hari, Max, all,
>
>thank you very much from your kind help and support.
>
>I really appreciate it, and I hope to have the opportunity to reciprocate.
>
+1
Kolusu's assistance is priceless!


I've read on about regular expressions.  I see in the DFSORT Guide:
INCLUDE Control Statement
  The basic regular expression metacharacters are:
 ¬ $ . * \( \) [ \{ \} \

but later in a table:
[^string]

Is it "^" or "¬"?  Some clarification is needed.  I'll submit an RCF.

I hate EBCDIC!

The ISPF Edit Macros manual says that  metacharacters in regular
expressions are interpreted according to the CCSID of the controlling
terminal, listing several dozen supported CCSIDs, and says that in
background IBM-1047 is presumed.  Is this also true if DFSORT is
invoked by TSO CALL?  If SYSIN is allocated to a UNIX file tagged
with a CCSID, does DFSORT respect that CCSID?

I hate EBCDIC!

Also, in a table:
The caret symbol, when inside square brackets,
negates the characters within the square brackets.
Thus [^abc], if compared to other strings, would fail
to match any that contains even one a, b, or c.

("when inside square brackets" seems to be a restrictive
clause.  It should not be enclosed in commas.)

The "^" must be the first character inside the brackets
to have this effect.

The last sentence beginning "Thus ..." is incorrect.

"[^abc]" matches any string containing a character
other than a, b, or c.  It matches "wombat".  However,
"^[^abc]*$" matches strings containing no character
other than a, b, or c.   It does not match "wombat".

Another RCF, or the same one?

The DFSORT manual (and others) should not attempt
to explain regular expressions.  They should defer to
citing a single publication with such an explanation.

--
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Carmen Vitullo
+1 Tom, in my experience getting tradition help here has been great, 
especially in the DFSORT area, in my experience getting help with Java 
related issues, even from my vendors was spurratic(sp)  at best


Carmen

On 8/31/2022 12:30 PM, Tom Brennan wrote:

On 8/31/2022 9:35 AM, Sri h Kolusu wrote:
I can post a note here describing what I'm trying to do along with 
some data samples, and like the elves who make shoes, complete JCL 
and SYSIN will magically appear the next morning.


Tom,

I believe this platform is to share and help each other. I for one 
believe in sharing the knowledge and in the process, I might learn a 
thing or two from other topics. It also helps us to understand the 
customer requirements and implement them in future.There may be few 
bad apples who might take advantage of the help being received here, 
but that shouldn't stop us from sharing the knowledge.




I don't know how this turned into something about helping and sharing. 
I'm saying that if I don't know how to work either DFSORT or Java, I'd 
choose DFSORT because I'd get much better help here, often including 
complete and tested JCL/SYSIN.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Tom Brennan

On 8/31/2022 9:35 AM, Sri h Kolusu wrote:

I can post a note here describing what I'm trying to do along with some data 
samples, and like the elves who make shoes, complete JCL and SYSIN will 
magically appear the next morning.


Tom,

I believe this platform is to share and help each other. I for one believe in 
sharing the knowledge and in the process, I might learn a thing or two from 
other topics. It also helps us to understand the customer requirements and 
implement them in future.There may be few bad apples who might take advantage 
of the help being received here, but that shouldn't stop us from sharing the 
knowledge.



I don't know how this turned into something about helping and sharing. 
I'm saying that if I don't know how to work either DFSORT or Java, I'd 
choose DFSORT because I'd get much better help here, often including 
complete and tested JCL/SYSIN.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Sri h Kolusu

Hi,

One email with multiple responses.

>>. I can never understand what the DFSORT solutions are doing from reading the 
>>control cards, and I'm sure I am not alone there. A programming language 
>>makes it much easier for the person who has to understand it in the future.

Andrew,

Just to be clear, DFSORT is an Utility which does a lot of stuff and is not a 
match for a programming language. As for the understanding the control cards, 
it all depends on how you perceive them.  If you put a little effort like you 
do when you learn a new programming language, then it is a walk in the park.


>>I can post a note here describing what I'm trying to do along with some data 
>>samples, and like the elves who make shoes, complete JCL and SYSIN will 
>>magically appear the next morning.

Tom,

I believe this platform is to share and help each other. I for one believe in 
sharing the knowledge and in the process, I might learn a thing or two from 
other topics. It also helps us to understand the customer requirements and 
implement them in future.There may be few bad apples who might take advantage 
of the help being received here, but that shouldn't stop us from sharing the 
knowledge.

>>Although this is a joke... some respect for Sri please.

KB,

Thanks. Much appreciated for your support.

>>The rest is reality as I see it.  Whether that's good or bad I guess depends 
>>on your point of view.

The people who take advantage of the help they receive here will only thrive 
for a short period of time.

>>Kolusu's assistance is priceless!

Paul,

Thanks.

>>The last sentence beginning "Thus ..." is incorrect.

Thanks for bringing it to our attention. we will try to clarify it.

>>The DFSORT manual (and others) should not attempt to explain regular 
>>expressions.  They should defer to citing a single publication with such an 
>>explanation.

I completely agree, however each component within IBM is implementing a regular 
expression flavor. Different regular expression flavors are not fully 
compatible with each other. So it is difficult to have 1 central publication.


>>(I forgot to ask whether the LOCALE command affects the interpretation of 
>>metacharacters in SYSIN.  And to note that the Guide's using a 
>>proportional-spaced font makes syntax runes and examples confusing.)


Paul,

Locale is NOT supported with regular expressions and it is documented here

https://www.ibm.com/docs/en/zos/2.5.0?topic=expressions-regular-application-notes


Thanks,
Kolusu
DFSORT Development
IBM Corporation




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Paul Gilmartin
(I forgot to ask whether the LOCALE command affects the interpretation
of metacharacters in SYSIN.  And to note that the Guide's using a
proportional-spaced font makes syntax runes and examples confusing.)

On Wed, 31 Aug 2022 10:21:42 -0500, Walt Farrell wrote:

>On Wed, 31 Aug 2022 10:03:21 -0500, Paul Gilmartin  wrote:
>
>>
>>"[^abc]" matches any string containing a character
>>other than a, b, or c.  It matches "wombat".  However,
>>"^[^abc]*$" matches strings containing no character
>>other than a, b, or c.   It does not match "wombat".
>
>Was that something you said, or something you're quoting from the manual? I'm 
>not sure.
>
That;s what I said.  The passage in z⧸OS DFSORT Application Programming Guide
which I quoted and you trimmed was:

Also, in a table:
The caret symbol, when inside square brackets,
negates the characters within the square brackets.
Thus [^abc], if compared to other strings, would fail
to match any that contains even one a, b, or c.

Further on:
The following patterns are given as examples, along with descriptions of 
what they match:

abc Matches any record containing the three letters abc in that order.
Correct.  "containing" because it's unanchored.

a.c Matches any string beginning with the letter a, followed by any 
character, followed by the letter c.
Incorrect.  It's unanchored.  "beginning with" should be "containing".

(But is there a nice distinction between "record containing" and
"string beginning with"  of which I'm unaware.  Are those terms defined
and distinguished?)

>In any case, "[^abc]" does not match "wombat". It matches only a single 
>character of a string. So, it might match the "w" in "wombat", or the "o", or 
>the "m", or the "t", depending on other details of the input string being 
>processed, and the application doing the processing.
> 
Absent an anchor ("^" and/or "$") a pattern can be matched anywhere in a 
subject.

>I agree with your comment (which I omitted from my quote) that the DFSORT 
>books should not try to explain reg-ex processing, unless they have written 
>their own processor instead of reusing someone else's.
>
+1
But it might be proper to emphasize any difference between DFSORT's use of
reg-ex and traditional beliefs.

-- 
Thanks,
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Walt Farrell
On Wed, 31 Aug 2022 10:03:21 -0500, Paul Gilmartin  wrote:

>
>"[^abc]" matches any string containing a character
>other than a, b, or c.  It matches "wombat".  However,
>"^[^abc]*$" matches strings containing no character
>other than a, b, or c.   It does not match "wombat".

Was that something you said, or something you're quoting from the manual? I'm 
not sure.

In any case, "[^abc]" does not match "wombat". It matches only a single 
character of a string. So, it might match the "w" in "wombat", or the "o", or 
the "m", or the "t", depending on other details of the input string being 
processed, and the application doing the processing.

I agree with your comment (which I omitted from my quote) that the DFSORT books 
should not try to explain reg-ex processing, unless they have written their own 
processor instead of reusing someone else's.

-- 
Walt

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Paul Gilmartin
On Wed, 31 Aug 2022 05:55:46 -0500, Mario Bezzi wrote:

>Sri Hari, Max, all,
>
>thank you very much from your kind help and support. 
>
>I really appreciate it, and I hope to have the opportunity to reciprocate.
> 
+1
Kolusu's assistance is priceless!


I've read on about regular expressions.  I see in the DFSORT Guide:
INCLUDE Control Statement
  The basic regular expression metacharacters are:
 ¬ $ . * \( \) [ \{ \} \

but later in a table:
[^string]

Is it "^" or "¬"?  Some clarification is needed.  I'll submit an RCF.

I hate EBCDIC!

The ISPF Edit Macros manual says that  metacharacters in regular
expressions are interpreted according to the CCSID of the controlling
terminal, listing several dozen supported CCSIDs, and says that in
background IBM-1047 is presumed.  Is this also true if DFSORT is
invoked by TSO CALL?  If SYSIN is allocated to a UNIX file tagged
with a CCSID, does DFSORT respect that CCSID?

I hate EBCDIC!

Also, in a table:
The caret symbol, when inside square brackets,
negates the characters within the square brackets.
Thus [^abc], if compared to other strings, would fail
to match any that contains even one a, b, or c.

("when inside square brackets" seems to be a restrictive
clause.  It should not be enclosed in commas.)

The "^" must be the first character inside the brackets
to have this effect.

The last sentence beginning "Thus ..." is incorrect.

"[^abc]" matches any string containing a character
other than a, b, or c.  It matches "wombat".  However,
"^[^abc]*$" matches strings containing no character
other than a, b, or c.   It does not match "wombat".

Another RCF, or the same one?

The DFSORT manual (and others) should not attempt
to explain regular expressions.  They should defer to
citing a single publication with such an explanation.

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Mario Bezzi
Sri Hari, Max, all,

thank you very much from your kind help and support. 

I really appreciate it, and I hope to have the opportunity to reciprocate.

mario

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-31 Thread Andrew Rowley

On 31/08/2022 10:02 am, Paul Gilmartin wrote:

The DFSORT command syntax is dreadful -- too positional.  It's
hard to read ...,keyword,value,keyword,value,...
Considerably better would be ,keyword(value), or ,keyword=value,...


I'm not sure that it is that bad for defining a sort, but it does get 
complex when it is extended to do other tasks.


There seem to be various "tricks" used which work, but are not exactly 
intuitive.


Andrew Rowley
Black Hill Sofware

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Tom Brennan
It's not meant to be disrespectful, and the only joke is the elves.  The 
rest is reality as I see it.  Whether that's good or bad I guess depends 
on your point of view.


On 8/30/2022 10:19 PM, kekronbekron wrote:

Although this is a joke... some respect for Sri please.
Remember that he doesn't need to share anything.
We'll be the ones looking dumb with capable tools & not knowing how to properly 
use them.

- KB

--- Original Message ---
On Wednesday, August 31st, 2022 at 10:08 AM, Tom Brennan 
 wrote:



But with DFSORT I don't need to know the syntax at all. I can post a
note here describing what I'm trying to do along with some data samples,
and like the elves who make shoes, complete JCL and SYSIN will magically
appear the next morning.

On 8/30/2022 5:02 PM, Paul Gilmartin wrote:


The DFSORT command syntax is dreadful -- too positional. It's
hard to read ...,keyword,value,keyword,value,...
Considerably better would be ,keyword(value), or ,keyword=value,...
I suppose the design is OK to programmers versed in it, but it
repels the novice. It may be easy for a computer to parse,
but silicon is now cheaper than carbon.



--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread kekronbekron
Although this is a joke... some respect for Sri please.
Remember that he doesn't need to share anything.
We'll be the ones looking dumb with capable tools & not knowing how to properly 
use them.

- KB

--- Original Message ---
On Wednesday, August 31st, 2022 at 10:08 AM, Tom Brennan 
 wrote:


> But with DFSORT I don't need to know the syntax at all. I can post a
> note here describing what I'm trying to do along with some data samples,
> and like the elves who make shoes, complete JCL and SYSIN will magically
> appear the next morning.
> 
> On 8/30/2022 5:02 PM, Paul Gilmartin wrote:
> 
> > The DFSORT command syntax is dreadful -- too positional. It's
> > hard to read ...,keyword,value,keyword,value,...
> > Considerably better would be ,keyword(value), or ,keyword=value,...
> > I suppose the design is OK to programmers versed in it, but it
> > repels the novice. It may be easy for a computer to parse,
> > but silicon is now cheaper than carbon.
> 
> 
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Tom Brennan
But with DFSORT I don't need to know the syntax at all.  I can post a 
note here describing what I'm trying to do along with some data samples, 
and like the elves who make shoes, complete JCL and SYSIN will magically 
appear the next morning.


On 8/30/2022 5:02 PM, Paul Gilmartin wrote:


The DFSORT command syntax is dreadful -- too positional.  It's
hard to read ...,keyword,value,keyword,value,...
Considerably better would be ,keyword(value), or ,keyword=value,...
I suppose the design is OK to programmers versed in it, but it
repels the novice.  It may be easy for a computer to parse,
but silicon is now cheaper than carbon.


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Paul Gilmartin
On Wed, 31 Aug 2022 08:38:19 +1000, Andrew Rowley  wrote:
>
>If we're looking at alternatives, there's also Java. I can never
>understand what the DFSORT solutions are doing from reading the control
>cards, ...
>
+1
The DFSORT command syntax is dreadful -- too positional.  It's
hard to read ...,keyword,value,keyword,value,...
Considerably better would be ,keyword(value), or ,keyword=value,...
I suppose the design is OK to programmers versed in it, but it
repels the novice.  It may be easy for a computer to parse,
but silicon is now cheaper than carbon.

> ... and I'm sure I am not alone there. A programming language makes
>it much easier for the person who has to understand it in the future.
>
DFSORT is properly data driven, like some of my favorite UNIX utilities;
it's the correct design.

MVS, however, makes it unduly difficult to combine utilities.  DFSORT
has a transformation to upper case; UNIX sort needs none.  It's
easy enough to:
sort  | awk '{ print toupper() }'

No need to replicate such a function in every utility that might need it.

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Andrew Rowley

On 30/08/2022 10:46 pm, Bob Bridges wrote:

I usually keep my bigoted mouth shut in threads like this, but guys, why 
DFSORT?  That's great for the simple stuff, but REXX is so much easier and you 
don't have to sweat over more and more and yet more inventive solutions.


If we're looking at alternatives, there's also Java. I can never 
understand what the DFSORT solutions are doing from reading the control 
cards, and I'm sure I am not alone there. A programming language makes 
it much easier for the person who has to understand it in the future.


Java performance should be much better than Rexx if you have significant 
numbers of records. I wouldn't consider 5 million records a large 
number, unless they are particularly large records.


Andrew Rowley
Black Hill Software

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Paul Gilmartin
On Tue, 30 Aug 2022 12:55:19 -0500, Paul Gilmartin wrote:
>
>... (Does DFSORT support regular expressions?) ...
>
Yes.  I found it in the Ref.  With several pages specifying regular expression 
syntax
which would better be replaced by a citation of another document.

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Paul Gilmartin
On Tue, 30 Aug 2022 17:21:22 +, Sri h Kolusu wrote:
>
>≫ Little argument other than the economic balance between silicon and carbon, 
>counting learning in the latter.  How much data?
>
>Take a simple of ca e less than or equal to 5 Million records. You can run a 
>test and see for your self as to how much it takes to do the same using REXX 
>vs DFSORT.
> 
I wouldn't try to sort even a hundred records purely in REXX.  It's the wrong 
tool for that.


>>>... address LINKMVS DFSORT ...
>
>Aren't you invoking DFSORT from REXX?  I think you skipped reading the text in 
>BOLD
>
Which "text in BOLD"?  There are several instances.

> " Moreover you need to have the Data SORTED before you can calculate the 
> deltas and you need to invoke SORT or have a separate step to sort the data"
>
POSIX pipes support using multiple utilities in a single job step.  I've used 
Binder | sed.

>We can debate about it, but in the end, if someone asks for a DFSORT solution 
>and if it can be done using it, then I will try to post which would show case 
>the rich features available with the product.
> 
If Bob had asked the list for a way to sort a file using REXX, would you be 
slow to jump in
and offer DFSORT as a better alternative?

Some tasks require multiple tools.  What if someone asked for sorted output of 
all records
matching a given regular expression (Does DFSORT support regular expressions?)
I'd be inclined to pipe "sed" into DFSORT; I'd expect you to call regex in an 
input exit.
Both work.

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Sri h Kolusu


≫ Little argument other than the economic balance between silicon and carbon, 
counting learning in the latter.  How much data?

Paul,

Take a simple of case less than or equal to 5 Million records. You can run a 
test and see for your self as to how much it takes to do the same using REXX vs 
DFSORT.

>>... address LINKMVS DFSORT ...

Aren't you invoking DFSORT from REXX?  I think you skipped reading the text in 
BOLD

 " Moreover you need to have the Data SORTED before you can calculate the 
deltas and you need to invoke SORT or have a separate step to sort the data"

≫" ... everything looks like a nail."  (Yes, to Bob and me also.)

We can debate about it, but in the end, if someone asks for a DFSORT solution 
and if it can be done using it, then I will try to post which would show case 
the rich features available with the product.



Thanks,
Kolusu
DFSORT Development
IBM Corporation




--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Paul Gilmartin
On Tue, 30 Aug 2022 16:28:24 +, Sri h Kolusu wrote:

>>> I usually keep my bigoted mouth shut in threads like this, but guys, why 
>>> DFSORT?  That's great for the simple stuff, but REXX is so much easier and 
>>> you don't have to sweat over more and more and yet more inventive solutions.
>
>Bob,
>
>Rexx is a handy tool, but it performs poorly against huge volumes of data.  
>
Little argument other than the economic balance between silicon and carbon, 
counting
learning in the latter.  How much data?

>Moreover you need to have the Data SORTED before you can calculate the deltas 
>and you need to invoke SORT or have a separate step to sort the data, as you 
>cannot load the entire file into a stem.
>
???  How about:
address syscall pipe P.
call BPXWDYN "alloc dd(SORTOUT) path('/dev/fd/"P.2"') ..."
... address LINKMVS DFSORT ...
/* Use LINEIN() to read from P.1 -- no stem; no separate step. */

>If you are sorting the data using SORT, why not calculate the delta there 
>itself?
>
" ... everything looks like a nail."  (Yes, to Bob and me also.)

-- 
gil

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Sri h Kolusu
>> I usually keep my bigoted mouth shut in threads like this, but guys, why 
>> DFSORT?  That's great for the simple stuff, but REXX is so much easier and 
>> you don't have to sweat over more and more and yet more inventive solutions.

Bob,

Rexx is a handy tool, but it performs poorly against huge volumes of data.  
Moreover you need to have the Data SORTED before you can calculate the deltas 
and you need to invoke SORT or have a separate step to sort the data, as you 
cannot load the entire file into a stem.

If you are sorting the data using SORT, why not calculate the delta there 
itself?


Thanks,
Kolusu

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Michael Babcock
Don’t have an answer, just a question.  Do you need to allow for the
quantity to go up?  Say additional inventory was added and went from say,
20 to 40, which may result in a negative number during subtraction?

On Tue, Aug 30, 2022 at 7:47 AM Bob Bridges  wrote:

> I usually keep my bigoted mouth shut in threads like this, but guys, why
> DFSORT?  That's great for the simple stuff, but REXX is so much easier and
> you don't have to sweat over more and more and yet more inventive solutions.
>
> ---
> Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313
>
> /* It is a settled policy of America, that as peace is better than war,
> war is better than tribute. The United States, while they wish for war with
> no nation, will buy peace with none.  -James Madison, upon the conclusion
> of a US war against Barbary piracy (in the person of the Dey of Algiers,
> Omar Pasha) in 1815 */
>
> -Original Message-
> From: IBM Mainframe Discussion List  On Behalf
> Of Massimo Biancucci
> Sent: Tuesday, August 30, 2022 07:09
>
> I first tried with WHEN=GROUP but with no success.
>
> After that I hopefully succeeded with a JOIN.
> The main idea is to extract keys from file and number those simply by
> sequential number.
> So the STAMPA "view" at ST010 should show something like this:
>
> SUGAR100   01
> SUGAR9702
> SUGAR9303
> X2004
> Y150   05
> Y140   06
>
> then try to JOIN every key with the relative (+1) of the original file.
> So SUGAR-02 of the original file must match with SUGAR-01 of the
> keys subset.
> This has been done with the JNF2CNTL ADD statement.
>
> The final sample output is:
>
>
> +1+2+3+4+5+6+7+8+9+0+1+2
> SUGAR,2022/08/01,100  01
>   1  00
> SUGAR,2022/08/02,97   02SUGAR100
> 02B  03
> SUGAR,2022/08/03,93   03SUGAR97
>  03B  04
> X,2022/08/03,20   04SUGAR93
>  04B  00
> Y,2022/08/01,150  05X20
>  05B  00
> Y,2022/08/01,140  06Y150
> 06B  10
>
> where first piece (1-56) is the original record, the second piece (57-80)
> is the trace of the JOIN process and last column (81:86) is the result you
> need.
> Double check if the idea is effective.
>
> //*---*
> //* EXTRACT KEYS AND SEQNUM FROM ORIGINAL FILE*
> //* FILE SHOULD BE ORDERED BY PRODUCT AND DATE.   *
> //*---*
> //ST010   EXEC PGM=SORT
> //SYSOUT  DD SYSOUT=*
> //SORTOUT DD DSN=,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
> //STAMPA  DD SYSOUT=*
> //SORTIN  DD *
> SUGAR,2022/08/01,100
> SUGAR,2022/08/02,97
> SUGAR,2022/08/03,93
> X,2022/08/03,20
> Y,2022/08/01,150
> Y,2022/08/01,140
> /*
> //SYSIN  DD *
>  SORT FIELDS=(1,5,A,7,10,A),FORMAT=BI
>  OUTFIL FNAMES=SORTOUT,
>   OUTREC=(1,5,18,10,SEQNUM,6,ZD)
>  OUTFIL FNAMES=STAMPA,
>   OUTREC=(1,5,18,10,SEQNUM,6,ZD)
> /*
> //*---*
> //* JOIN WITH ORIGINAL FILE ON SEQNUM + 1 *
> //*---*
> //ST020   EXEC PGM=SORT
> //SYSOUT  DD SYSOUT=*
> //SORTOUT DD SYSOUT=*
> //F1  DD *
> SUGAR,2022/08/01,100
> SUGAR,2022/08/02,97
> SUGAR,2022/08/03,93
> X,2022/08/03,20
> Y,2022/08/01,150
> Y,2022/08/01,140
> /*
> //JNF1CNTL DD *
>  INREC FIELDS=(1,50,SEQNUM,6,ZD)
> /*
> //F2  DD DSN=,DISP=(OLD,DELETE)
> //JNF2CNTL DD *
>  INREC FIELDS=(1,15,16,6,ZD,ADD,+1,TO=ZD,LENGTH=6)
> /*
> //SYSIN  DD *
>  JOINKEYS F1=F1,FIELDS=(51,6,A)
>  JOINKEYS F2=F2,FIELDS=(16,6,A)
>  JOIN UNPAIRED,F1
>  REFORMAT FIELDS=(F1:1,56,F2:1,21,?)
>  SORT FIELDS=COPY
>  OUTFIL FNAMES=SORTOUT,REMOVECC,
>   IFTHEN=(WHEN=(1,5,CH,EQ,56,5,CH),
>OVERLAY=(81:61,10,UFF,SUB,18,10,UFF,EDIT=(TT))),
>   IFTHEN=(WHEN=NONE,
>OVERLAY=(81:C'00'))
>
> --- Il giorno mar 30 ago 2022 alle ore 09:32 Mario Bezzi <
> subscriptions.mario.be...@gmail.com> ha scritto:
> > say I have a file with goods, dates, and available quantities, not
> > necessarily sorted. I want to sort it and calculate daily deltas.
> >
> > For example using the following input :
> >
> > Product,Date,Availability
> > Sugar,2022/08/01,100
> > Sugar,2022/08/02,97
> > Sugar,2022/08/03,93
> >
> > I need to get to this:
> >
> > Product,Date,Sold
> > Sugar,2022/08/01,N/A  (No daily delta for the first record)
> > Sugar,2022/08/02,3(100 - 97)
> > Sugar,2022/08/03,4(97 - 93)
> >
> > May I use bultin DFSORT functions to calculate deltas from the
> > previous record and the current one?
> >
> > I had a look 

Re: Calculate deltas using DFSORT

2022-08-30 Thread Sri h Kolusu
Mario,

Max has the right idea but it is a overkill with 2 passes of data.  Here is a 
simpler version with just 1 pass.   Since the data is NOT sorted, I added a 
SORT statement.

I assumed that the product has a length of 5 bytes and starts in position 1. I 
also added lot of comments so that it is easy to understand the job.

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
ABCDE,2022/07/02,140
ABCDE,2022/07/03,120
//SORTOUT  DD SYSOUT=*
//SYSINDD *
  SORT FIELDS=(01,16,CH,A),EQUALS

** Tag records based on the key with a sequence number
  OUTREC IFOUTLEN=80,
 IFTHEN=(WHEN=GROUP,KEYBEGIN=(01,5),
 PUSH=(081:SEQ=5)),

** If sequence is even then push the availability to odd number
** record at position 087, so that is easy to calculate delta
 IFTHEN=(WHEN=GROUP,
BEGIN=(085,1,BI,EQ,B'...1'),
 PUSH=(087:018,03)),

** If sequence is even then push the availability to odd number
** record at position 091, so that is easy to calculate delta
 IFTHEN=(WHEN=GROUP,
BEGIN=(085,1,BI,EQ,B'...0'),
 PUSH=(091:018,03)),

** once again check the sequence for odd and calculate the
** delta of availability at position 22
 IFTHEN=(WHEN=(085,1,BI,EQ,B'...1'),
  OVERLAY=(22:091,03,UFF,SUB,
  018,03,UFF,M10,LENGTH=3),
  HIT=NEXT),

** For the first record the delta is not applicable, so hardcode
** the value of N/A as delta for it
 IFTHEN=(WHEN=(081,5,ZD,EQ,1),
  OVERLAY=(22:C'N/A')),

** once again check the sequence for even and calculate the
** delta of availability at position 22
 IFTHEN=(WHEN=(085,1,BI,EQ,B'...0'),
  OVERLAY=(22:087,03,UFF,SUB,
  018,03,UFF,M10,LENGTH=3))
/*


The output from this job is

ABCDE,2022/07/02,140 N/A
ABCDE,2022/07/03,120  20
SUGAR,2022/08/01,100 N/A
SUGAR,2022/08/02,973
SUGAR,2022/08/03,934
X,2022/08/03,20  N/A
Y,2022/08/01,150 N/A
Y,2022/08/01,140  10

Further if you have any questions, please let me know

Thanks,
Kolusu
DFSORT Development
IBM Corporation


-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Mario Bezzi
Sent: Tuesday, August 30, 2022 12:32 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: [EXTERNAL] Calculate deltas using DFSORT

Hello list,

say I have a file with goods, dates, and available quantities, not necessarily 
sorted. I want to sort it and calculate daily deltas.

For example using the following input :

Product,Date,Availability
Sugar,2022/08/01,100
Sugar,2022/08/02,97
Sugar,2022/08/03,93

I need to get to this:

Product,Date,Sold
Sugar,2022/08/01,N/A  (No daily delta for the first record)
Sugar,2022/08/02,3(100 - 97)
Sugar,2022/08/03,4(97 - 93)

May I use bultin DFSORT functions to calculate deltas from the previous record 
and the current one?

I had a look at the OUTREC statement in the Application Programming Manual, but 
as far as I can see arithmetic expressions can only use input fields from the 
current record or decimal constants.

It believe I can achieve the above result using an E35 exit, just wanted to be 
sure that's the only way.

Thanks!
mario

--
For IBM-MAIN subscribe / signoff / archive access instructions, send email to 
lists...@listserv.ua.edu with the message: 
INFO IBM-MAIN


--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Seymour J Metz
REXX is certain ly easy, but if the OP has large volumes of data then 
performance may be an isswue.


--
Shmuel (Seymour J.) Metz
http://mason.gmu.edu/~smetz3


From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of Bob 
Bridges [robhbrid...@gmail.com]
Sent: Tuesday, August 30, 2022 8:46 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Calculate deltas using DFSORT

I usually keep my bigoted mouth shut in threads like this, but guys, why 
DFSORT?  That's great for the simple stuff, but REXX is so much easier and you 
don't have to sweat over more and more and yet more inventive solutions.

---
Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313

/* It is a settled policy of America, that as peace is better than war, war is 
better than tribute. The United States, while they wish for war with no nation, 
will buy peace with none.  -James Madison, upon the conclusion of a US war 
against Barbary piracy (in the person of the Dey of Algiers, Omar Pasha) in 
1815 */

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Massimo Biancucci
Sent: Tuesday, August 30, 2022 07:09

I first tried with WHEN=GROUP but with no success.

After that I hopefully succeeded with a JOIN.
The main idea is to extract keys from file and number those simply by 
sequential number.
So the STAMPA "view" at ST010 should show something like this:

SUGAR100   01
SUGAR9702
SUGAR9303
X2004
Y150   05
Y140   06

then try to JOIN every key with the relative (+1) of the original file.
So SUGAR-02 of the original file must match with SUGAR-01 of the keys 
subset.
This has been done with the JNF2CNTL ADD statement.

The final sample output is:

+1+2+3+4+5+6+7+8+9+0+1+2
SUGAR,2022/08/01,100  01
  1  00
SUGAR,2022/08/02,97   02SUGAR100
02B  03
SUGAR,2022/08/03,93   03SUGAR97
 03B  04
X,2022/08/03,20   04SUGAR93
 04B  00
Y,2022/08/01,150  05X20
 05B  00
Y,2022/08/01,140  06Y150
06B  10

where first piece (1-56) is the original record, the second piece (57-80) is 
the trace of the JOIN process and last column (81:86) is the result you need.
Double check if the idea is effective.

//*---*
//* EXTRACT KEYS AND SEQNUM FROM ORIGINAL FILE*
//* FILE SHOULD BE ORDERED BY PRODUCT AND DATE.   *
//*---*
//ST010   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD DSN=,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//STAMPA  DD SYSOUT=*
//SORTIN  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//SYSIN  DD *
 SORT FIELDS=(1,5,A,7,10,A),FORMAT=BI
 OUTFIL FNAMES=SORTOUT,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
 OUTFIL FNAMES=STAMPA,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
/*
//*---*
//* JOIN WITH ORIGINAL FILE ON SEQNUM + 1 *
//*---*
//ST020   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//F1  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//JNF1CNTL DD *
 INREC FIELDS=(1,50,SEQNUM,6,ZD)
/*
//F2  DD DSN=,DISP=(OLD,DELETE)
//JNF2CNTL DD *
 INREC FIELDS=(1,15,16,6,ZD,ADD,+1,TO=ZD,LENGTH=6)
/*
//SYSIN  DD *
 JOINKEYS F1=F1,FIELDS=(51,6,A)
 JOINKEYS F2=F2,FIELDS=(16,6,A)
 JOIN UNPAIRED,F1
 REFORMAT FIELDS=(F1:1,56,F2:1,21,?)
 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTOUT,REMOVECC,
  IFTHEN=(WHEN=(1,5,CH,EQ,56,5,CH),
   OVERLAY=(81:61,10,UFF,SUB,18,10,UFF,EDIT=(TT))),
  IFTHEN=(WHEN=NONE,
   OVERLAY=(81:C'00'))

--- Il giorno mar 30 ago 2022 alle ore 09:32 Mario Bezzi < 
subscriptions.mario.be...@gmail.com> ha scritto:
> say I have a file with goods, dates, and available quantities, not
> necessarily sorted. I want to sort it and calculate daily deltas.
>
> For example using the following input :
>
> Product,Date,Availability
> Sugar,2022/08/01,100
> Sugar,2022/08/02,97
> Sugar,2022/08/03,93
>
> I need to get to this:
>
> Product,Date,Sold
> Sugar,2022/08/01,N/A  (No daily delta for the first record)
> Sugar,2022/08/02,3(100 - 97)
> Sugar,2022/08/03,4(97 - 93)
>
> May I use bultin DFSORT functions to calculate deltas from the
> previous record and the current one?
>
> I had a look at the OU

Re: Calculate deltas using DFSORT

2022-08-30 Thread Bob Bridges
I usually keep my bigoted mouth shut in threads like this, but guys, why 
DFSORT?  That's great for the simple stuff, but REXX is so much easier and you 
don't have to sweat over more and more and yet more inventive solutions.

---
Bob Bridges, robhbrid...@gmail.com, cell 336 382-7313

/* It is a settled policy of America, that as peace is better than war, war is 
better than tribute. The United States, while they wish for war with no nation, 
will buy peace with none.  -James Madison, upon the conclusion of a US war 
against Barbary piracy (in the person of the Dey of Algiers, Omar Pasha) in 
1815 */

-Original Message-
From: IBM Mainframe Discussion List  On Behalf Of 
Massimo Biancucci
Sent: Tuesday, August 30, 2022 07:09

I first tried with WHEN=GROUP but with no success.

After that I hopefully succeeded with a JOIN.
The main idea is to extract keys from file and number those simply by 
sequential number.
So the STAMPA "view" at ST010 should show something like this:

SUGAR100   01
SUGAR9702
SUGAR9303
X2004
Y150   05
Y140   06

then try to JOIN every key with the relative (+1) of the original file.
So SUGAR-02 of the original file must match with SUGAR-01 of the keys 
subset.
This has been done with the JNF2CNTL ADD statement.

The final sample output is:

+1+2+3+4+5+6+7+8+9+0+1+2
SUGAR,2022/08/01,100  01
  1  00
SUGAR,2022/08/02,97   02SUGAR100
02B  03
SUGAR,2022/08/03,93   03SUGAR97
 03B  04
X,2022/08/03,20   04SUGAR93
 04B  00
Y,2022/08/01,150  05X20
 05B  00
Y,2022/08/01,140  06Y150
06B  10

where first piece (1-56) is the original record, the second piece (57-80) is 
the trace of the JOIN process and last column (81:86) is the result you need.
Double check if the idea is effective.

//*---*
//* EXTRACT KEYS AND SEQNUM FROM ORIGINAL FILE*
//* FILE SHOULD BE ORDERED BY PRODUCT AND DATE.   *
//*---*
//ST010   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD DSN=,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//STAMPA  DD SYSOUT=*
//SORTIN  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//SYSIN  DD *
 SORT FIELDS=(1,5,A,7,10,A),FORMAT=BI
 OUTFIL FNAMES=SORTOUT,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
 OUTFIL FNAMES=STAMPA,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
/*
//*---*
//* JOIN WITH ORIGINAL FILE ON SEQNUM + 1 *
//*---*
//ST020   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//F1  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//JNF1CNTL DD *
 INREC FIELDS=(1,50,SEQNUM,6,ZD)
/*
//F2  DD DSN=,DISP=(OLD,DELETE)
//JNF2CNTL DD *
 INREC FIELDS=(1,15,16,6,ZD,ADD,+1,TO=ZD,LENGTH=6)
/*
//SYSIN  DD *
 JOINKEYS F1=F1,FIELDS=(51,6,A)
 JOINKEYS F2=F2,FIELDS=(16,6,A)
 JOIN UNPAIRED,F1
 REFORMAT FIELDS=(F1:1,56,F2:1,21,?)
 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTOUT,REMOVECC,
  IFTHEN=(WHEN=(1,5,CH,EQ,56,5,CH),
   OVERLAY=(81:61,10,UFF,SUB,18,10,UFF,EDIT=(TT))),
  IFTHEN=(WHEN=NONE,
   OVERLAY=(81:C'00'))

--- Il giorno mar 30 ago 2022 alle ore 09:32 Mario Bezzi < 
subscriptions.mario.be...@gmail.com> ha scritto:
> say I have a file with goods, dates, and available quantities, not 
> necessarily sorted. I want to sort it and calculate daily deltas.
>
> For example using the following input :
>
> Product,Date,Availability
> Sugar,2022/08/01,100
> Sugar,2022/08/02,97
> Sugar,2022/08/03,93
>
> I need to get to this:
>
> Product,Date,Sold
> Sugar,2022/08/01,N/A  (No daily delta for the first record)
> Sugar,2022/08/02,3(100 - 97)
> Sugar,2022/08/03,4(97 - 93)
>
> May I use bultin DFSORT functions to calculate deltas from the 
> previous record and the current one?
>
> I had a look at the OUTREC statement in the Application Programming 
> Manual, but as far as I can see arithmetic expressions can only use 
> input fields from the current record or decimal constants.
>
> It believe I can achieve the above result using an E35 exit, just 
> wanted to be sure that's the only way.

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN


Re: Calculate deltas using DFSORT

2022-08-30 Thread Massimo Biancucci
Mario,

I first tried with WHEN=GROUP but with no success.

After that I hopefully succeeded with a JOIN.
The main idea is to extract keys from file and number those simply by
sequential number.
So the STAMPA "view" at ST010 should show something like this:

SUGAR100   01
SUGAR9702
SUGAR9303
X2004
Y150   05
Y140   06

then try to JOIN every key with the relative (+1) of the original file.
So SUGAR-02 of the original file must match with SUGAR-01 of the
keys subset.
This has been done with the JNF2CNTL ADD statement.

The final sample output is:

+1+2+3+4+5+6+7+8+9+0+1+2
SUGAR,2022/08/01,100  01
  1  00
SUGAR,2022/08/02,97   02SUGAR100
02B  03
SUGAR,2022/08/03,93   03SUGAR97
 03B  04
X,2022/08/03,20   04SUGAR93
 04B  00
Y,2022/08/01,150  05X20
 05B  00
Y,2022/08/01,140  06Y150
06B  10

where first piece (1-56) is the original record, the second piece (57-80)
is the trace of the JOIN process and last column (81:86) is the result you
need.
Double check if the idea is effective.

//*---*
//* EXTRACT KEYS AND SEQNUM FROM ORIGINAL FILE*
//* FILE SHOULD BE ORDERED BY PRODUCT AND DATE.   *
//*---*
//ST010   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD DSN=,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//STAMPA  DD SYSOUT=*
//SORTIN  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//SYSIN  DD *
 SORT FIELDS=(1,5,A,7,10,A),FORMAT=BI
 OUTFIL FNAMES=SORTOUT,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
 OUTFIL FNAMES=STAMPA,
  OUTREC=(1,5,18,10,SEQNUM,6,ZD)
/*
//*---*
//* JOIN WITH ORIGINAL FILE ON SEQNUM + 1 *
//*---*
//ST020   EXEC PGM=SORT
//SYSOUT  DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//F1  DD *
SUGAR,2022/08/01,100
SUGAR,2022/08/02,97
SUGAR,2022/08/03,93
X,2022/08/03,20
Y,2022/08/01,150
Y,2022/08/01,140
/*
//JNF1CNTL DD *
 INREC FIELDS=(1,50,SEQNUM,6,ZD)
/*
//F2  DD DSN=,DISP=(OLD,DELETE)
//JNF2CNTL DD *
 INREC FIELDS=(1,15,16,6,ZD,ADD,+1,TO=ZD,LENGTH=6)
/*
//SYSIN  DD *
 JOINKEYS F1=F1,FIELDS=(51,6,A)
 JOINKEYS F2=F2,FIELDS=(16,6,A)
 JOIN UNPAIRED,F1
 REFORMAT FIELDS=(F1:1,56,F2:1,21,?)
 SORT FIELDS=COPY
 OUTFIL FNAMES=SORTOUT,REMOVECC,
  IFTHEN=(WHEN=(1,5,CH,EQ,56,5,CH),
   OVERLAY=(81:61,10,UFF,SUB,18,10,UFF,EDIT=(TT))),
  IFTHEN=(WHEN=NONE,
   OVERLAY=(81:C'00'))
/*

Best regards.
Max

Il giorno mar 30 ago 2022 alle ore 09:32 Mario Bezzi <
subscriptions.mario.be...@gmail.com> ha scritto:

> Hello list,
>
> say I have a file with goods, dates, and available quantities, not
> necessarily sorted. I want to sort it and calculate daily deltas.
>
> For example using the following input :
>
> Product,Date,Availability
> Sugar,2022/08/01,100
> Sugar,2022/08/02,97
> Sugar,2022/08/03,93
>
> I need to get to this:
>
> Product,Date,Sold
> Sugar,2022/08/01,N/A  (No daily delta for the first record)
> Sugar,2022/08/02,3(100 - 97)
> Sugar,2022/08/03,4(97 - 93)
>
> May I use bultin DFSORT functions to calculate deltas from the previous
> record and the current one?
>
> I had a look at the OUTREC statement in the Application Programming
> Manual, but as far as I can see arithmetic expressions can only use input
> fields from the current record or decimal constants.
>
> It believe I can achieve the above result using an E35 exit, just wanted
> to be sure that's the only way.
>
> Thanks!
> mario
>
> --
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

--
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN