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
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
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.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Quote:
Thanks Dick for showing the way to format the post.
You're welcome
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
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.