Application Development 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: 

How to read the method and put that code in 1 internal table

Former Member
0 Kudos

Hi,

Actually in the normal ABAP, if we want to read the report, then we will write read report statement.

If we want to read method then this statement will not work.

So, to read the method and put that code in 1 internal table , which statement we need to write?

Regards,

Radhika

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

You can use the same READ report statement, but before doing that you need to get the INCLUDE name which is actually storing the METHOD's code.

Use the FM SEO_METHOD_GET_INCLUDE_BY_NAME to get the Inlcude name by providing CLASS & METHOD as the key.

Now use the Read report statement for Include program to get the source code of the method.

Regards

Naimesh Patel

6 REPLIES 6

naimesh_patel
Active Contributor
0 Kudos

You can use the same READ report statement, but before doing that you need to get the INCLUDE name which is actually storing the METHOD's code.

Use the FM SEO_METHOD_GET_INCLUDE_BY_NAME to get the Inlcude name by providing CLASS & METHOD as the key.

Now use the Read report statement for Include program to get the source code of the method.

Regards

Naimesh Patel

0 Kudos

Hi Naimesh,

Thanks for your reply.

As, i am not aware of ABAP Objects i am having some issues:

Actually that is working for some methods in some classes.

Here 1 issue is there:

In se24 1 method is there in 1 class.

Even by using that FM i am able to get the program name by giving class and method name,

but in se38 and in se80 that program is not there.

so, where we can i find that program to read the source code of the program?

1 example here:

Class name is CL_GUI_FRONTEND_SERVICES.

in this class, methods like FILE_EXIST , FILE_GET_SIZE, etc are there.

By giving the class name and method name i am able to get the program name also,

but in se38 that program is not there. So, i am unable to read the source code of that program.

please help me out in this regard.

Thanks & Regards,

Radhika

uwe_schieferstein
Active Contributor
0 Kudos

Hello Radhika

An alternative approach is to use fm SEO_METHOD_GET_SOURCE.

Regards

Uwe

Former Member
0 Kudos

Hi Naimesh,

Thanks for your reply.

As, i am not aware of ABAP Objects i am having some issues:

Actually that is working for some methods in some classes.

Here 1 issue is there:

In se24 1 method is there in 1 class.

Even by using that FM in SE37 i am able to get the program name by giving class and method name,

but while using that FM in the program i am not able to get that program name.

so, i am unable to read the source code of the program?

1 example here:

Class name is CL_GUI_FRONTEND_SERVICES.

in this class, methods like FILE_EXIST , FILE_GET_SIZE, etc are there.

By giving the class name and method name i am able to get the program name also,

but while using that FM in the program i am not able to get that program name.

so, i am unable to read the source code of the program?

Here is my code:

REPORT Z16059_SCAN_METHOD.

DATA: BEGIN OF I_PROGRAM OCCURS 0,

LINE(256) TYPE C,

END OF I_PROGRAM.

DATA METHOD TYPE PROGRAM.

DATA: BEGIN OF I_STRUCTURE,

CLS_NAME(30) TYPE C,

METH_NAME(61) TYPE C,

END OF I_STRUCTURE.

I_STRUCTURE-CLS_NAME = 'CL_GUI_FRONTEND_SERVICES'.

I_STRUCTURE-METH_NAME = 'CL_GUI_FRONTEND_SERVICES-FILE_EXIST'.

CALL FUNCTION 'SEO_METHOD_GET_INCLUDE_BY_NAME'

EXPORTING

MTDKEY = I_STRUCTURE

IMPORTING

PROGNAME = METHOD

EXCEPTIONS

INTERNALMETHOD_NOT_EXISTING = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

READ REPORT METHOD INTO I_PROGRAM.

Please help me out in this regard.

Thanks & Regards,

Radhika

0 Kudos

You should only pass the method name to the METH_NAME field.


I_STRUCTURE-CLS_NAME = 'CL_GUI_FRONTEND_SERVICES'.
I_STRUCTURE-METH_NAME = 'FILE_EXIST'.

Regards,

Naimesh Patel

0 Kudos

Naimesh,

Thanks a lot, now it is working.

Thanks for your instant reply.

if any doubts, i'll get back to you.

Thanks,

Radhika