Ads

Showing posts with label Career ABAP-OOP Steps. Show all posts
Showing posts with label Career ABAP-OOP Steps. Show all posts

Wednesday, November 18, 2009

Object oriented programming (OOP) IX

Step-by-step
approach with screen-shots



Write the required code.



Similarly for SET_BALANCE





Object oriented programming (OOP) VIII

Step-by-step
approach with screen-shots




Now we IMPLEMENT the 3 methods.


Double click the method
DEPOSIT.




Object oriented programming (OOP) VII

Step-by-step
approach with screen-shots

We can see

the attributes and methods by pressing “Display object list” button on top.







Object oriented programming (OOP) VI

Step-by-step
approach with screen-shots



For withdraw we define an exception.



Object oriented programming (OOP) V

Step-by-step
approach with screen-shots


And WITHDRAW





Object oriented programming (OOP) IV

Step-by-step
approach with screen-shots


Write the parameters imported / exported for DEPOSIT method.


Similarly for SET_BALANCE



Object oriented programming (OOP) III

Step-by-step
approach with screen-shots


Place the mouse cursor in DEPOSIT and hit the Parameters button.


Object oriented programming (OOP) II

Step-by-step approach with screen-shots


Define 3 methods


DEPOSIT,

SET_BALANCE

and

WITHDRAW.





Object oriented programming (OOP) XVII

Step-by-step

approach with screen-shots






We get an exception.

Given below is an example code for using the global class we defined.

REPORT ZGB_OOPS_BANK .

DATA: acct1 type ref to zaccountaa.

DATA: bal type i.

create object: acct1.

selection-screen begin of block a.
parameters: p_amnt type dmbtr,
p_dpst type dmbtr,
p_wdrw type dmbtr.

selection-screen end of block a.

start-of-selection.


call method acct1->set_balance( p_amnt ).
write:/ 'Set balance to ', p_amnt.


bal = acct1->deposit( p_dpst ).
write:/ 'Deposited ', p_dpst ,' bucks making balance to ', bal.


bal = acct1->withdraw( p_wdrw ).
write:/ 'Withdrew ', p_wdrw ,' bucks making balance to ', bal.


This is the output.





Object oriented programming (OOP) XVI

Step-by-step

approach with screen-shots





Now the BALANCE is 2000



Lets try withdrawing 3000 now.





Object oriented programming (OOP) XV

Step-by-step

approach with screen-shots




Now let’s WITHDRAW 4000







Object oriented programming (OOP) XIV

Step-by-step

approach with screen-shots




We see the return Values now.





Object oriented programming (OOP) XIII

Step-by-step

approach with screen-shots



We come back to Initial Screen.



Now click DEPOSIT.








Object oriented programming (OOP) XII

Step-by-step

approach with screen-shots




Click SET_BALANCE.


Write the NEW_BALANCE and


Press ENTER.





Object oriented programming (OOP) XI

Step-by-step

approach with screen-shots



Now we are almost done creating the object.


Press CTRL + F3 to activate or hit the Matchstick.


We will see this in the status


Now we are done building the global class we can test it.


Press F8.







Object oriented programming (OOP) X

Step-by-step

approach with screen-shots


Write the required code.



Similarly for
WITHDRAW.


Blog Archive