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

Passing internal table from a function module

Former Member
0 Likes
5,363

Hi,

I am trying to pass an internal table from a function module to a calling program.

This is the internal table structure in my function module.

DATA: BEGIN OF authtab OCCURS 0,

seqnr like sy-tabix,

field_1 type XUFIELD,

fieldval type XUVAL,

END OF authtab.

The passing parameters are

*" REFERENCE(DATE) TYPE DATS

*" TABLES

*" AUTHTAB

my calling function is:

CALL FUNCTION XXX

EXPORTING

XXX = XXX

XXX = XXX

XXX = XXX

TABLES

AUTHTAB = authentab.

authentab is an internal table i declared in my calling program

DATA: BEGIN OF authentab OCCURS 0,

seqnr like sy-tabix,

field type XUFIELD,

fieldval type XUVAL,

END OF authentab.

The FM works fine. But i cant pass the content of the internal table over to the calling program for display. Anyone know how to go abt solving this?

regards,

r3venant

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,040

Hi,

I think you cann't declare internal table in the FM for Table parameter.

You should do this:

1. Create Structure in SE11 for Table Parameter (ex. Z_AUTH ).

2. Insert your Table Parameter at tab TABLES in your FM:

Parameter Name: <b>TAB_AUTHTAB</b>.

Type Spec: LIKE

Associated Type: Z_AUTH ( Your Sturcture Name that you created in SE11).

And in calling program, cretate the internal table, like this:

DATA: IT_AUTHTAB TYPE STANDARD TABLE OF Z_AUTH OCCURS 0 WITH HEADER LINE.

CALL FUNCTION XXX

EXPORTING

XXX = XXX

XXX = XXX

XXX = XXX

TABLES

<b>TAB_AUTHTAB</b> = IT_AUTHTAB.

Regards,

14 REPLIES 14
Read only

Former Member
0 Likes
2,041

Hi,

I think you cann't declare internal table in the FM for Table parameter.

You should do this:

1. Create Structure in SE11 for Table Parameter (ex. Z_AUTH ).

2. Insert your Table Parameter at tab TABLES in your FM:

Parameter Name: <b>TAB_AUTHTAB</b>.

Type Spec: LIKE

Associated Type: Z_AUTH ( Your Sturcture Name that you created in SE11).

And in calling program, cretate the internal table, like this:

DATA: IT_AUTHTAB TYPE STANDARD TABLE OF Z_AUTH OCCURS 0 WITH HEADER LINE.

CALL FUNCTION XXX

EXPORTING

XXX = XXX

XXX = XXX

XXX = XXX

TABLES

<b>TAB_AUTHTAB</b> = IT_AUTHTAB.

Regards,

Read only

0 Likes
2,040

Hi Jatra,

Ok i understand where u are coming from. I think that might be the last option i would try becoz i dun want to create a table just for that. 😃 thanks anyway

Read only

Former Member
0 Likes
2,040

r3venant,

Check 2 things.

1.In your function module is the internal table getting filled with some data ?.

Have you checked it in debugging mode.

2.Is the date passing date value through parameter is available in function

module?.Check in debugg mode

Pls. reward if useful

Read only

0 Likes
2,040

Hi kaipha,

The function module works fine, the internal table "authtab" is filled with data that i want to pass to the calling program. But i cant seem to display the data. Its empty over at the calling program.

Regards,

r3venant

Read only

former_member194669
Active Contributor
0 Likes
2,040

can you give the attributes from tables tab of your fm for this table?

aRs

Read only

0 Likes
2,040

hi ars,

I've only declared authtab under the table tab w/o any typing or associated type.

regards,

r3venant

Read only

former_member194669
Active Contributor
0 Likes
2,040

Define a strcuture in SE11 for authtab.

in tables declaration TAB of fm define LIKE structure your created in SE11

aRs

Read only

Former Member
0 Likes
2,040

Inside the function module code, declare an internal table with the same structure and move the contents of the tables parameter internal table to this one. After that you will be able to work with the individual fields.

So in other words, I will declare an internal table inside the function module code that is exactly similar to what you declared in your calling program.

FUNCTION XXXXX.

*TABLES

*ITAB

DATA: BEGIN OF local_authtab OCCURS 0,

seqnr like sy-tabix,

field_1 type XUFIELD,

fieldval type XUVAL,

END OF local_authtab.

local_authtab[] = itab[].

*-- do whatever you want to do with local_authtab. if you modify local_authtab, then add this statement at the end, just before ENDFUNCTION.

clear itab[].

itab[] = local_authtab[].

Read only

Former Member
0 Likes
2,040

i cant under stand 1 thing in your tables paramenter you declare AUTHTAB and in source code also you are dclaring like

DATA: BEGIN OF authtab OCCURS 0,

seqnr like sy-tabix,

field_1 type XUFIELD,

fieldval type XUVAL,

END OF authtab.

and system does not give any error .....

as per i can understand you did not define any tables parameter in the tab tables?

if i am right then declare in the tables tab (after changing tab) AUTHTAB and delete the declaration of authtab in source code .. and do the modification or any thing with AUTHTAB it will automatically assign the value to your prog ..

regards

shiba dutta

Read only

0 Likes
2,040

Hi Srinivas, Thanks for your reply.

Hi SHIBA, yep you are correct there was error in the codes i gave sorry this is the new one.

FM : i declare

authtab TYPE STANDARD TABLE OF ust12 WITH HEADER LINE.

under table tab : parameter name : authtab1

end of the FM i did a

authtab1[] = authtab.

now all my content is held in authtab1.

In the calling program, i declare authtab again.

authtab TYPE STANDARD TABLE OF ust12 WITH HEADER LINE.

with the calling :

CALL FUNCTION XXX

EXPORTING

UNAME = sy-uname

OBJECT = XXX'

FIELD = XXX

DATE = sy-datum

TABLES

AUTHTAB1 = authtab.

by here, when debugging, there is no data in authtab1 i think... there is no data. Any idea?

regards,

r3venant

Read only

0 Likes
2,040

sorry again i cant get you

end of the FM i did a

authtab1[] = authtab.

in the source code also you are declaring authtab?

if it is so

authtab1[] = authtab[].

just put a break point in the fn module and check before endfunction statement if authtab1 containing any value or not if it is containing any value then your itab in prog should also get the value.

just check in above statement authtab1[] = authtab[]. authtab[] what value it contains?

regards

shiba dutta

Read only

0 Likes
2,040

its contains data like "department 07"

Read only

0 Likes
2,040

> Hi Srinivas, Thanks for your reply.

>

> Hi SHIBA, yep you are correct there was error in the

> codes i gave sorry this is the new one.

>

> FM : i declare

>

> authtab TYPE STANDARD TABLE OF ust12 WITH HEADER

> LINE.

>

> under table tab : parameter name : authtab1

>

> end of the FM i did a

> authtab1[] = authtab. <b><-- this has to be authtab1[] = authtab[].</b>

>

> now all my content is held in authtab1.

>

> In the calling program, i declare authtab again.

> authtab TYPE STANDARD TABLE OF ust12 WITH HEADER

> LINE.

>

> with the calling :

> CALL FUNCTION XXX

> EXPORTING

> UNAME = sy-uname

> OBJECT = XXX'

> FIELD = XXX

> DATE = sy-datum

> TABLES

> AUTHTAB1 = authtab.

> here, when debugging, there is no data in authtab1 i

> think... there is no data. Any idea?

>

> regards,

> r3venant

Read only

Former Member
0 Likes
2,040

Hi,

you try once by using the squarebrackets for the internal table you are using.

TABLES

AUTHTAB = authentab[].