Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting and changing parameter

Former Member
0 Kudos

Hi abapers,

I am working object oriented abap and i need a small example of ,how to use

export and changing parameter of a method.

Can anyone help me regarding this

sanjay

2 REPLIES 2

0 Kudos

Hi,

Check standard program <b>demo_abap_objects_methods</b>.

Regards,

Sesh

Former Member
0 Kudos

See the below code. Hope it will be helpful.

<code>

REPORT zexp1 .

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 .

</code>

The program contains a method TAX_CALC belonging to the class CTAX. It receives GRADE as IMPORTING parameter and SALARY as CHANGING parameter. Based on the grade, the EXPORTING parameter ITAX is calculated and the CHANGING parameter , SALARY is modified by deducting tax from it.

reward if you find it helpful.

Thanks & Regards,

Rajesh