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

Convert perform subroutine into method using oops concepts in SAP ABAP.

its_mkz
Discoverer
0 Likes
2,935

Greetings Abapers,

Need to translate-procedural subroutine call using internal table into method call using oops concepts.

Sample statement -

PERFORM f_test_subroutine TABLE lt_table .

------------------------------------------------------------------------

FORM f_test_subroutine TABLES tab1 like gt_test.

ENDFORM.

------------------------------------------------------------------------

Please provide definition and implementation of class as well.

Thanks in advance 🙂

Greetings Abapers,

Need to translate-procedural subroutine call using internal table into method call using oops concepts.

Sample statement -

PERFORM f_test_subroutine TABLE lt_table .

------------------------------------------------------------------------

FORM f_test_subroutine TABLES tab1 like gt_test.

ENDFORM.

------------------------------------------------------------------------

Please provide definition and implementation of class as well.

Thanks in advance 🙂

6 REPLIES 6
Read only

moshenaveh
Community Manager
Community Manager
0 Likes
2,814

Welcome to the SAP Community! Thank you for visiting us to get answers to your questions.

Since you're asking a question here for the first time, I'd like to offer some friendly advice on how to get the most out of your community membership and experience.

First, please see https://community.sap.com/resources/questions-and-answers, as this resource page provides tips for preparing questions that draw responses from our members. Secondly, feel free to take our Q&A tutorial at https://developers.sap.com/tutorials/community-qa.html as well, as that will help you when submitting questions to the community.

Finally, I recommend that you include a profile picture. By personalizing your profile, you encourage readers to respond: https://developers.sap.com/tutorials/community-profile.html.

I hope you find this advice useful, and we're happy to have you as part of SAP Community!

Read only

Sandra_Rossi
Active Contributor
2,814

Seems quite basic, what is your problem rewriting form as method?

Read only

matt
Active Contributor
2,814

Chat gpt can answer this kind of question reasonably well.

Read only

its_mkz
Discoverer
0 Likes
2,814

Usually methods don't support TABLES parameters.

So wanted to know how exactly we translate the same.

Read only

matt
Active Contributor
2,814
BEGIN OF TYPE: ty_record,
  field1 TYPE i,
  field2 type char20,
END OF TYPE ty_record.

TYPE ty_records TYPE STANDARD TABLE OF ty_record WITH DEFAULT KEY.

CLASS myclass DEFINITION.
  PUBLIC SECTION.
    METHODS my_method
      IMPORTING i_records TYPE ty_records.
...
Read only

Sandra_Rossi
Active Contributor
2,814

It's not "usually", "TABLES" parameter has been obsolete for a long time (at same time as subroutines I guess), and doesn't exist in methods. You pass internal tables by declaring a Table Type, and using it via IMPORTING, EXPORTING, CHANGING or RETURNING/RECEIVING.

TYPES your_type_name TYPE ... TABLE OF ... (could be also a range type or a DDIC Table Type instead of TABLE OF)

METHODS ...

parameter_name TYPE your_type_name

...