View previous topic :: View next topic
|
Author |
Message |
santhunaveen
New User
Joined: 22 Sep 2006 Posts: 33
|
|
|
|
My report format like,
acct code amount
151 101 5000
transaction 111 zs 1800 cr
transaction 121 ms 1900 dr
acct code amount
161 101 5000
transaction 131 zs 2000 cr
transaction 141 nn 2000 dr
.......above tells like...for acct 151...,2 transactions are present....and for acct 161..., 2 transactions are present....
cr means credit transaction and dr means debit transaction.
..........
Whenever the code differs I have to print summary...all transactions has to be printed...
transaction 111 zs 1800 cr
transaction 121 ms 1900 dr
transaction 131 zs 2000 cr
transaction 141 nn 2000 dr
...I tried to print by using occurs cluase like.....whenevr i'm printing main line same time i tried to move to temporary variables of transaction....like...
set index-var to 1
move var-111 to print-var-temp1(1)
move var-121 to print-var-temp1(1)
move var-131 to print-var-temp1(1)
move var-141 to print-var-temp1(1)
set index-var up by 1
and whenever the code differs i'm going to set index-var to 1 and tried t print tht print-var-temp1(1)..but it's not getting populated with 1 st occurence..it is pointing to last occurence.....can i know like how to print all above lines to below? |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
I assume that the each record containing the account info is followed by corresponding transaction records and the account no does not repeat itself.
Declare the table with occurence equal to suitable no of maximum transacton counts for an account.
Code: |
1. In a loop,
a) Read file record until eof
b)
IF it is account record
IF it is not first account record
/* PRINT TABLE */
Perform varying countvar from 1 by 1 until countvar > indexvar
print table-rec(countvar)
end-perform
end-if
initialize table
SET INDEXVAR TO 1
Else
/* it is a trans record */
move file-rec to table-rec(indexvar)
set indexvar up by 1
End-if
c) go to 1.a |
|
|
Back to top |
|
|
santhunaveen
New User
Joined: 22 Sep 2006 Posts: 33
|
|
|
|
I can't read the file again..that is the prob..according to standards i should not open file more than once in a program...whenver i need to print summary the control is at last record..i can't go back to first record...
when I tried to print first acct number and transactions...I'm saving tht values using index....and at the time of printing summary again setting tht index to 1 and tried to print..but it is ponting to last record not first record.... |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
In the above solution, file is opened only once before going into the loop.
Another thing, where and why are you using the index when you are moving all types of transaction records to print-var-temp1(1) . Are you sure you are loading the table correctly?
set index-var to 1
move var-111 to print-var-temp1(1)
move var-121 to print-var-temp1(1)
move var-131 to print-var-temp1(1)
move var-141 to print-var-temp1(1)
set index-var up by 1
If my assumptions are coorect, you should get what you want by implementing the pseudocode.
set index-var to 1
move var-111 to print-var-temp1(1)
move var-121 to print-var-temp1(1)
move var-131 to print-var-temp1(1)
move var-141 to print-var-temp1(1)
Thanks,
Ajay |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
Quote: |
whenver i need to print summary the control is at last record..i can't go back to first record... |
If you go thru my pseudocode, you will know that we are printing the transaction for the previous account no always.
Slight modification for the above pseudocode. Care has been taken to print the transactions for the last account no.
Code: |
First open the file.
1. In a loop,
a) Read file record until eof. At endoffile, goto step 1.D
b)
IF it is account record
IF it is not first account record
/* PRINT TABLE */
Perform varying countvar from 1 by 1 until countvar > indexvar - 1
print table-rec(countvar)
end-perform
end-if
initialize table
SET INDEXVAR TO 1
Else
/* it is a trans record */
move file-rec to table-rec(indexvar)
set indexvar up by 1
End-if
c) go to 1.a
d)
/* print the transaction records for the last account in file */
Perform varying countvar from 1 by 1 until countvar > indexvar - 1
print table-rec(countvar)
end-perform
e) close file |
On reading the first account record, I bypass that record and just go on to load the print table in the second and subsequent iteraton of the loop.
If there is only one account no, after the EOFile, we indexvar variable holds the no of transaction records + 1 for the first account. The perform loop in 1.D prints the transactions records and we close the file.
If there are more than 1 Account records, once we come across next account no, we print the previous transactions that we had stored in the table.
Thanks,
Ajay |
|
Back to top |
|
|
santhunaveen
New User
Joined: 22 Sep 2006 Posts: 33
|
|
|
|
I decalred table like,
01 WS-LOAN-TYPE-REC-VAR.
03 WS-LOAN-TYPE-REC OCCURS 999 TIMES
INDEXED BY X-LOAN-TY.
05 WS-TRAN-CODE-S1 PIC X(12) VALUE SPACES.
05 WS-TRAN-DESC-S1 PIC X(16) VALUE SPACES.
05 WS-AMOUNT-S1 PIC X(23) VALUE SPACES.
in loop,
set index-var to 1.
Perform section1.
section1.
MOVE TXN-CODE TO WS-TRAN-CODE. ==>this is when we print first time..
MOVE TXN-CODE TO WS-TRAN-CODE-S1(index-var). ==>this is for summary
MOVE RPT-DESC TO WS-TRAN-DESC.
MOVE RPT-DESC TO WS-TRAN-DESC-S1(index-var).
MOVE AMT TO WS-AMOUNT.
MOVE AMT TO WS-AMOUNT-S1(index-var).
set index-var up by 1
end-section1.
whenever i need to print summary(not eof i shd print summary..after changing some code)
Now the code is diff...I shd print summary
set index-var to 1
Perform section2.
section2.
MOVE WS-TRAN-CODE-S1(index-var) TO PRINT-VAR1.===>i had index to 1 above but still here it is displaying last record values not first record values
MOVE WS-TRAN-DESC-S1(index-var) TO PRINT-VAR2.
MOVE WS-AMOUNT-S1(index-var) TO PRINT-VAR3.
set index-var up by 1
end-section2. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
santhunaveen wrote: |
i had index to 1 above but still here it is displaying last record values not first record values |
If I understand, you "think/intended to" set the index to 1, right?
I hate to be the one to tell you this, but apparently you did not.....
Maybe it is a logic error or maybe it is a coding error...Stick a "DISPLAY "Setting the summary index to one" right after you do and see if it shows up....You could also display the index value in the summery paragraph.... |
|
Back to top |
|
|
|