Monday, March 18, 2013

Exporting and Changing Parameter in a Method


In the following example we have three different kinds of parameters – importing, exporting & changing of the public method m_exp_chn. We mention the import parameter is the selection screen input parameter. We have declared two variables – v_exp & v_chn with values. Now we are calling the method with mentioning of exporting parameter – v_exp (0) & changing parameter – v_chn (1).

Inside the method m_exp_chn we have a DO – ENDDO loop for 10 times. It means the operation will continue for 10 times. Here we are multiplying the input with 1,2,3… 10 to have a table.

REPORT  zsr_test NO STANDARD PAGE HEADING.

DATA: v_exp TYPE i VALUE 0,
      v_chn TYPE i VALUE 1.
PARAMETER p_inp TYPE i.

*----------------------------------------------------------------------*
*       CLASS cl_exp_chn DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_exp_chn DEFINITION.
  PUBLIC SECTION.
    METHODS m_exp_chn IMPORTING i_inp TYPE i
                      EXPORTING e_exp TYPE i
                      CHANGING  c_chn TYPE i.
ENDCLASS.                    "cl_exp_chn DEFINITION

*----------------------------------------------------------------------*
*       CLASS cl_exp_chn IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_exp_chn IMPLEMENTATION.
  METHOD m_exp_chn.
    DO 10 TIMES.
      e_exp = i_inp * c_chn.
      WRITE: / i_inp, '*', c_chn, '=', e_exp.
      c_chn = c_chn + 1.
    ENDDO.
  ENDMETHOD.                    "m_exp_chn
ENDCLASS.                    "cl_exp_chn IMPLEMENTATION

START-OF-SELECTION.
  DATA obj TYPE REF TO cl_exp_chn.
  CREATE OBJECT obj.
  CALL METHOD obj->m_exp_chn
    EXPORTING
      i_inp = p_inp
    IMPORTING
      e_exp = v_exp
    CHANGING
      c_chn = v_chn.

Now at debugging level we see that e_exp & c_chn parameters change their values and at the same time the values of the variables v_exp & v_chn also change (The input parameter is 10).


The program generates the following output.

10 comments:

yektek training said...

nice post thanks for sharing from Swathi

siva sankar Sankar said...

excellent post thanks for sharing from Sankar

Bhavya Kumar said...

Best blog.Got to learn new things.Thanks for this Blog SAP Success Factors Training in Chennai

sanayamohit said...

SAP Success Factors Real Time Hands on Training in Chennai...

Don't always Depend on Training Institute Alone and so please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer over SAP Success Factors Means??? Please ready for an DEMO From the Trainer MR.Karthick
CONTACT:8122241286

Both Classroom/Online Training is Available!!!!!!

Unknown said...



Best SAP Success Factors Training Institute in Chennai
http://thecreatingexperts.com/sap-successfactors-training-in-chennai/
Best SAP MM Training in Chennai
http://thecreatingexperts.com/sap-mm-training-in-chennai/
Best SAP SD Training in Chennai
http://thecreatingexperts.com/sap-sd-training-in-chennai/
http://thecreatingexperts.com/sap-hr-training-in-chennai/
Best SAP FICO Training in Chennai
http://thecreatingexperts.com/sap-fico-training-in-chennai/
Best SAP ABAP Training in Chennai
http://thecreatingexperts.com/sap-abap-training-in-chennai/
Best SAP BASIS Training in Chennai
http://thecreatingexperts.com/sap-basis-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Keerthi Suresh said...

SAP Success Factors Real Time Hands on Training in Chennai…

Don’t always Depend on Training Institute alone.Please aware of Best Trainers too..

http://thecreatingexperts.com/sap-successfactors-training-in-chennai/

If You need a Best Trainer in SAP Success Factors??? Then be ready for a DEMO From the Trainer MR.Karthick
CONTACT:8122241286
http://thecreatingexperts.com/sap-mm-training-in-chennai/

Both Classroom/Online Training is Available!!!!!!

Anonymous said...

Very Nice explanation of all tutorials.
Thank you sir for sharing information.
All the Best Sir.

Rajendran Gunasekar said...

i have one doubt can u help me guys .

exporting will act as call by reference ,
import will act as call by value...

is it correct what i am saying

i am new to ooabap please help me

Rajendran Gunasekar said...

sir u can provide test also after completeing all object what u provided...i think it may helpful to all because they may know the how much they learnt ...this my suggestion

gilledashivani said...

Informative article. Thank you for sharing the great blog. You have done great explanation and visualization. Keep up the good work.
BEST SAP ABAP TRAINING IN HYDERABAD