SUM fields with IF statement?



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

SUM fields with IF statement?

Postby schneiderusa » Tue Aug 24, 2010 1:18 am

Hello,

Is it possible to add an IF statement or any other comand before SUM FIELDS.
Currenly I am adding below fields without any conditions. But I need to add condition to sum these filds only when (3,6,CH,A) not equal.

SORT FIELDS=(52,8,CH,A,3,6,CH,A,828,9,CH,A,362,6,CH,A,783,4,CH,A,
895,9,CH,A)
SUM FIELDS=(138,9,371,9,395,9,407,9,469,9,843,9,852,9,
861,9,870,9),FORMAT=PD

Thank you.
schneiderusa
 
Posts: 11
Joined: Tue Mar 23, 2010 11:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SUM fields with IF statement?

Postby Frank Yaeger » Tue Aug 24, 2010 1:36 am

Well, you can use INREC with IFTHEN before SORT and SUM. But it's not clear from your description what you want to do exactly or whether that will help.

Perhaps the sequence of DFSORT processing shown here will help:

http://publibz.boulder.ibm.com/cgi-bin/ ... FIGSTMTSEQ

If you need more specific help, give a better description of the rules for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field. It would also help if you'd show an example of the records in your input file (relevant fields only) and what you expect for output.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: SUM fields with IF statement?

Postby schneiderusa » Tue Aug 24, 2010 1:55 am

File is regular sequential and fixed format. LREC= 1000 and RECFM= FB

First 80 bytes look like this:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
DMCREDIT100820 10932485 03887100
DMCREDIT100820 10932485 03887100
DMDEBIT 100820 10932485 03887100

This is my current sort card.
SORT FIELDS=(52,8,CH,A,3,6,CH,A,828,9,CH,A,362,6,CH,A,783,4,CH,A,
895,9,CH,A)
SUM FIELDS=(138,9,371,9,395,9,407,9,469,9,843,9,852,9,
861,9,870,9),FORMAT=PD

New task is to SUM above fields only when one record is CREDIT and another is DEBIT.
schneiderusa
 
Posts: 11
Joined: Tue Mar 23, 2010 11:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SUM fields with IF statement?

Postby Frank Yaeger » Tue Aug 24, 2010 2:45 am

New task is to SUM above fields only when one record is CREDIT and another is DEBIT.


Huh? I don't see how the input example you gave relates to the fields you show or the very vague "rule" you stated. I see two records with CREDIT and one with DEBIT. What is the complete set of "rules" for "when one record is CREDIT and another is DEBIT". In the entire file? In a group of records (what is a group)? You need to do a much better job of explaining the rules for what you want to do before anyone can help you. A good example of input and expected output related to the rules and your SORT and SUM fields would help immensely.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: SUM fields with IF statement?

Postby schneiderusa » Tue Aug 24, 2010 7:07 pm

Sorry for the confusion.

Let’s try to simplify the input file.

Fld1 pic xx
Fld2 pic 99.
Fld3 pic 999.
Fld4 pic 99.

For example I need to sum Fld4 if values in fld3 are the same and values in fld1 are NOT the same.
schneiderusa
 
Posts: 11
Joined: Tue Mar 23, 2010 11:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SUM fields with IF statement?

Postby DieZ » Tue Aug 24, 2010 11:44 pm

if values in fld3 are the same
over how many records ? Or, just one record ?
values in fld1 are NOT the same.
over how many records ? Or, just one record ?

:roll:
DieZ
 
Posts: 15
Joined: Sat Aug 21, 2010 11:03 am
Has thanked: 0 time
Been thanked: 0 time

Re: SUM fields with IF statement?

Postby schneiderusa » Wed Aug 25, 2010 12:53 am

I think it could be many or 1 for both fields.

Can you give syntax for both scenarios? Thanks.
schneiderusa
 
Posts: 11
Joined: Tue Mar 23, 2010 11:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: SUM fields with IF statement?

Postby Frank Yaeger » Wed Aug 25, 2010 2:40 am

Still not clear what you want to do (to me anyway). If you want help:

For the various possible cases, show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the rules for getting from input to output.

If you can't explain clearly what you want, then it will be difficult for anyone to help you.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post