2023 Aug 08 2:28 PM
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 🙂
2023 Aug 08 2:28 PM
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!
2023 Aug 08 4:22 PM
Seems quite basic, what is your problem rewriting form as method?
2023 Aug 09 8:33 AM
2023 Aug 09 12:50 PM
Usually methods don't support TABLES parameters.
So wanted to know how exactly we translate the same.
2023 Aug 09 2:04 PM
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.
...
2023 Aug 09 3:01 PM
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
...
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |