Application Development and Automation 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: 
Read only

Perform in a method.

Former Member
0 Likes
2,829

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

6 REPLIES 6
Read only

Former Member
0 Likes
1,808

Just create a new method for your task and call it repeatedly.

Michael

Read only

Former Member
0 Likes
1,808

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

Read only

Former Member
0 Likes
1,808

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.

Read only

Former Member
0 Likes
1,808

Hi Rahul,

Create a private method in your class and write your required code.

George

Read only

former_member585060
Active Contributor
0 Likes
1,808

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

Read only

Former Member
0 Likes
1,808

Hi Rahul,

You can write a perform in a method. you can refer program:BCALV_GRID_06 .

Regards,

Sameer.