‎2009 Jun 02 1:40 PM
Hi,
I have a requirement where in I have to do a set of tasks repeatedly in a method. Is it possible to write a perform within a method?
Is there any other alternate solution to this problem?
Thanks & Regards,
Rahul
‎2009 Jun 02 1:45 PM
Just create a new method for your task and call it repeatedly.
Michael
‎2009 Jun 02 1:48 PM
Hi,
We do not have an option to write the PERFORM statment with in the clss or methods, you need to repeat your code inorder to do the set of tasks
Thanks
Sudheer
‎2009 Jun 02 1:53 PM
Hi Rahul,
If your requirement is within a CLASS, create a METHOD for repeatly used code , and call it from other methods where you required within that class.
if it is in normal ABAP programmingotherthan OOABAP, place the repeatly used code in a PERFORM, and call it from other methods(form...endform) where you required.
by
Prasad GVK.
‎2009 Jun 02 1:58 PM
Hi Rahul,
Create a private method in your class and write your required code.
George
‎2009 Jun 02 2:02 PM
Hi,
You can't use PERFORM statements, instead u can use MACROs or create a separate Method and call that method.
Below is the code sample of a BDC in a Method, which uses Macro as well as Method for repeated process.
DATA: ls_bdcdata TYPE bdcdata, " Work area for BDCDATA
lt_bdcdata TYPE TABLE OF bdcdata. " Internal table for BDCDATA
*---------------------------------------------------------------*
* Macro declaration for BDCDATA
*---------------------------------------------------------------*
DEFINE bdc_.
clear ls_bdcdata.
if &3 is initial.
ls_bdcdata-fnam = &1.
ls_bdcdata-fval = &2.
else.
ls_bdcdata-program = &1.
ls_bdcdata-dynpro = &2.
ls_bdcdata-dynbegin = &3.
endif.
append ls_bdcdata to lt_bdcdata.
END-OF-DEFINITION.
* Filling the BDCDATA
* Screen '0300'
bdc_ 'SAPMM06E' '0300' 'X'.
bdc_ 'BDC_CURSOR' 'EKKO-ANGDT' ' '.
bdc_ 'BDC_OKCODE' '=KOPF' ' '.
bdc_ 'RM06E-ASART' ls_impcluster-rfq_type ' '.
bdc_ 'EKKO-SPRAS' 'EN' ' '.
CALL METHOD me->convert_date( EXPORTING iv_date = ls_impcluster-post_date
IMPORTING ev_date = l_date ).
bdc_ 'RM06E-ANFDT' l_date ' '.
CALL METHOD me->convert_date( EXPORTING iv_date = ls_impcluster-close_date
IMPORTING ev_date = l_date ).
bdc_ 'EKKO-ANGDT' l_date ' '.
bdc_ 'EKKO-EKORG' ls_impcluster-purchasing_org ' '.Regards
Bala Krishna
‎2009 Jun 02 2:05 PM
Hi Rahul,
You can write a perform in a method. you can refer program:BCALV_GRID_06 .
Regards,
Sameer.