Skip to Content
author's profile photo Former Member
Former Member

Exporting and changing parameter

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 11, 2007 at 04:51 AM

    Hi,

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

    Regards,

    Sesh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 11, 2007 at 05:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.