‎2008 Jan 18 10:59 AM
Hi.
In my alv report am getting dump
The current statement is defined for character-type data objects only.
Please look at this code and help me to solve this problem.
Please tell me whats wrong in my program.
i wann to display chick box in output, how to do this.
REPORT zpr_test03 no standard page heading.
DATA: BEGIN OF itab OCCURS 0,
ecod TYPE zemp2-ecod,
name TYPE zemp2-name,
divn TYPE zemp2-divn,
END OF itab.
TYPE-POOLS: slis.
TABLES:zemp2.
DATA:alv_field TYPE slis_t_fieldcat_alv,
alv_layout type slis_layout_alv.
SELECT-OPTIONS: ecode FOR zemp2-ecod.
SELECT * FROM zemp2 INTO CORRESPONDING FIELDS OF TABLE itab
WHERE ecod IN ecode.
perform alv_layout.
PERFORM alv_init.
PERFORM alv_disply.
form alv_layout.
alv_layout-box_fieldname = 'BOX'.
endform.
&----
*& Form alv_init
&----
text
----
FORM alv_init.
DATA : alv_field1 TYPE slis_fieldcat_alv.
alv_field1-fieldname = 'ECOD'.
alv_field1-tabname = 'ITAB'.
alv_field1-seltext_l = 'Employee Code'.
alv_field1-key = 'X'.
alv_field1-checkbox = 'X'.
APPEND alv_field1 TO alv_field .
clear alv_field1-key.
alv_field1-fieldname = 'NAME'.
alv_field1-tabname = 'ITAB'.
alv_field1-seltext_l = 'Employee name'.
APPEND alv_field1 TO alv_field.
alv_field1-fieldname = 'DIVN'.
alv_field1-tabname = 'ITAB'.
alv_field1-seltext_l = 'Division'.
APPEND alv_field1 TO alv_field.
ENDFORM. "alv_init
&----
*& Form alv_disply
&----
text
----
FORM alv_disply.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = 'X'
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = ''
I_BACKGROUND_ID = ' '
i_grid_title = 'My first program'
I_GRID_SETTINGS =
IS_LAYOUT = alv_layout
it_fieldcat = alv_field
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "alv_disply
Regards
Prajwal K.
Edited by: prajwal k on Jan 18, 2008 12:00 PM
‎2008 Jan 18 11:43 AM
hi,
this will help you for check box display....
REPORT YMS_CHECKBOXALV.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
-
FORM SET_PF_STATUS *
-
........ *
-
--> EXTAB *
-
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
-
FORM user_command *
-
........ *
-
--> UCOMM *
--> SELFIELD *
-
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DETAIL'.
LOOP AT itab WHERE box = 'X'.
itab-icon = '@08@'.
MODIFY itab TRANSPORTING icon.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
regards,
karthik.
‎2008 Jan 18 11:08 AM
Hi Prajwal,
Can you send me the place it is giving the dump. If possible attach the screen shot.
Regards
Pavan
‎2008 Jan 18 11:17 AM
013780 * is there a complex color table defined ?
013790 if not rs_layout-ctab_fname is initial.
013800 clear g_style_color.
013810 perform field_color_complex using <coltab>
013820 <ls_fieldcat>
013830 g_style_color.
013840 if not g_style_color is initial.
013850 gs_lvc_data-style = g_style_color.
013860 endif.
013870 endif.
013880 * is a complex style defined ?
013890 if not rs_layout-stylefname is initial.
013900 read table <gt_style> into gs_style
013910 with key fieldname = <ls_fieldcat>-fieldname.
013920 if sy-subrc = 0.
013930 gs_lvc_data-style = gs_lvc_data-style + gs_style-style.
013940 gs_lvc_data-style2 = gs_lvc_data-style2 + gs_style-style2.
013950 gs_lvc_data-style3 = gs_lvc_data-style3 + gs_style-style3.
013960 gs_lvc_data-style4 = gs_lvc_data-style4 + gs_style-style4.
013970 gs_lvc_data-maxlen = gs_style-maxlen.
013980 endif.
013990 endif.
014000 * deactivate hotspot when field is initial
014010 if <ls_fieldcat>-hotspot = 'V' and
014020 gs_lvc_data-value is initial.
014030 add alv_style_single_clk_event_no to gs_lvc_data-style.
014040 endif.
014050 * set sytle for a checkbox/radiobutton
014060 if <ls_fieldcat>-checkbox = 'X'.
*> if <gfield> ca '01'.*_
014080 add alv_style_enabled to gs_lvc_data-style.
014090 else.
014100 * add alv_style_disabled to gs_lvc_data-style.
here is that code which i got from st22.
‎2008 Jan 18 11:27 AM
Hi,
Reply from sunil seems to be the answer for your query. Check the field length to be 1 character for the checkbox field.
Regards
Pavan
‎2008 Jan 18 11:12 AM
Hi Prajwal,
if you want to display the output field as check box just chek the type of field it is.
i.e For any field to display as check box the field must be of type CHAR ( charcter field) with only 1 chac.
ex: parameter: CHK type c as check box.
here CHK is of single character of type C.
you are using here
<b>ecod TYPE zemp2-ecod</b> in your internal table. check whether zemp2-ecod is of char type or not and not only it should be of single charcter only then it can be used as check box.
Hope this will give u idea......
<b>please reward if useful </b>.
regards,
sunil kairam.
‎2008 Jan 18 11:43 AM
hi,
this will help you for check box display....
REPORT YMS_CHECKBOXALV.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF itab OCCURS 0,
icon TYPE icon-id,
vbeln TYPE vbeln,
kunnr TYPE kunnr,
erdat TYPE erdat,
box TYPE c,
END OF itab.
DATA: v_repid TYPE syrepid.
START-OF-SELECTION.
Get the data.
SELECT vbeln kunnr erdat UP TO 100 ROWS
FROM vbak
INTO CORRESPONDING FIELDS OF TABLE itab.
IF sy-subrc 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
Modify the record with red light.
itab-icon = '@0A@'.
MODIFY itab TRANSPORTING icon WHERE NOT vbeln IS initial.
v_repid = sy-repid.
Get the field catalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'ICON'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-seltext_l = 'Status'.
s_fieldcatalog-icon = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'KUNNR'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'KUNNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'ERDAT'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'ERDAT'.
APPEND s_fieldcatalog TO t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = itab.
-
FORM SET_PF_STATUS *
-
........ *
-
--> EXTAB *
-
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
-
FORM user_command *
-
........ *
-
--> UCOMM *
--> SELFIELD *
-
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DETAIL'.
LOOP AT itab WHERE box = 'X'.
itab-icon = '@08@'.
MODIFY itab TRANSPORTING icon.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
regards,
karthik.
‎2008 Jan 19 4:36 AM