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

How to call a Method in a Program?

Former Member
0 Likes
68,558

Hello,

I am very new to the ABAP world. I have been given a task to call a method if_hrbas_plain_infotype_access~read_single from the class CL_HRBAS_PLAIN_INFOTYPE_ACCESS in a program to see if we can use it to display some employee information. I don't know how to call a method in a program. Can somebody please provide me some pseudo code or instructions?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
22,487

Hi,

in the source code screen in se37 or se38 --> Press Ctrl+F6 or pattern

next>select ABAP object pattern and execute>enter calss "CL_HRBAS_PLAIN_INFOTYPE_ACCESS"

under enter method "if_hrbas_plain_infotype_access~read"

and enter

Prabhudas

13 REPLIES 13
Read only

former_member376453
Contributor
0 Likes
22,487

In the same way you call a FM. Click on button Pattern, then give the method name you want to call.

Kuntal

Read only

0 Likes
22,487

Thanks for the response. However, I don't know how to call a FM as well. I am looking for some syntax or pseudo code. Sorry, if it is a basic question.

Thanks.

Read only

0 Likes
22,487

As I have said, press the pattern button from your editor. Their you will get the option. Or search net to get step by step details.

Kuntal

Read only

Former Member
0 Likes
22,488

Hi,

in the source code screen in se37 or se38 --> Press Ctrl+F6 or pattern

next>select ABAP object pattern and execute>enter calss "CL_HRBAS_PLAIN_INFOTYPE_ACCESS"

under enter method "if_hrbas_plain_infotype_access~read"

and enter

Prabhudas

Read only

Former Member
0 Likes
22,487

Hi Shan,

go to your program Se38 or from where you want to call method.

then in application tool bar, one pushbutton called 'PATERN ' is there. click that.

then one pop-up will come, within pop-up select 'abap object patern', radio button. then enter.

select call method radiobtton & then give the class name & method of that class which you want to called.

for class see tr. se24.

Regards,

Tutun

Read only

Former Member
0 Likes
22,487

Hi,

Either you can use the patterns, or if you can simply type

CALL METHOD (CLASS_NAME)=>(METHOD NAME)

EXPORTING

IMPORTING .

Use F1 on 'Call method' to get more details.

Thanks

Read only

Former Member
0 Likes
22,487

Hello Shan,

Just follow the navigation provided below to call method from program.

Go to se38 transaction---> Open your program----> press ctrl+f6 (or) PATTERN button on the toolbar--->select ABAP OBJECT PATTERNS----> select CALL METHOD---> enter the method you want to call and hit enter.

hope this solves your problem.

Regards,

Pavan.

Read only

Former Member
0 Likes
22,487

Hi,

Click on the Pattern button (or ctrl+f6) in se38, choose "ABAP Object Patters" and click on u201Centeru201D button.

It will open an other window

Enter the Class as if_hrbas_plain_infotype_access and

enter the method as read

and again press enter...

The code is ready

Hope this helps.

Thanks

Sindhu

Read only

Former Member
0 Likes
22,487

hi shan ,

you can try this wiki link as reference , to get the idea of your problem

https://wiki.sdn.sap.com/wiki/display/ABAP/7stepstocreateOOPS+ALV

Regards

Saurabh Goel

Read only

Former Member
0 Likes
22,487

Hi Shan,

here is the code to call a method. while calling the method Instance as 'r_info' which is the type reference to class as specified.

pass the values to exporting parameters plvar,otype,objid...etc according to the requirement


infotypes: 0002.   " creates an internal table p0002.
data:

 r_info type ref to CL_HRBAS_PLAIN_INFOTYPE_ACCESS.
 
 TRY.
 CALL METHOD r_info->if_hrbas_plain_infotype_access~read
   EXPORTING
     plvar           =  
     otype           =
     objid           =
     istat           =
     infty           =
*     SUBTY           =
     begda           =
     endda           =
     no_auth_check   =  'X'
     message_handler =
   IMPORTING
     PNNNN_TAB       = P0002 
*     HRTNNNN_TAB     =
*     IS_OK           =
     .
  CATCH CX_HRBAS_VIOLATED_ASSERTION .
 ENDTRY.

LOOP AT P0002.
      WRITE:/
        P0002-VORNA,
        P0002-NCHMC,
        P0002-NACHN.
    ENDLOOP.


Regards

Read only

Former Member
0 Likes
22,487

Hi,

From the ABAP editor (SE38) press the PATTERN button or press Control+F6.

Then select the radiio-button ABAP Object Patterns and then continue.

Next put in the Class/Interface name as - CL_HRBAS_PLAIN_INFOTYPE_ACCESS

and the Method name as - if_hrbas_plain_infotype_access~read_single and then click continue.

Read only

0 Likes
22,487

Thanks a lot to all of you for help.

Read only

YLATHI
Newcomer
0 Likes
9,220

Hi,

an example 

YLATHI_0-1740402821299.png

YLATHI_1-1740402859301.png