Scenario :-
Three classes has been defined SAVING_ACCOUNT ( BANK SAVING
Perform Friends Operation For above example using Global Class.
Procedure :-
Step 1. Go To Tcode SE24 . Create Class For Account Holder . & Provide Display
Amount Method.
Step 2. Do Implementation in Methods & Save , Activate
Step 2. Create Class For Saving Account & Provide Account Holder Class name
in Friends.
Step 4. Provide Deposit ,Withdraw & Display Methods in Account Class . Keep
Visibility of Withdrawal amount is Private .
Step 5. Do Implementation For Each Methods.
Step 6. Go To Attributes .Provide Attributes For Deposit & Withdraw . & Save
and Activate.
Step 7. Create Class For Other Person & Provide Display amount Method.
Step 8. Do Implementation For Method . Check the Code It Will Give Error .
Error is because . other person Don't have permission to withdraw money from account due To ZCL_OTH Class is not friend of account class .Visibility of Withdrawal is Private .Now Comment display Withdrawal method . Save , Check & Activate
Step 9. Go To Account Class ( ZCL_ACH) . Execute Class
Step 10. Execute Method Display_ACC
Step 11. Create Program For Account Class & Execute .
Step 12 . Output.
Three classes has been defined SAVING_ACCOUNT ( BANK SAVING
ACCOUNT ), ACCOUNT_HOLDER (SAVING ACCOUNT OWNER) , OTHER_PERSON ( NON ACCOUNT HOLDER) .Both account holder & other person class inherit from Saving Account class. Saving Account Class Define itself friend of Account holder so This Will Allow Account Holder To Access Private data of Saving account Class .
Perform Friends Operation For above example using Global Class.
Procedure :-
Step 1. Go To Tcode SE24 . Create Class For Account Holder . & Provide Display
Amount Method.
Step 2. Do Implementation in Methods & Save , Activate
Step 2. Create Class For Saving Account & Provide Account Holder Class name
in Friends.
Step 4. Provide Deposit ,Withdraw & Display Methods in Account Class . Keep
Visibility of Withdrawal amount is Private .
Step 5. Do Implementation For Each Methods.
Step 6. Go To Attributes .Provide Attributes For Deposit & Withdraw . & Save
and Activate.
Step 7. Create Class For Other Person & Provide Display amount Method.
Step 8. Do Implementation For Method . Check the Code It Will Give Error .
Error is because . other person Don't have permission to withdraw money from account due To ZCL_OTH Class is not friend of account class .Visibility of Withdrawal is Private .Now Comment display Withdrawal method . Save , Check & Activate
Step 9. Go To Account Class ( ZCL_ACH) . Execute Class
Step 10. Execute Method Display_ACC
Step 11. Create Program For Account Class & Execute .
Step 12 . Output.
0 comments:
Post a Comment