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

Function Module with internal table insie internal table as a parameter

former_member201275
Active Contributor
0 Likes
1,820

Hi,

I have a function module which should receive back information about customers. There could be many customers therefore the export Parameter has to be a table.

The Problem is that for each customer we will also receive a list of invoices i.e. invoice number and invoice date.

The table for the Export Parameter should be able to handle more than one customer and for each customer more than one invoice.

All help greatly appreciated

1 ACCEPTED SOLUTION
Read only

Patrick_vN
Active Contributor
1,742

Have you considered creating a table type based on a deep structure?

  1. Create/Find a table type in DDIC with invoice data.
  2. Create a structure with customer data, add a field 'invoices' of the table type you made/found in 1.
  3. Create a table type based on the deep structure you made in 2.

And of course use that last table type to type the export parameter

9 REPLIES 9
Read only

joltdx
Active Contributor
0 Likes
1,742

Can you not just have the function module return two tables? One for the customers, and one with the invoices, having also the customer as a key field?

Something like tables of these?

TYPES:
  BEGIN OF customer,
    customer_number type customer_number_type,
    customer_name   type string,
  END OF customer.

TYPES:
  BEGIN OF invoice,
    customer_number type customer_number_type,
    invoice_number  type invoice_number_type,
    invoice_date    type dats,
  END OF invoice.
Read only

0 Likes
1,742

Thank you for your answer. I don't think we can do that because it is an RFC so we call another System and it has to be able to come back as table in table 😞

Read only

joltdx
Active Contributor
1,742

Ok, yes you can do that and I see pvnierop has already explained how...

Read only

Patrick_vN
Active Contributor
1,743

Have you considered creating a table type based on a deep structure?

  1. Create/Find a table type in DDIC with invoice data.
  2. Create a structure with customer data, add a field 'invoices' of the table type you made/found in 1.
  3. Create a table type based on the deep structure you made in 2.

And of course use that last table type to type the export parameter

Read only

0 Likes
1,742

Yes I think this is what I have to do. Do you know if there are any such demo Function Modules in SAP?

Read only

0 Likes
1,742

By the way, if you're going to use it as table-parameter, then you don't need step 3. Just use the deep structure there.

Not really sure if there are demo FM's. But if you want to know how to make a deep structure, there are more than a few tutorials on the www 😉

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,742

What is your issue in declaring a table inside a table?

Read only

former_member201275
Active Contributor
0 Likes
1,742

Thank you for your answer. I was getting error messages trying to create this so i thought it is not possible in SAP. I will keep trying and close the question then if this possible. Sorry for the hassle. 😞

Read only

former_member201275
Active Contributor
0 Likes
1,742

Thank you all for your help and apologies for the stupid question