‎2009 Oct 13 7:37 AM
Hi,
I have a field called status in Module Pool for which i need to write a search help.
This is the piece of code i have written.
TYPES: BEGIN OF ty_status,
stat type i,
status type string,
END OF ty_status.
DATA: lt_emp_status TYPE STANDARD TABLE OF ty_status,
lw_emp_status TYPE ty_status.
REFRESH lt_emp_status.
lw_emp_status-stat = '1'.
lw_emp_status-status = 'Draft'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
lw_emp_status-stat = '2'.
lw_emp_status-status = 'Employee Review'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
REFRESH lt_emp_status.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'STATUS'
value_org = 'S'
TABLES
value_tab = lt_emp_status
return_tab = t_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
READ TABLE t_return INDEX 1.
MOVE t_return-fieldval TO LV_EMP_status.
ENDIF.
But i am getting the following error.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_ASSIGN_CAST_ILLEGAL_CAST', was
not caught in
procedure "F4IF_INT_TABLE_VALUE_REQUEST" "(FUNCTION)", nor was it propagated by
a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
The error occurred at a statement of the form
ASSIGN f TO <fs> CASTING.
ASSIGN f TO <fs> CASTING TYPE t.
or
ASSIGN f TO <fs> CASTING LIKE f1.
or
at table statements with the addition
ASSIGNING <fs> CASTING.
The following error causes are possible:
1. The type of field f or the target type determined by <fs>, t or f1
contains data references, object references, strings or internal tables
as components.
Could some one help me how to resolve this issue.
Thanks in advance.
‎2009 Oct 13 7:44 AM
Hi,
Try this code
TYPES: BEGIN OF ty_status,
stat type i,
status(20) type c,
END OF ty_status.
DATA: lt_emp_status TYPE STANDARD TABLE OF ty_status,
lw_emp_status TYPE ty_status.
REFRESH lt_emp_status.
lw_emp_status-stat = '1'.
lw_emp_status-status = 'Draft'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
lw_emp_status-stat = '2'.
lw_emp_status-status = 'Employee Review'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
*REFRESH lt_emp_status.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'STATUS'
value_org = 'S'
TABLES
value_tab = lt_emp_status
return_tab = t_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc = 0.
READ TABLE t_return INDEX 1.
MOVE t_return-fieldval TO LV_EMP_status.
ENDIF.
Regards,
Shankar
‎2009 Oct 13 7:46 AM
REFRESH lt_emp_status. "==============> why this????? remove it
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
‎2009 Oct 13 7:48 AM
Hi Karthik,
I dont think there is any issue with the refresh statement. I would suggest you to Debug this portion of code to find out where exactly you get this dump. In that way it helps you identify the issue and correct it.
Best Regards,
Ram.
‎2009 Oct 13 7:52 AM
ram,
>DATA: lt_emp_status TYPE STANDARD TABLE OF ty_status,
the table is without header line...
he is refreshing the table,means data is gone.. memory are is gone...
then he is passing this to the FM
‎2009 Oct 13 7:54 AM
Hi,
If you define a table as TYPE STANDARD TABLE OF - it declares a table with header line.
But, i agree that after filling the internal table, he is refreshing it which is wrong. I didnot see that earlier
Best Regards,
Ram.
Edited by: ram Kumar on Oct 13, 2009 12:25 PM
‎2009 Oct 13 8:00 AM
Hi,
Please see this sample code below:
*To fetch the classification data on the sel screen
DATA: BEGIN OF IT_KLAH OCCURS 0,
CLINT TYPE CLINT,
CLASS TYPE KLASSE_D,
END OF IT_KLAH.
SELECT CLINT CLASS FROM KLAH UP TO 500 ROWS
INTO TABLE IT_KLAH.
IF SY-SUBRC <> 0 .
MESSAGE TEXT-006 TYPE 'E'.
ELSE.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
DDIC_STRUCTURE = ' '
RETFIELD = 'CLASS'
PVALKEY = ' '
DYNPPROG = SY-REPID
DYNPNR = SY-DYNNR
DYNPROFIELD = 'p_s_clascn_low' "i had to put the f4 help on the selection screen's select option low value,
"here basically you have to give the internal table name inside quotes in which
"you want to retrieve your data
VALUE_ORG = 'S'
DISPLAY = ' '
TABLES
VALUE_TAB = IT_KLAH.
ENDIF.
Hope it helps,
Regards,
Mansi
‎2009 Oct 13 8:03 AM
‎2009 Oct 13 8:15 AM
Hi,
<li>I have made some change to your program to work in Report program. The problem is coming because of the STATUS field in the TY_STATUS types.
<li>Commented REFRESH statement.
Thanks
Venkat.O
REPORT ztest.
PARAMETERS:p_status TYPE string.
types: BEGIN OF ty_status,
stat TYPE i,
* status TYPE string "If status refers to String, It becomes Deep structure.
status TYPE char100, "That is why it is giving dump. I just changed. It works.
END OF ty_status.
*
DATA: lt_emp_status TYPE TABLE OF ty_status,
lw_emp_status TYPE ty_status.
DATA:t_return TYPE ddshretval OCCURS 0.
DATA:w_return LIKE LINE OF t_return.
*REFRESH lt_emp_status.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_status.
lw_emp_status-stat = '1'.
lw_emp_status-status = 'Draft'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
lw_emp_status-stat = '2'.
lw_emp_status-status = 'Employee Review'.
APPEND lw_emp_status TO lt_emp_status.
CLEAR lw_emp_status.
*REFRESH lt_emp_status.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'STATUS'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_STATUS'
value_org = 'S'
TABLES
value_tab = lt_emp_status
return_tab = t_return.
IF sy-subrc = 0.
READ TABLE t_return INTO w_return INDEX 1.
MOVE w_return-fieldval TO p_status.
ENDIF.
‎2009 Oct 13 8:34 AM
Hi,
You are right. The type string does not work here.
Now its working.
Thanks to all for helping me.
‎2009 Oct 13 8:35 AM
The type string does not work. Thats why the Function Module was throwing dump.