Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Monday, December 13, 2010

OOPS:2.4 Use of EXPORT and CHANGING parameters of a method

REPORT YSUBDEL .

DATA : w_tax type p decimals 2 ,
w_salary type p decimals 2 .

CLASS CTAX DEFINITION.
PUBLIC SECTION.
METHODS : TAX_CALC IMPORTING grade TYPE C
EXPORTING itax TYPE P
CHANGING salary TYPE P .
ENDCLASS.

CLASS CTAX IMPLEMENTATION.
METHOD : TAX_CALC.
CASE grade.
WHEN 'A01'.
itax = salary * '0.2'.
WHEN 'A02'.
itax = salary * '0.1'.
WHEN OTHERS.
itax = salary * '0.15'.
ENDCASE.
salary = salary - itax.
ENDMETHOD.
ENDCLASS.


START-OF-SELECTION.
DATA : OREF1 TYPE REF TO CTAX.
CREATE OBJECT : OREF1.
w_salary = 30000.
w_tax = 0 .
write:/5 'Before method call, salary and tax are' ,
w_salary ,
w_tax .
CALL METHOD OREF1->TAX_CALC EXPORTING grade = 'A01'
IMPORTING itax = w_tax
CHANGING salary = w_salary.
write:/5 'After method call, salary and tax are' ,
w_salary ,
w_tax .


Output Before method call, salary and tax are 30,000.00 0.00
After method call, salary and tax are 24,000.00 6,000.00

No comments: