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

Doubt in export, import and table para when creating Function Module

Former Member
0 Likes
1,683

Dear fellow ABAPers,

I have a doubt in defining export, import and table parameter while creating a function module.

I am calling a function module inside a user exit. Now in the user exit the SAP fills an internal table called i_lfa1 with all the data user has eneterd.

Now I want to pass this whole internal table to function module and the perform some checks on the values of internal table.

After that function module fills an error structure with values depending on some check.

1)

How do I pass this internal table to function module ?

When I am creating function module in se37 where do I define this iternal table type ? Is it in Import or Table parameter during function module creation?

2)

Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?

Please clear my doubt..

Relevant points will be awarded.

Regards,

Tushar.

17 REPLIES 17
Read only

Former Member
0 Likes
1,626

1. that should be table parameter.

2. that errorstructure is export parameter.

Read only

Former Member
0 Likes
1,626

Hi Tushar,

1. How do I pass this internal table to function module ?

I assume u are creating your own Y/Z FM.

Pass it thru TABLES parameter.

2. When I am creating function module in se37 where do I define this iternal table type

Define this in TABLES interface.

What Type ?

THE SAME TYPE WHICH HAS BEEN DEFINED

WHILE PASSING IN THE USER-EXIT FUNCTION MODULE.

IF U SEE THE FM OF THE USER-EXIT,

U WILL COME TO KNOW.

3.

Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?

Define it in TABLES interace. (not in export, import)

(Since what u are going to return is an internal table)

U can take for eg. BDCMSGCOLL.

OR u can create your own Y/Z structure

for the same purpose.

(or u can use the structure type T100)

I hope it helps.

Regards,

Amit M.

Read only

Former Member
0 Likes
1,626

Hi Tushar,

You create structure in se11 which is the same as the internal table structure that is filled in the userexit.

Similarly, you can create the structure for error.

Now, in 'Tables' tab you define two internal tables and give the respective structures created in column 'Associated type'.

Hope its clear.

Regards,

Raj

Read only

Former Member
0 Likes
1,626

1) you have to define the internal table in the tables section of the FM.

if ur i_lfa1 is having a structure like zv_lfa1

then u have specify it as

i_lfa1 like zv_lfa1.

2)you can define the error structure in tables.

here in the FM you can append the error structure if u did not find the data and display the error if the itab is having the null values. you can use the structure like bapiret2,etc .,

for this if you want to define some exceptions, you can define it in exceptions.

hope this will be helpful.

reward points if its helpful.

Cheers

Read only

Former Member
0 Likes
1,626

for creating the internal table , just go to se11 and create the table type structure. and give the reference while creating the table parameter of the FM.

error structure can be given as bapireturn structure.

vijay

Read only

Former Member
0 Likes
1,626

1)

How do I pass this internal table to function module ?

When I am creating function module in se37 where do I define this iternal table type ? Is it in Import or Table parameter during function module creation?

<u><b>You have to define it as an table parameter</b></u>

2)

Where do I define error structure type (which is returned by function module to main program)? Is it in Export or table parameter during function module creation?

<u><b>It depends on how many records you want to return in the error-structure. If it will contain more than one record then you will have to define it as an table paramter or if it returns only one record then define it as an export parameter in the function module.</b></u>

Read only

0 Likes
1,626

Sam,

My error structure will have a structure referencing one custom structure created in DDIC.

his reference struture has around eight fields. So the error structure may get populated with ll fields or just one depending on checks.

So I guess I have to define the error structure in table parameter when I am creating function module. Isn't it right ?

Read only

0 Likes
1,626

if you are expecting more than one eror use tables parameter...

vijay

Read only

0 Likes
1,626

So does this mean that in tables parameter statement we can define both tables which are imported as well as exporte ?

Read only

0 Likes
1,626

yeah both will be imported(blank) and exported(with data).

vijay

Read only

0 Likes
1,626

The deciding factor is the number of records/rows not the number of fields. So if you think that your return parameter should (or will) return you more that one record then define it as an table parameter otherwise you can define it as a export parameter.

However If you are not sure then define it as a table parameter!

Message was edited by: Sam

Read only

0 Likes
1,626

you can define the error structure as export parameter as well, just delcare your error struc in export like the ddic structure.

within your function you can assign a itab this (same type).

errorstruc[] = localitab[] .

check any bapi in your system how the return table is handled.

Regards

Raja

Read only

Former Member
0 Likes
1,626

Hi Tushar,

when creating ur function modules of ur own (i.e y)u have to define this table in the table parameters and u can import the data into into that.and the error messages r handled using the exceptions in the function modules.

if this doesn't clear ur douts semd me the code i'll make the modifications,

Regards,

suresh

Read only

Former Member
0 Likes
1,626

Hi Tushar

1. The table should be table parameter.

2. The error structure should be the export parameter.

Read only

Former Member
0 Likes
1,626

Hi Tushar

1. The table should be table parameter.

2. The error structure should be the export parameter.

Read only

Former Member
0 Likes
1,626

If I define errorstruc as table parameterwhile creation of function module in se37,

then to extract the values from structure while doing call to function module in main program do I need to define it in TABLES also?

Tushar.

Read only

0 Likes
1,626

Hi again,

1. I assume u have defined the FM

and in TABLES

u have also defined the errorstruc parameter

of some type say XABC.

2. While calling the FM,

u will have to declare a variable like this.

data : err like table of XABC with header line.

3. Now call the FM

call function 'myfunc'

EXPORTING

.

.

IMPORTING

.

.

TABLES

ERR

.

I hope it helps.

regards,

amit M.