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 issue

Former Member
0 Likes
2,492

HI Guru s

                  I am practicing FM. I am facing two issue

1) In source code if i use "DATA : ITAB_TABLE....." i get an error ITAB_TABLE is already use.

2) iF i use " DATA : A_TABLE......" i am able to activate it and get 1st o/p screen ,however when i insert the reqd info and click on value i didn't get the reqd info, i have attached all screenshot plz tell me Y  i am not getting output......

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,457

HI happy,

           

            In export parameter u have declared itab_table right,

           that is not a internal table that is work area

            u have to define Itab_table in tables Tab.

         follow this logic

       

 

write the code in source Code.

select * from kna1 into TABLE itab

             where kunnr = cust_no and

             name1 = name and

             land1 = countryname.

output:

   after executing u will recieve detail in ti internal table..


Award points if useful

regards,

arun prasath

6 REPLIES 6
Read only

uppu_narayan
Active Participant
0 Likes
2,457

Hi Happy,

        the reason you are getting the first error because you have already declared a variable with same name in the exporting parameter and in the second case it is not populating  with data since you have not assigned the value in the a_table back to your exporting parameter itab_table.

        hope thats clear.......

thanks and regards,

narayan

Read only

0 Likes
2,457

Hi Uppa,

             Thax for reply Sir  will u plz explain how to assigned the value in the a_table.... appreciate ur help

Read only

0 Likes
2,457

Hi Happy,

While building a function module you need to keep at least the following things in mind:

1) Import parameters: Those variables for which values will be provided at the time of calling the function module.

2) Export parameters: Those variables for which values will be populated and produced as output from the Function Module.

So while defining a new FM, if you have already provided ITAB_TABLE in the export parameter, that means it is already declared. You dont need to re-declare it inside the source code once again.

This is why you were getting the error as: "ITAB_TABLE" is already in use.

In the 2nd case, you declared the table A_TABLE in the source code but you have not given it in the export parameters. FM only shows the export and tables parameters containing outputs after executing.

So here the basic idea is,

Just declare the variable (internal table in your case) inside the export parameter (dont declare it once again in the source code) and then just write the select statement as you did in the source code.

Hope this helps.

Read only

Former Member
0 Likes
2,457

Hi Happy,

If you had already declared in one of the parameters in the FM, so no need to declare one more time in the source code.

Thanks.

Pavan

Read only

Former Member
0 Likes
2,457

Hi Happy,

You shouldn't declare variables of same name in a Function Module,

Here you are Declaring ITAB_TABLE as Exporting Parameter as well as Local Table, so You should change name of any one

You can solve your second problem of Data not getting filled by doing as below code

DATA : itab_temp LIKE kna1 OCCURS 0 WITH HEADER LINE.

SELECT SINGLE *

     FROM kan1

          INTO itab_temp

               WHERE kunnr = cust_no.

itab_table = itab_temp.

Or you can even Directly use ITAB_TABLE in the select statement, This will Solve your Problem

Thanks and Regards,

Pratheek

Read only

Former Member
0 Likes
2,458

HI happy,

           

            In export parameter u have declared itab_table right,

           that is not a internal table that is work area

            u have to define Itab_table in tables Tab.

         follow this logic

       

 

write the code in source Code.

select * from kna1 into TABLE itab

             where kunnr = cust_no and

             name1 = name and

             land1 = countryname.

output:

   after executing u will recieve detail in ti internal table..


Award points if useful

regards,

arun prasath