Analysis: As per business a material type can have 'n' number of materials
As per SAP, tables in function modules obsolete, instead using them, we can create a table type in SE11, use it as exporting parameter.
Changing and Tables are parameters of Function Modules. Changing: Changing parameter acts as both exporting and importing parameters. Tables: These are internal tables which can import and export.
Using Tables in SAP Function Modules
Go to SE37, provide name as ZSAPN_FM_TABLES, click on create.
A pop up will open, provide a function group (we have created already), a short text and enter.
Go to import tab, provide parameter name as IM_MTART -> TYPE -> MARA-MTART, enter.
Go to 'Tables' tab, provide parameter name as T_MARA -> LIKE -> MARA, enter.You will get a warning message saying tables are obsolete just ignore it, hit enter.
Go to source code tab, add below logic to material details.
Execute the Function Module