2007 Aug 15 10:38 PM
Hi,
I am doing a project and i ahve to submit it in next week so plese help me in coading.
The name of the database table is Zcra_trans
it consits 7 fields and they are
ZTRANS_NUMBER
TRANS_AMT
TRANS_TYPE
CURRENCY
ACC_NO
ACC_HOLDER_NAME
SSN_NUM
this table refers to transactions for a particular account in a bank.
ZTRANS_NUMBER is transaction number , ACC_NO is Account Number and TRANS_AMT is the transaction amount (This field is numeric) and TRANS_TYPE is transaction type that is Deposit or withdrawal.
Example records in the Zcra_trans table.
00001 1000 DEPOSIT USD 00123456 Michel 00sf451225
00002 500 withdrawl USD 00123456 Michel 00sf451225
00003 2000 DEPOSIT USD 00123456 Michel 00sf451225
00004 800 withdrawl USD 00123456 Michel 00sf451225
For example account number 00123456 has made the above 4 transactions.
This table that is ZCRA_TRANS consits of many transactions of diffrent account holders with unique a account number.
Please writea report to caluculate total amount (TRANS_AMT) deposited and total amount withdrawn by a particular account number 00123456.
Title was edited by:
Alvaro Tejada Galindo
Hi,
I am doing a project and i ahve to submit it in next week so plese help me in coading.
The name of the database table is Zcra_trans
it consits 7 fields and they are
ZTRANS_NUMBER
TRANS_AMT
TRANS_TYPE
CURRENCY
ACC_NO
ACC_HOLDER_NAME
SSN_NUM
this table refers to transactions for a particular account in a bank.
ZTRANS_NUMBER is transaction number , ACC_NO is Account Number and TRANS_AMT is the transaction amount (This field is numeric) and TRANS_TYPE is transaction type that is Deposit or withdrawal.
Example records in the Zcra_trans table.
00001 1000 DEPOSIT USD 00123456 Michel 00sf451225
00002 500 withdrawl USD 00123456 Michel 00sf451225
00003 2000 DEPOSIT USD 00123456 Michel 00sf451225
00004 800 withdrawl USD 00123456 Michel 00sf451225
For example account number 00123456 has made the above 4 transactions.
This table that is ZCRA_TRANS consits of many transactions of diffrent account holders with unique a account number.
Please writea report to caluculate total amount (TRANS_AMT) deposited and total amount withdrawn by a particular account number 00123456.
Title was edited by:
Alvaro Tejada Galindo
2007 Aug 15 10:51 PM
<b>URGENT</b> is not allowed on the forums...That's why I change the title of the post...
If you want help, post the code you have done so far...We're not here to do your job...We are here to help solve problems in already written codes...
Greetings,
Blag.
2007 Aug 15 10:55 PM
HI,
Data : itab like standard table of Zcra_trans with header line.
data : begin of finaltab occurs 0,
ACC_NO type zcra_trans-acc-no,
TRANS_AMT type zcra_trans-trans_amt,
TRANS_TYPE type zcra_tran-trans_type,
end of finaltab.
tables : zcra_trans.
select-options : s_acc for zcra_trans-ACC_NO.
start-of-selection.
select * from zcra_trans into table itab where acc_no in s_acc.
if sy-subrc eq 0.
sort itab by accno.
loop at itab.
finaltab-acc_no = itab-acc_no.
finaltab-trans_amt = itab-trans_amt.
finaltab-trans_type = itab-trans_type.
collect finaltab.
endloop.
endif.
end-of-selection.
<b>data : lv_deposit type zcra_trans-trans_amt</b>.
sort finaltab by acc_no trans_type.
if not finaltab[] is initial.
loop at finaltab .
at new acc_no.
lv_deposit = finaltab-trans_amt.
endat.
at end of acc_no.
read table itab with key acc_no = itab-acc_no.
write : / 'Account No' , finaltab-acc_no,
'Deposit ', lv_deposit,
'Withdrawl', finaltab-trans_amt,
'Name' , itab-name,
'ssn' , itab-ssn.
clear lv_deposit.
endat
endloop.
endif.
Thanks
mahesh
2007 Aug 15 11:23 PM
Hi Mahesh,
Thanks for helping but there is an error in the code at this statement.
lv_deposit = finaltab-trans_amt.
the error is lv_deposit and finaltab-trans_amt are not mutually convertable in a unicode praogram.
2007 Aug 16 2:00 AM
2007 Aug 16 2:52 AM
One suggestion - try to modulise and comment your code as you build it as it will make it easier to document and maintain (and debug)... so I've shuffled your code around here to show what I mean... obviously I can't tell if it will compile as I don't have your DB table defined, but hopefully it will encourage you in your work. Also, I've assumed you'll want to total by currency?...:
report zlocal_jc_demo_code1.
tables:
zcra_trans. "Bank account information
data:
gt_zcra_trans like standard table of zcra_trans. "g= global, t=t able
select-options:
s_acc for zcra_trans-acc_no.
start-of-selection.
perform get_data.
end-of-selection.
perform generate_report.
*---------------------------------------------------------------------*
* FORM GET_DATA
*---------------------------------------------------------------------*
form get_data.
*" visit the database for what we need
select * into table gt_zcra_trans
from zcra_trans
where acc_no in s_acc.
endform.
*---------------------------------------------------------------------*
* FORM GENERATE_REPORT
*---------------------------------------------------------------------*
form generate_report.
*" work on the data and display
data:
ls_zcra_trans like zcra_trans,
*" lt_account will get a discrete list of ACC_NO
begin of ls_account,
acc_no type zcra_trans-acc_no,
end of ls_account,
lt_account type standard table of ls_account occurs 10.
*" lt_total will get totals by ACC_NO + CURRENCY
begin of ls_total,
acc_no type zcra_trans-acc_no,
currency type zcra_trans-currency,
deposit type zcra_trans-trans_amt,
withdrawal type zcra_trans-trans_amt,
end of ls_total,
lt_total like ls_total occurs 10.
*" Is there anything to do?
if gt_zcra_trans[] is initial.
write: / 'There was no data matching your criteria'.
exit.
endif.
*" Get a list of ACC_NO, and generate totals
sort gt_zcra_trans by accno currency.
loop at gt_zcra_trans into ls_zcra_trans.
append ls_zcra_trans-acc_no to lt_account. "will remove dupes below
clear: ls_total.
ls_total-acc_no = ls_zcra_trans-acc_no.
ls_total-currency = ls_zcra_trans-currency.
*" RULE NEEDED: How are deposits and withdrawals distinguished?
*" if ls_zcra_trans-trans_type = 'D'. "what rule??
if ls_zcra_trans-trans_amt > 0. "what rule to follow??
ls_total-deposit = ls_zcra_trans-trans_amt.
else.
ls_total-withdrawal = ls_zcra_trans-trans_amt.
endif.
collect ls_total into lt_total.
endloop.
*" Make unique list of ACC_NO values
sort lt_account.
delete adjacent duplicates from lt_account.
*" Work through the list of accounts, producing a statement for each
format reset.
loop at lt_account into ls_account.
*" Write out the statement info
loop at lt_total into ls_total
where acc_no = ls_account-acc_no.
*" Get ACC_NO + CURRENCY description from gt_zcra_trans (yes?)
clear: ls_zcra_trans.
read table gt_zcra_trans into ls_zcra_trans
with key acc_no = ls_total-acc_no
currency = ls_total-currency.
*" Print result
format reset.
format color col_normal.
write: /
'Account No', ls_account-acc_no,
'Currency', ls_total-currency,
'Deposit', ls_total-deposit, "from collect
'Withdrawal', ls_total-withdrawal, "from collect
'Name', ls_zcra_trans-name, "from gt_zcra_trans
'SSN', ls_zcra_trans-ssn, "from gt_zcra_trans
at sy-linsz space.
format reset.
endloop. "lt_total
endloop. "lt_account
format reset.
uline.
endform.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |