‎2010 Oct 19 1:09 AM
Hi ,
I created Custom function module importing parameter as X
and changing parameter as emp_det type ZTABLE (Transpearent table)
I used select stat which will get data from Ztable stored into internal table itab.
at the end i am assing internal table emp_det
EMP_DET = itab.
This emp_det gives final result.
Whilie checking iam getting error as
itab cannot be converted to the type of emp_det
Thanks,
Sam
‎2010 Oct 19 3:41 AM
‎2010 Oct 19 1:25 AM
Hi,
Please, put the your code (start of FM , call of FM, definition of variables).
Best regards,
Leandro Mengue
‎2010 Oct 19 3:29 AM
Code
FUNCTION Z_TEST_RKM.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(EMPLOYEE) LIKE ZHRS_EMP
*" STRUCTURE ZHRS_EMPLOYEE_SEARCH OPTIONAL
*" CHANGING
*" REFERENCE(EMPLOYEE_DETAILS) TYPE ZHR_TABLE
*"----
types: begin of ty_str,
MANDT type MANDT,
PERNR type PERSNO,
VORNA type PAD_VORNA,
NACHN type PAD_NACHN,
end of ty_str.
data: it_employee_detail TYPE STANDARD TABLE OF ty_str,
wa_employee_info TYPE ty_str.
select * from ZHR_TABLE into table it_employee_detail.
EMPLOYEE_DETAILS = it_employee_detail.
ENDFUNCTION.
‎2010 Oct 19 3:25 PM
Hi,
Try this:
DATA: i_zhr_table LIKE zhr_table OCCURS 0 WITH HEADER LINE.
CALL FUNCTION 'Z_TEST_RKM'
TABLES EMPDETAIL = i_zhr_table.
FUNCTION Z_TEST_RKM.
*"--------------------------------------------------------------------
""Local Interface:
*" TABLES
*" EMPDETAIL STRUCTURE zhr_table
*"--------------------------------------------------------------------
select * from ZHR_TABLE into table EMPDETAIL.
ENDFUNCTION.Best regards,
Leandro Mengue
‎2010 Oct 19 3:50 PM
>
> FUNCTION Z_TEST_RKM.
> *"----
> ""Local Interface:
> *" IMPORTING
> *" VALUE(EMPLOYEE) LIKE ZHRS_EMP
> *" STRUCTURE ZHRS_EMPLOYEE_SEARCH OPTIONAL
> *" CHANGING
> *" REFERENCE(EMPLOYEE_DETAILS) TYPE ZHR_TABLE
> *"----
>...
>
> EMPLOYEE_DETAILS = it_employee_detail.
>
>
>
> ENDFUNCTION.
The problem occurs because you've defined EMPLOYEE_DETAILS to be a structure that is like ZHR_TABLE. Not a table. There are two ways of dealing with this.
1. Use the TABLES parameter as Leandro suggested above - although this is obsolete in later versions, it must be used for RFCs.
2. Define a table type in the data dictionary, e.g. ZHR_TABLE_T_TY, which has a line type of ZHR_TABLE. Then you can use
> *" CHANGING
> *" REFERENCE(EMPLOYEE_DETAILS) TYPE ZHR_TABLE_T_TY
3. Use
> *" CHANGING
> *" REFERENCE(EMPLOYEE_DETAILS) TYPE ANY TABLE
I recommend 1 if your function module is RFC enabled, and 2 if it isn't. 3 will work, but it's bad programming!
matt
‎2010 Oct 19 3:12 AM
Hi, Samprithsap,
you have to define a table type for changing parameter emp_det, or you just declare a structure emp_det because here ztable is just refered as a structure.
so, you have to go to se11 and define a table type whose line type is ztable, then use this table type to define emp_det.
in addition, I don't think it's necessary to define changing parameter. If it is, you just need define emp_det as table parameter where you can use ztable directly.
Edited by: Peter Peng on Oct 19, 2010 4:13 AM
‎2010 Oct 19 3:41 AM
‎2010 Oct 19 5:18 AM
i changed changing parameter to table parameter
still same error
FUNCTION Z_TEST_RKM.
*"----
""Local Interface:
*" TABLES
*" EMPDETAIL STRUCTURE zhr_table
*"----
types: begin of ty_str,
MANDT type MANDT,
PERNR type PERSNO,
VORNA type PAD_VORNA,
NACHN type PAD_NACHN,
end of ty_str.
data: it_employee_detail TYPE STANDARD TABLE OF ty_str,
wa_employee_info TYPE ty_str.
select * from ZHR_TABLE into table it_employee_detail.
EMPDETAIL = it_employee_detail.
ENDFUNCTION.
‎2010 Oct 19 5:39 AM
Hi
Does your structure ty_Str contains all the fields of table zhr_table. the structure of ty_str and it_emp_detail is not matching i guess.
You can define your internal table of the same structure of zhr_table and try.
Regards
Sridevi S
‎2010 Oct 19 7:08 AM
If you want all data from ZHR_TABLE into EMPDETAIL parameter of FM
No need to define any structure and another internal table and then assigning
this internal table to FM parameter you can just write below query in your FM logic,
select * from ZHR_TABLE into table EMPDETAIL.
Regards,
Pawan
‎2010 Oct 19 4:06 PM
Hi,
If you already changed to table type then, must be the different structure,
Please check tht both the tables are identical.
Thanks,
Anmol.
‎2010 Oct 19 4:22 PM
Hi,
use
EMPDETAIL[] = it_employee_detail[].to make sure the table body is used regardless of header line presence.
Regards,
Clemens