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

How can I export a table from a function module

Former Member
0 Likes
15,839

Hello friends,

I want to know how can I export an internal table from a function module, for example, in the export tab I want to have my table called IT_DATA

but for insert parameters in the export tab, I need have these objects in the ABAP DICTIONARY but I don't know how can I define this internal table into the ABAP DICTIONARY, is this possible?

And, If I want to export a table from a function module. ¿Where I have to define the table? in the EXPORT tab or in  TABLES tab?

Best regards,

Luis.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,122

Hi,

Go to SE11 (ABAP Dictionary).

1. Initially, create a structure (structure of the Internal Table) by selecting Datatype radio button and give name (Z....) and click create. A popup arises and select Structure radio button and click Ok button. Fill the fields and data elements or predefined type needed, choose the enhancement category and activate it.

2. Then, select Datatype radio button and give name (Z....) and click create. Now, a popup arises and choose Table Type radio button and click Ok button. Give the line type name  (i.e) the structure that has been created for the internal table.

In Function Module,

for the export parameters: You can give the associated type of the parameter as  Table type that has been created.

Eg:      Parameter     Typing     Associated Type

    

          ITAB               TYPE         <Table type name>

Do not use Tables since it follows with header line concept.

If you want to use it, you must give associated type of the parameter as  Structure that has been created.

Eg:      Parameter     Typing     Associated Type

    

          ITAB               LIKE         <Structure name>

Thanks & Regards,

Prasanna

8 REPLIES 8
Read only

Former Member
0 Likes
6,122

Hi Luis,

  For exporting the internal table you need to create an table type in SE11.

Go to SE11, select 'Data Type' radio button, and enter any name and create.

From the Type Popup box select 'Table Type'. Ex: ZITAB

In the Line Type, give your database table name. Save and activate.

Go to SE37 to create function module.

In the Export tab, create an parameter with associated type as your table type name i.e ZITAB.

Read only

0 Likes
6,122

Hello,

Thanks for your fast answer but, in this option: "Table type", not allows me give the fields name and types field, how I can I do this?

Read only

0 Likes
6,122

Hi Luis,

You cannot give the field names and their types in the table type creation screen. I'm just rephrasing what Satish already told. Hope it makes it clear for you.

Creating a table with a set of fields is usually a two step process.

1. Create a Structure in SE11 (let's say you named it ZSDEMO). You can give the list of filed names and their types that you want in this structure.(If you have trouble creating a structure use this link http://help.sap.com/saphelp_nw04s/helpdata/en/90/8d7310b1af11d194f600a0c929b3c3/content.htm)

2. Create a Table Type in SE11 (let's say you named it ZTDEMO). Here you've to give the structure you created in Step 1 (ZSDEMO) as the Line Type. (If you have trouble creating a table type use this link http://help.sap.com/saphelp_nw04/helpdata/EN/90/8d731fb1af11d194f600a0c929b3c3/frameset.htm)

Once you've created the table type you can use them in the export tab as Satish mentioned.

Hope that helps!

Read only

0 Likes
6,122

Hi,

when creating table type u can use your Z structure or database table for line type

in code table type doesnt have header line so declare work area type your structure

loop at it_data

     into wa.

endloop.

Read only

0 Likes
6,122

Hi Luis,

In your code logic declare the work area and using this work area append the values to your table type.

Suppose your table type name is ZITAB and your database table( line type) is ZDBTABLE.

Then use the following code for updating the values in your function module:

DATA: wa TYPE ZDBTABLE.

wa-field1 = value1.

wa-field2 = value2.

wa-field3 = value3.

APPEND wa TO GT_TABLE.

GT_TABLE will be your exporting internal table which is of type ZITAB.

And if you want to use this GT_TABLE use the following code in your report where the function module is called:

LOOP AT gt_table INTO wa.

**** Write your logic

ENDLOOP.

Read only

Former Member
0 Likes
6,122

Hi,

You can either create the line type/table type and use it to define your EXPORT parameter as suggested by POLAT. Or you can directly create a custom (ZXYZ) structure in SE11 and then use that in defining your TABLE parameter ( I suggest this as this would be straight and easy).

Either way you will have to create a Z structure in SE11(as per the req fields) and in the Code section you have to define internal table of that structure type and have a work area to manipulate the values.

Please let us know if this helps.

Regards,

Deepak.

Read only

Former Member
0 Likes
6,122

Hi Luis,

Please create it in the Tables Tab as that is the expected way of declaring for the new version of sap. You can create a structure or a line type or a table type in SE11 and declare it of that structure type.

Hope this helps!

Read only

Former Member
0 Likes
6,123

Hi,

Go to SE11 (ABAP Dictionary).

1. Initially, create a structure (structure of the Internal Table) by selecting Datatype radio button and give name (Z....) and click create. A popup arises and select Structure radio button and click Ok button. Fill the fields and data elements or predefined type needed, choose the enhancement category and activate it.

2. Then, select Datatype radio button and give name (Z....) and click create. Now, a popup arises and choose Table Type radio button and click Ok button. Give the line type name  (i.e) the structure that has been created for the internal table.

In Function Module,

for the export parameters: You can give the associated type of the parameter as  Table type that has been created.

Eg:      Parameter     Typing     Associated Type

    

          ITAB               TYPE         <Table type name>

Do not use Tables since it follows with header line concept.

If you want to use it, you must give associated type of the parameter as  Structure that has been created.

Eg:      Parameter     Typing     Associated Type

    

          ITAB               LIKE         <Structure name>

Thanks & Regards,

Prasanna