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

Create and Call Method.;

ronaldo_aparecido
Contributor
0 Likes
1,099

Hello guys.

Inside a method can not use Perform(message error) . Should I replace a method>

How I will create a method ? How I will call it?

I am in IF_EX_ME_HOLD_PO~IS_ALLOWED.

See attached.

Thanks.

1 ACCEPTED SOLUTION
Read only

ChandrashekharMahajan
Active Contributor
0 Likes
1,058

Hi,

It seems that you have BAdI implementation class. Just create required method in class and in place of perform call. your new method should have logic of PERFORM and have required signature for data input/output.

Regards,

Chandra

6 REPLIES 6
Read only

ChandrashekharMahajan
Active Contributor
0 Likes
1,059

Hi,

It seems that you have BAdI implementation class. Just create required method in class and in place of perform call. your new method should have logic of PERFORM and have required signature for data input/output.

Regards,

Chandra

Read only

0 Likes
1,058

Hi Chandra.

You have examples codes?

Thanks.

Read only

0 Likes
1,058

Mentioned below is an example of how to do this in a local class defined in a report program. If you are using a BADI then just define the new method in class which is created in BADI implementation as mentioned by chandra.

Way of calling the method new method from IF_EX_ME_HOLD_PO~IS_ALLOWED is same as shown below for METHOD m2.

 

CLASS c1 DEFINITION.
PUBLIC SECTION.
METHODS: m1 IMPORTING p1 TYPE string
p2 TYPE I
EXPORTING p3 TYPE d
p4 TYPE f
EXCEPTIONS ex1
ex2,
m2.
ENDCLASS.

CLASS c1 IMPLEMENTATION.
METHOD m1.
...
ENDMETHOD.
METHOD m2.
DATA: text TYPE string,
number TYPE i,
date TYPE d,
amount TYPE f.
...
m1( EXPORTING p1 = text
p2 = number
IMPORTING p3 = date
p4 = amount
EXCEPTIONS ex1 = 10
ex2 = 20
OTHERS = 30 ).
CASE sy-subrc.
WHEN 10.
...
WHEN 20.
...
WHEN 30.
...
ENDCASE.
ENDMETHOD.
ENDCLASS.

Read only

0 Likes
1,058

Hi I create the method valida past and i use call method.

IF t_ekko-bsart = 'PEST'.

     CALL METHOD valida_pest.

*    PERFORM f_valida_pest.

     EXIT.

   ENDIF.

will it go work?

Its correct.?

Thanks for help.

Read only

0 Likes
1,058

Hi Ronaldo,

You can create a method valida_pest in the BADI implementation class with required import/ export parameters (You can get the Implementing class name in the header details of the BADI imlementation).

And then you can try to call this method inside the BADI method IF_EX_ME_HOLD_PO~IS_ALLOWED by calling me->valida_pest(). To get exact syntax use pattern option in editor.

If you need to store any global data make sure you declare attributes in the same class and then store the data in the attributes.

Thanks,

Ajay

Read only

0 Likes
1,058

thanks AJAY