IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can it be done by DFSORT?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sandy0407

New User


Joined: 01 Aug 2010
Posts: 7
Location: Morley

PostPosted: Sat Aug 28, 2010 3:20 am
Reply with quote

Hi, I have the following requirement. They key is single byte, the tran codes are (3050, 100, 2050, etc), the values are 100, 200 etc as shown below.

The output is required to have the following:

1. Key
2. Prev Bill Value (Second last tran type 100)
3. Curr Billl Value (last tran type 100)
4.Addition of values for tran codes 2050 between the 2 bills (for example key 1 as shown below)

If prev bill value is not present (for example, key 2 as shown below), then the output should show the following:

1. Key
2. Prev Bill Value as 0
3. Curr Bill Value (last tran type 100)
4. sum of values for tran codes 2050 before curr bill (last tran type 100)

If there is no curr and prev bill, then all other values for the key should be zeros (for example key 3 as shown below)

the input and output is as shown in the attachment.
attachment inlined and deleted


Code:

Input File:

Key           Tran Code            Value
-----       -------------         --------
1              3050                100
1               100                200<--- Prev to Prev bill value
1              2050                600
1               100                150 < ---- Prev Bill Value
1              2050                100
1              2050                150
1              2050                100
1               100                500 <---- Current Bill Value
1              2050                200
2              2050                100
2              2050                100
2               100                700 <------- Curr Bill value
3              2050                100

I want output in the following way:

Key       Prev Bill Value       Current Bill Value           Sum of Transactions
-----    ------------------     --------------------        -------------------------
1           150                     500                           350 (sum of txn btn pre n cur)
2             0                     700                           200 (since inception till curr)
3             0                       0                             0
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Aug 28, 2010 3:23 am
Reply with quote

Hello,

You need to practice using the Code tag and Preview so your post are more readable. . .

The dupicate in your other topic has been removed.
Back to top
View user's profile Send private message
sandy0407

New User


Joined: 01 Aug 2010
Posts: 7
Location: Morley

PostPosted: Sat Aug 28, 2010 3:32 am
Reply with quote

Thanks Dick for showing the way to format the post.
Hope I am able to explain it clearly now.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Aug 28, 2010 4:20 am
Reply with quote

Sandy,

The downloaded file is all jumbled together when I look at it so I can't tell what your input and output looks like.

Please post inline text using the code tags.

Please 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. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Aug 28, 2010 4:25 am
Reply with quote

Quote:
Thanks Dick for showing the way to format the post.
You're welcome icon_smile.gif

Also, several of our contributors cannot download attachments due to security restrictions.

When showing code, jcl, data, or anything else from a "3270 screen" using copy/paste and the Code tag works very well. Just make sure you Preview so you can see your post as it will appear to the forum rather than how it looks in the Reply Editor. If you copy/paste from the 3270, the alignment will automatically be preserved.

A good time for a first-run would be when providing the info Frank requested icon_wink.gif
Back to top
View user's profile Send private message
sandy0407

New User


Joined: 01 Aug 2010
Posts: 7
Location: Morley

PostPosted: Sat Aug 28, 2010 3:22 pm
Reply with quote

Hi Frank,

The input file is of the following description:

1. Key - X(1)
2. Tran Code - X(4)
3. Value - 9(5)

A value of 0100 in Tran code field implies the bill generated.

The input file is as shown below:

Code:
1305000100
1010000200 <--- Prev to Prev bill value for key 1
1205000600
1010000150 < ---- Prev Bill Value for key 1
1205000100
1205000150
1205000100
1010000500 <---- Current Bill Value for key 1
1205000200
2215100700
2205000100
2205000100
2010000700 <------- Curr Bill value for key 2
3205000100
"Code'd"

The output is required to have the following:

1. Key - x(1)
2. Prev Bill Value - 9(5)
3. Current Bill value - 9(5)
4. Sum of values for tran type 2050 between prev and current bill - 9(5)

The output is to be driven by the following rules:

1. If a key has got previous and current bill (tran code 0100), then report the prev bill value, current bill value and sum of transactions between prev and current bill value for tran type 2050

Thus for key 1,
the current bill is of value 500 as marked above
the prev bill is of value 150 as marked above
there are 3 trans ( 2050 tran code) between the prev and current bill, the sum of values is 350.


2. If a key has only got current bill, then report the prev bill as 0, current bill and sum of transactions that have occured prior to generating current bill.

Thus for key 2,

The current bill is of value 700 as marked
the prev bill is not present for key 2
the sum of tran prior to generating the current bill is 200 (for tran code 2050)

3. If no prev and currrent bill is present, then report all values for that particular key as zeros.

The output is as shown below:

1001500050000350
2000000070000200
3000000000000000
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Aug 31, 2010 4:30 am
Reply with quote

sandy0407,

Try this DFSORT JCL which will give you the desired results. I think I covered most of the scenarios , but let me know if I missed any.


Code:

//STEP0100 EXEC PGM=SORT   
//SYSOUT   DD SYSOUT=*     
//SORTIN   DD DSN=Your input 10 byte FB file,DISP=SHR
//SORTOUT  DD SYSOUT=*                                           
//SYSIN    DD *                                                   
  INCLUDE COND=(2,4,SS,EQ,C'0100,2050')                           
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(30:5C'0')),                   
  IFTHEN=(WHEN=GROUP,BEGIN=(2,4,CH,EQ,C'0100'),PUSH=(12:ID=8)),   
  IFTHEN=(WHEN=(2,4,CH,EQ,C'0100'),                               
  OVERLAY=(21:SEQNUM,8,ZD,RESTART=(1,1)),HIT=NEXT),               
  IFTHEN=(WHEN=(28,1,SS,EQ,C'0,2,4,6,8'),                         
  OVERLAY=(12:12,8,ZD,SUB,+1,M11,LENGTH=8,30:6,5,6:5C'0'))   

   
  SORT FIELDS=(12,8,CH,A,1,5,CH,A),EQUALS                         
  SUM FIELDS=(6,5,ZD,30,5,ZD)                                     
                                                                 
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(21,8,CH,GT,C' '),             
           PUSH=(21:21,8,30:30,5)),                               
  IFTHEN=(WHEN=GROUP,BEGIN=(2,4,CH,EQ,C'2050'),                   
           PUSH=(36:6,5)),                                       
  IFTHEN=(WHEN=(2,4,CH,EQ,C'2050'),                               
  OVERLAY=(6:5C'0',30:5C'0',36:5C'0'))                           
                                                                 
  OUTFIL OMIT=(21,8,CH,GE,12,8,CH,AND,2,4,CH,EQ,C'2050'),         
  REMOVECC,NODETAIL,SECTIONS=(1,1,                               
  TRAILER3=(1,1,                                                 
            MAX=(30,5,ZD,M11,LENGTH=5),                           
            6,5,                                                 
            MAX=(36,5,ZD,M11,LENGTH=5)))                         
//*
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts DFsort help with SUM() DFSORT/ICETOOL 12
No new posts DFSORT - VB file RDW getting overridden DFSORT/ICETOOL 3
Search our Forums:

Back to Top