2007 Sep 05 10:55 AM
hi experts
how to set the trafic light(red,yellow,green) for a particular field based on condition.
Pls, give me sample code also.
Thanks in advance.
Regards
Rajaram
2007 Sep 05 11:02 AM
Hi,
check the samplecode.
REPORT ZTEST MESSAGE-ID Z8.
TYPE-POOLS:SLIS.
TABLES: MARA, MAKT.
*AS per the req the internal table sud consist of check box, lights, material no, icon ,material desc,
editable basic text box.
data : BEGIN OF itab1 occurs 0,
v_TEXT(60) type c,
v_lights(2) type c,
v_box(1) type c,
v_icon(4) type c,
MATNR type MATNR,
MAKTX type MAKTX,
text type tdline,
END OF itab1.
DATA: BEGIN OF itab2 occurs 0 ,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
TEXT_1 TYPE TDLINE,
END OF ITAB2.
DATA: S_NAME TYPE THEAD-TDNAME.
data: wa type tline.
data: wa1(55).
data: v_progname type sy-repid.
data: v_gridtitle type lvc_title.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
parameters: p_var like disvariant-variant.
FOR USER-DEFINED AND GENERAL LIST VARIANTS.
data: i_variant like disvariant.
*DATA DECLARATION FOR THE CATALOGS
data: i_fieldcat type slis_t_fieldcat_alv.
*DATA DECLARATION FOR THE 2ND CATALOGS
data: i_fC_DISPLAY type slis_t_fieldcat_alv.
FOR LAYOUT
data: i_layout type slis_layout_alv.
FOR THE EVENT CATALOG.
data: i_eventcat type slis_t_event.
FOR THE TOP OF PAGE EVENT
data: i_listheader type slis_t_listheader.
FOR THE INTERNAL TABLE CONTAINING LONGTEXT
DATA: IT_LINES TYPE TLINE OCCURS 0 WITH HEADER LINE.
************************************************************************
INITIALIZATION EVENT *
************************************************************************
*to perform screen validations..........
at selection-screen.
perform sel_validations.
initialization.
v_progname = sy-repid.
DISPLAY DEFAULT VARIANT
perform default_variant.
************************************************************************
START OF SELECTION EVENT *
************************************************************************
start-of-selection.
perform zf_build_fieldcat using i_fieldcat.
perform DISPLAY using i_fC_DISPLAY.
perform SELECT_TABLE.
perform modify_MARA.
perform layout_itab1.
perform zf_build_eventcat using i_eventcat.
perform zf_build_listheader using i_listheader.
perform grid_title.
.
perform display_alv_grid.
&----
*& Form zf_check_var_exist
&----
text
----
--> p1 text
<-- p2 text
----
form zf_check_var_exist .
data: l_variant like disvariant.
if not p_var is initial.
clear l_variant.
l_variant-report = v_progname.
l_variant-variant = p_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
cs_variant = L_VARIANT
EXCEPTIONS
WRONG_INPUT = 1
NOT_FOUND = 2
PROGRAM_ERROR = 3
OTHERS = 4
.
IF sy-subrc = 0.
clear i_variant.
move l_variant-variant to i_variant-variant.
move l_variant-report to i_variant-report.
ELSE.
*
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
endform. " zf_check_var_exist
&----
*& Form zf_build_fieldcat
&----
text
----
-->P_I_FIELDCAT text
----
form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv.
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_box'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'Itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-emphasize = 'C410'. " COLOR OF THIS COLUMN.
l_fieldcat-seltext_l = 'check-box'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'box'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'box'. " SHORT TEXT FOR HEADER.
l_fieldcat-CHECKBOX = 'X'.
l_fieldcat-edit = 'X'.
l_fieldcat-outputlen = 2.
" TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
*V_LIGHTS(1) TYPE C. " FOR TRAFFIC LIGHTS.
clear l_fieldcat.
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_LIGHTS'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'Itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-emphasize = 'C410'. " COLOR OF THIS COLUMN.
l_fieldcat-seltext_l = 'LIGHT-BOX'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'L-BOX'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'L.B.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 7. " TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
I_MARA-MATNR. MATERIAL NUMBER
clear l_fieldcat.
l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL Number'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL No.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.N.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MARA'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_fieldcat.
itab1-V_ICON.
clear l_fieldcat.
l_fieldcat-col_pos = '4'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_ICON'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Icon'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-icon = 'X'. " AS ICON.
append l_fieldcat to p_i_fieldcat.
MAKT-MAKTX
clear l_fieldcat.
l_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL DESC.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.D.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_fieldcat.
itab11-TEXT.
clear l_fieldcat.
l_fieldcat-col_pos = '6'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'TEXT'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Basic Text'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-EDIT = 'X'. " AS SYMBOL.
l_fieldcat-seltext_l = 'BASIC TEXT'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'B.TEXT.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'B.T.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40.
append l_fieldcat to p_i_fieldcat.
endform. " zf_build_fieldcat
&----
*& Form SELECT_TABLE
&----
text
----
--> p1 text
<-- p2 text
----
form SELECT_TABLE .
Select matnr into itab1-matnr from mara where matnr in s_matnr.
append itab1.
endselect.
loop at itab1.
select single maktx into itab1-maktx from makt where matnr = itab1-matnr.
modify itab1.
endloop.
*
*SELECT MARAMATNR MAKTMAKTX INTO CORRESPONDING FIELDS OF TABLE itab1 FROM MARA INNER JOIN MAKT ON MARAMATNR = MAKTMATNR
*WHERE MARA~MATNR IN S_MATNR.
IF SY-SUBRC <> 0.
MESSAGE E001.
endif.
sort itab1 by matnr.
endform. " SELECT_TABLE
&----
*& Form modify_MARA
&----
text
----
--> p1 text
<-- p2 text
----
form modify_MARA .
loop at itab1.
S_NAME = itab1-MATNR.
REFRESH IT_LINES.
CLEAR IT_LINES.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
id = 'GRUN'
language = 'E'
name = S_NAME
object = 'MATERIAL'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
tables
lines = IT_LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*
endif.
*
if iTAB1-MATNR < '10'.
iTAB1-v_lights = '3'.
modify iTAB1 transporting v_lights.
ENDIF.
if iTAB1-MATNR > '50'.
iTAB1-v_lights = '2'.
modify iTAB1 transporting v_lights.
ENDIF.
*
*if ITAB1-MATNR = '000000000000000001'.
*
itab1-v_LIGHTS = '1'.
modify itab1 transporting v_LIGHTS.
endif.
*
*READ TABLE IT_LINES into wa.
*
*here the longtext maybe of more than 1 line, so we concatenate a temporary field by looping at the it_lines
*and then getting the whole long text into that variable.
*endloop.
loop at it_lines.
concatenate wa1 it_lines-tdline into wa1.
endloop.
itab1-text = wa1.
modify itab1.
clear wa1.
*no longtext, so red color
IF ITab1-text = ''.
itab1-v_lights = '1'.
modify itab1 transporting v_LIGHTS.
*for longtext with starting word important, green color
elseIF ITab1-text(9) = 'IMPORTANT' or itab1-text(9) = 'important'.
itab1-v_lights = '3'.
modify itab1 transporting v_LIGHTS.
*for any other longtext , yellow color.
else. itab1-v_lights = '2'.
modify itab1 transporting v_LIGHTS.
ENDIF.
endloop.
LOOP AT itab1.
if itab1-matnr < '000000000000000036'.
itab1-v_icon = '@1V@'.
modify itab1 transporting v_icon.
endif.
IF ITAB1-MATNR = '000000000000000001'.
itab1-v_icon = '@4V@'.
modify itab1 transporting v_icon.
endif.
if itab1-matnr > '000000000000000050'.
itab1-v_icon = '@7V@'.
modify itab1 transporting v_icon.
endif.
endloop.
endform. " modify_MARA
&----
*& Form sel_validations
&----
text
----
--> p1 text
<-- p2 text
----
form sel_validations .
select matnr into corresponding fields of itab1 from mara where matnr in s_matnr.
exit.
endselect.
if sy-subrc <> 0.
message e001.
endif.
endform. " sel_validations
&----
*& Form grid_title
&----
text
----
--> p1 text
<-- p2 text
----
form grid_title .
v_gridtitle = 'LIST OF MATERIALS WITH DESCRIPTIONS AND BASIC TEXT.'.
endform. " grid_title
&----
*& Form display_alv_grid
&----
text
----
--> p1 text
<-- p2 text
----
form display_alv_grid .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'Z8SAPNA_ALV_REQ1'
I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME = 'itab1'
I_BACKGROUND_ID = ' '
I_GRID_TITLE = v_gridtitle
I_GRID_SETTINGS =
IS_LAYOUT = i_layout
IT_FIELDCAT = i_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = i_variant
IT_EVENTS = i_eventcat
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 = itab1
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. " display_alv_grid
&----
&----
*& Form layout_itab1
&----
text
----
--> p1 text
<-- p2 text
----
form layout_itab1 .
i_layout-zebra = 'X'.
i_layout-totals_text = 'Total'(a00).
*
i_layout-subtotals_text = 'SubTotal'(a01).
i_layout-lights_fieldname = 'V_LIGHTS'.
i_layout-lights_tabname = 'itab1'.
i_layout-box_fieldname = 'V_BOX'.
i_layout-box_tabname = 'itab1'.
i_layout-edit = 'x'.
endform. " layout_itab1
&----
*& Form default_variant
&----
text
----
--> p1 text
<-- p2 text
----
form default_variant .
i_variant-report = v_progname.
PROVIDES THE DEFAULT VARIANT FOR THE LIST SPECIFIED IN THE STRUCTURE CS_VARIANT
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = 'A' " 'A' , 'X', 'U', ' '
changing
cs_variant = i_variant
exceptions
wrong_input = 1
not_found = 2
program_error = 3
others = 4.
if sy-subrc = 0.
p_var = i_variant-variant.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " ZF_DEFAULT_VARIANT
&----
*& Form TOP-OF-PAGE
&----
text
----
--> p1 text
<-- p2 text
----
form ZF_TOP_OF_PAGE.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_listheader
i_logo = 'ENJOYSAP_LOGO'.
endform. " TOP-OF-PAGE
&----
*& Form zf_build_listheader
&----
text
----
-->P_I_LISTHEADER text
----
form zf_build_listheader using p_i_listheader type slis_t_listheader.
data: l_listheader type slis_listheader.
refresh p_i_listheader.
clear l_listheader.
l_listheader-typ = 'H'.
l_listheader-info = text-001.
append l_listheader to p_i_listheader.
endform. " zf_build_listheader
&----
*& ZF_PF_STATUS
&----
form zf_pf_status using p_extab type slis_t_extab.
set pf-status 'MENU1'.
endform. " PF_STATUS
&----
*& ZF_USER_COMMAND
&----
form ZF_user_command using p_ucomm type sy-ucomm
p_selfield type slis_selfield.
case p_ucomm.
WHEN 'IC1'.
WHEN '&DISP'.
LOOP AT ITAB1 WHERE V_BOX = 'X'.
ITAB2-MATNR = ITAB1-MATNR.
ITAB2-MAKTX = ITAB1-MAKTX.
ITAB2-TEXT_1 = ITAB1-TEXT.
APPEND ITAB2.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'z8sapna_alv_req1'
I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'itab2'
IS_LAYOUT =
IT_FIELDCAT = i_fc_display
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_eventcat
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 1
I_SCREEN_START_LINE = 1
I_SCREEN_END_COLUMN = 150
I_SCREEN_END_LINE = 150
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab2
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.
when '&UPDAT'.
LOOP AT ITAB1 WHERE V_BOX = 'X'.
when others.
if p_selfield-fieldname = 'MATNR' .
message i034 with p_selfield-value.
endif.
endloop.
endcase.
endform. " ZF_USER_COMMAND
&----
*& Form zf_build_eventcat
&----
text
----
-->P_I_EVENTCAT text
----
form zf_build_eventcat using p_i_eventcat TYPE slis_t_event.
data: l_event type slis_alv_event.
GET ALL THE EVENTS.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_i_eventcat
exceptions
list_type_wrong = 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.
clear l_event.
read table p_i_eventcat with key name = slis_ev_top_of_page into l_event.
if sy-subrc = 0.
move 'ZF_TOP_OF_PAGE' to l_event-form.
append l_event to p_i_eventcat.
endif.
clear l_event.
read table p_i_eventcat with key name = slis_ev_user_command into l_event.
if sy-subrc = 0.
move 'ZF_USER_COMMAND' to l_event-form.
append l_event to p_i_eventcat.
endif.
clear l_event.
read table p_i_eventcat with key name = slis_ev_pf_status_set into l_event.
if sy-subrc = 0.
move 'ZF_PF_STATUS'(002) to l_event-form.
append l_event to p_i_eventcat.
endif.
endform. " zf_build_eventcat
&----
*& Form i_fC_DISPLAY
&----
*& Form DISPLAY
&----
text
----
-->P_I_FC_DISPLAY text
----
form DISPLAY using p_i_fc_display TYPE slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv.
I_MARA-MATNR. MATERIAL NUMBER
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL Number'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL No.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.N.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MARA'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_FC_DISPLAY.
MAKT-MAKTX
clear l_fieldcat.
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL DESC.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.D.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_FC_DISPLAY.
itab11-TEXT.
clear l_fieldcat.
l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'TEXT_1'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Basic Text'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-EDIT = 'X'. " AS SYMBOL.
l_fieldcat-seltext_l = 'BASIC TEXT'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'B.TEXT.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'B.T.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40.
append l_fieldcat to p_i_FC_DISPLAY.
endform. " DISPLAY
ONE more program.
TYPE-POOLS : slis.
DATA : alvly TYPE slis_layout_alv.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : BEGIN OF itab OCCURS 0,
lt TYPE i,
matnr LIKE mara-matnr,
END OF itab.
END-OF-SELECTION.
itab-lt = 1.
APPEND itab.
itab-lt = 2.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 1.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.
alvly-lights_fieldname = 'LT'.
alvly-lights_tabname = 'ITAB'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = alvfc
is_layout = alvly
i_save = 'A'
TABLES
t_outtab = itab.
reward points if u find useful
Regards,
nagaraj
2007 Sep 05 11:00 AM
Hi,
Check the following program:
<b>BCALV_GRID_04</b> Illustrates the use of exceptions (lights or leds). According to the values of SFLIGHT-SEATSOCC, the lights are set to 1 (red), 2 (yellow) or 3 (green).
Hope this helps.
Reward if helpful.
Regards,
Sipra
2007 Sep 05 11:00 AM
you need to include the <icon> file in your program...
include <icon>.
and for traffic light you can use icon_green_light, icon_red_light and icon_yellow_light values for the respective icons...or alternatively use
@08@
@09@
@10@
needless to say....you need to have the AS ICON addition
include <icon> .
data str type string.
str = '@08@'.
write str as icon.
2007 Sep 05 11:51 AM
hi all
i am not getting clearly, pls explain step by step.
thanks
Regards
Rajaram
2007 Sep 05 11:02 AM
Hi,
check the samplecode.
REPORT ZTEST MESSAGE-ID Z8.
TYPE-POOLS:SLIS.
TABLES: MARA, MAKT.
*AS per the req the internal table sud consist of check box, lights, material no, icon ,material desc,
editable basic text box.
data : BEGIN OF itab1 occurs 0,
v_TEXT(60) type c,
v_lights(2) type c,
v_box(1) type c,
v_icon(4) type c,
MATNR type MATNR,
MAKTX type MAKTX,
text type tdline,
END OF itab1.
DATA: BEGIN OF itab2 occurs 0 ,
MATNR TYPE MATNR,
MAKTX TYPE MAKTX,
TEXT_1 TYPE TDLINE,
END OF ITAB2.
DATA: S_NAME TYPE THEAD-TDNAME.
data: wa type tline.
data: wa1(55).
data: v_progname type sy-repid.
data: v_gridtitle type lvc_title.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
parameters: p_var like disvariant-variant.
FOR USER-DEFINED AND GENERAL LIST VARIANTS.
data: i_variant like disvariant.
*DATA DECLARATION FOR THE CATALOGS
data: i_fieldcat type slis_t_fieldcat_alv.
*DATA DECLARATION FOR THE 2ND CATALOGS
data: i_fC_DISPLAY type slis_t_fieldcat_alv.
FOR LAYOUT
data: i_layout type slis_layout_alv.
FOR THE EVENT CATALOG.
data: i_eventcat type slis_t_event.
FOR THE TOP OF PAGE EVENT
data: i_listheader type slis_t_listheader.
FOR THE INTERNAL TABLE CONTAINING LONGTEXT
DATA: IT_LINES TYPE TLINE OCCURS 0 WITH HEADER LINE.
************************************************************************
INITIALIZATION EVENT *
************************************************************************
*to perform screen validations..........
at selection-screen.
perform sel_validations.
initialization.
v_progname = sy-repid.
DISPLAY DEFAULT VARIANT
perform default_variant.
************************************************************************
START OF SELECTION EVENT *
************************************************************************
start-of-selection.
perform zf_build_fieldcat using i_fieldcat.
perform DISPLAY using i_fC_DISPLAY.
perform SELECT_TABLE.
perform modify_MARA.
perform layout_itab1.
perform zf_build_eventcat using i_eventcat.
perform zf_build_listheader using i_listheader.
perform grid_title.
.
perform display_alv_grid.
&----
*& Form zf_check_var_exist
&----
text
----
--> p1 text
<-- p2 text
----
form zf_check_var_exist .
data: l_variant like disvariant.
if not p_var is initial.
clear l_variant.
l_variant-report = v_progname.
l_variant-variant = p_var.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
I_SAVE = 'A'
CHANGING
cs_variant = L_VARIANT
EXCEPTIONS
WRONG_INPUT = 1
NOT_FOUND = 2
PROGRAM_ERROR = 3
OTHERS = 4
.
IF sy-subrc = 0.
clear i_variant.
move l_variant-variant to i_variant-variant.
move l_variant-report to i_variant-report.
ELSE.
*
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
endform. " zf_check_var_exist
&----
*& Form zf_build_fieldcat
&----
text
----
-->P_I_FIELDCAT text
----
form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv.
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_box'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'Itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-emphasize = 'C410'. " COLOR OF THIS COLUMN.
l_fieldcat-seltext_l = 'check-box'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'box'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'box'. " SHORT TEXT FOR HEADER.
l_fieldcat-CHECKBOX = 'X'.
l_fieldcat-edit = 'X'.
l_fieldcat-outputlen = 2.
" TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
*V_LIGHTS(1) TYPE C. " FOR TRAFFIC LIGHTS.
clear l_fieldcat.
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_LIGHTS'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'Itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-emphasize = 'C410'. " COLOR OF THIS COLUMN.
l_fieldcat-seltext_l = 'LIGHT-BOX'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'L-BOX'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'L.B.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 7. " TO DEFINE OUTPUT LENGTH OF THE COLUMN.
append l_fieldcat to p_i_fieldcat.
I_MARA-MATNR. MATERIAL NUMBER
clear l_fieldcat.
l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL Number'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL No.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.N.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MARA'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_fieldcat.
itab1-V_ICON.
clear l_fieldcat.
l_fieldcat-col_pos = '4'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'V_ICON'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Icon'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-icon = 'X'. " AS ICON.
append l_fieldcat to p_i_fieldcat.
MAKT-MAKTX
clear l_fieldcat.
l_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL DESC.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.D.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_fieldcat.
itab11-TEXT.
clear l_fieldcat.
l_fieldcat-col_pos = '6'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'TEXT'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB1'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Basic Text'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-EDIT = 'X'. " AS SYMBOL.
l_fieldcat-seltext_l = 'BASIC TEXT'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'B.TEXT.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'B.T.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40.
append l_fieldcat to p_i_fieldcat.
endform. " zf_build_fieldcat
&----
*& Form SELECT_TABLE
&----
text
----
--> p1 text
<-- p2 text
----
form SELECT_TABLE .
Select matnr into itab1-matnr from mara where matnr in s_matnr.
append itab1.
endselect.
loop at itab1.
select single maktx into itab1-maktx from makt where matnr = itab1-matnr.
modify itab1.
endloop.
*
*SELECT MARAMATNR MAKTMAKTX INTO CORRESPONDING FIELDS OF TABLE itab1 FROM MARA INNER JOIN MAKT ON MARAMATNR = MAKTMATNR
*WHERE MARA~MATNR IN S_MATNR.
IF SY-SUBRC <> 0.
MESSAGE E001.
endif.
sort itab1 by matnr.
endform. " SELECT_TABLE
&----
*& Form modify_MARA
&----
text
----
--> p1 text
<-- p2 text
----
form modify_MARA .
loop at itab1.
S_NAME = itab1-MATNR.
REFRESH IT_LINES.
CLEAR IT_LINES.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
id = 'GRUN'
language = 'E'
name = S_NAME
object = 'MATERIAL'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
tables
lines = IT_LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*
endif.
*
if iTAB1-MATNR < '10'.
iTAB1-v_lights = '3'.
modify iTAB1 transporting v_lights.
ENDIF.
if iTAB1-MATNR > '50'.
iTAB1-v_lights = '2'.
modify iTAB1 transporting v_lights.
ENDIF.
*
*if ITAB1-MATNR = '000000000000000001'.
*
itab1-v_LIGHTS = '1'.
modify itab1 transporting v_LIGHTS.
endif.
*
*READ TABLE IT_LINES into wa.
*
*here the longtext maybe of more than 1 line, so we concatenate a temporary field by looping at the it_lines
*and then getting the whole long text into that variable.
*endloop.
loop at it_lines.
concatenate wa1 it_lines-tdline into wa1.
endloop.
itab1-text = wa1.
modify itab1.
clear wa1.
*no longtext, so red color
IF ITab1-text = ''.
itab1-v_lights = '1'.
modify itab1 transporting v_LIGHTS.
*for longtext with starting word important, green color
elseIF ITab1-text(9) = 'IMPORTANT' or itab1-text(9) = 'important'.
itab1-v_lights = '3'.
modify itab1 transporting v_LIGHTS.
*for any other longtext , yellow color.
else. itab1-v_lights = '2'.
modify itab1 transporting v_LIGHTS.
ENDIF.
endloop.
LOOP AT itab1.
if itab1-matnr < '000000000000000036'.
itab1-v_icon = '@1V@'.
modify itab1 transporting v_icon.
endif.
IF ITAB1-MATNR = '000000000000000001'.
itab1-v_icon = '@4V@'.
modify itab1 transporting v_icon.
endif.
if itab1-matnr > '000000000000000050'.
itab1-v_icon = '@7V@'.
modify itab1 transporting v_icon.
endif.
endloop.
endform. " modify_MARA
&----
*& Form sel_validations
&----
text
----
--> p1 text
<-- p2 text
----
form sel_validations .
select matnr into corresponding fields of itab1 from mara where matnr in s_matnr.
exit.
endselect.
if sy-subrc <> 0.
message e001.
endif.
endform. " sel_validations
&----
*& Form grid_title
&----
text
----
--> p1 text
<-- p2 text
----
form grid_title .
v_gridtitle = 'LIST OF MATERIALS WITH DESCRIPTIONS AND BASIC TEXT.'.
endform. " grid_title
&----
*& Form display_alv_grid
&----
text
----
--> p1 text
<-- p2 text
----
form display_alv_grid .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'Z8SAPNA_ALV_REQ1'
I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME = 'itab1'
I_BACKGROUND_ID = ' '
I_GRID_TITLE = v_gridtitle
I_GRID_SETTINGS =
IS_LAYOUT = i_layout
IT_FIELDCAT = i_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = i_variant
IT_EVENTS = i_eventcat
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 = itab1
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. " display_alv_grid
&----
&----
*& Form layout_itab1
&----
text
----
--> p1 text
<-- p2 text
----
form layout_itab1 .
i_layout-zebra = 'X'.
i_layout-totals_text = 'Total'(a00).
*
i_layout-subtotals_text = 'SubTotal'(a01).
i_layout-lights_fieldname = 'V_LIGHTS'.
i_layout-lights_tabname = 'itab1'.
i_layout-box_fieldname = 'V_BOX'.
i_layout-box_tabname = 'itab1'.
i_layout-edit = 'x'.
endform. " layout_itab1
&----
*& Form default_variant
&----
text
----
--> p1 text
<-- p2 text
----
form default_variant .
i_variant-report = v_progname.
PROVIDES THE DEFAULT VARIANT FOR THE LIST SPECIFIED IN THE STRUCTURE CS_VARIANT
call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
exporting
i_save = 'A' " 'A' , 'X', 'U', ' '
changing
cs_variant = i_variant
exceptions
wrong_input = 1
not_found = 2
program_error = 3
others = 4.
if sy-subrc = 0.
p_var = i_variant-variant.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " ZF_DEFAULT_VARIANT
&----
*& Form TOP-OF-PAGE
&----
text
----
--> p1 text
<-- p2 text
----
form ZF_TOP_OF_PAGE.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = i_listheader
i_logo = 'ENJOYSAP_LOGO'.
endform. " TOP-OF-PAGE
&----
*& Form zf_build_listheader
&----
text
----
-->P_I_LISTHEADER text
----
form zf_build_listheader using p_i_listheader type slis_t_listheader.
data: l_listheader type slis_listheader.
refresh p_i_listheader.
clear l_listheader.
l_listheader-typ = 'H'.
l_listheader-info = text-001.
append l_listheader to p_i_listheader.
endform. " zf_build_listheader
&----
*& ZF_PF_STATUS
&----
form zf_pf_status using p_extab type slis_t_extab.
set pf-status 'MENU1'.
endform. " PF_STATUS
&----
*& ZF_USER_COMMAND
&----
form ZF_user_command using p_ucomm type sy-ucomm
p_selfield type slis_selfield.
case p_ucomm.
WHEN 'IC1'.
WHEN '&DISP'.
LOOP AT ITAB1 WHERE V_BOX = 'X'.
ITAB2-MATNR = ITAB1-MATNR.
ITAB2-MAKTX = ITAB1-MAKTX.
ITAB2-TEXT_1 = ITAB1-TEXT.
APPEND ITAB2.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'z8sapna_alv_req1'
I_CALLBACK_PF_STATUS_SET = 'ZF_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_STRUCTURE_NAME = 'itab2'
IS_LAYOUT =
IT_FIELDCAT = i_fc_display
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = i_eventcat
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 1
I_SCREEN_START_LINE = 1
I_SCREEN_END_COLUMN = 150
I_SCREEN_END_LINE = 150
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = itab2
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.
when '&UPDAT'.
LOOP AT ITAB1 WHERE V_BOX = 'X'.
when others.
if p_selfield-fieldname = 'MATNR' .
message i034 with p_selfield-value.
endif.
endloop.
endcase.
endform. " ZF_USER_COMMAND
&----
*& Form zf_build_eventcat
&----
text
----
-->P_I_EVENTCAT text
----
form zf_build_eventcat using p_i_eventcat TYPE slis_t_event.
data: l_event type slis_alv_event.
GET ALL THE EVENTS.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = p_i_eventcat
exceptions
list_type_wrong = 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.
clear l_event.
read table p_i_eventcat with key name = slis_ev_top_of_page into l_event.
if sy-subrc = 0.
move 'ZF_TOP_OF_PAGE' to l_event-form.
append l_event to p_i_eventcat.
endif.
clear l_event.
read table p_i_eventcat with key name = slis_ev_user_command into l_event.
if sy-subrc = 0.
move 'ZF_USER_COMMAND' to l_event-form.
append l_event to p_i_eventcat.
endif.
clear l_event.
read table p_i_eventcat with key name = slis_ev_pf_status_set into l_event.
if sy-subrc = 0.
move 'ZF_PF_STATUS'(002) to l_event-form.
append l_event to p_i_eventcat.
endif.
endform. " zf_build_eventcat
&----
*& Form i_fC_DISPLAY
&----
*& Form DISPLAY
&----
text
----
-->P_I_FC_DISPLAY text
----
form DISPLAY using p_i_fc_display TYPE slis_t_fieldcat_alv.
data: l_fieldcat type slis_fieldcat_alv.
I_MARA-MATNR. MATERIAL NUMBER
clear l_fieldcat.
l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MATNR'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL Number'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL No.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.N.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 18. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MARA'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_FC_DISPLAY.
MAKT-MAKTX
clear l_fieldcat.
l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'MAKTX'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'itab2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-key = 'X'. " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
l_fieldcat-just = 'C'. " FOR JUSTIFICATION.
l_fieldcat-hotspot = 'X'. " MARK THIS FIELD AS HOTSOPT TO CAUSE THE F2 EVENTS TO TRIGGER.
l_fieldcat-lzero = 'X'. " OUTPUT WITH LEADING ZEROS.
l_fieldcat-seltext_l = 'MATERIAL DESCRIPTION'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'MTL DESC.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'M.D.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40. " SET THE OUTPUT LENGTH.
l_fieldcat-ref_tabname = 'MAKT'. " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
append l_fieldcat to p_i_FC_DISPLAY.
itab11-TEXT.
clear l_fieldcat.
l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN.
l_fieldcat-fieldname = 'TEXT_1'. " FIELD FOR WHICH CATALOG ID FILLED.
l_fieldcat-tabname = 'ITAB2'. " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
l_fieldcat-seltext_m = 'Basic Text'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-EDIT = 'X'. " AS SYMBOL.
l_fieldcat-seltext_l = 'BASIC TEXT'. " LONG TEXT FOR HEADER.
l_fieldcat-seltext_m = 'B.TEXT.'. " MEDIUM TEXT FOR HEADER.
l_fieldcat-seltext_s = 'B.T.'. " SHORT TEXT FOR HEADER.
l_fieldcat-outputlen = 40.
append l_fieldcat to p_i_FC_DISPLAY.
endform. " DISPLAY
ONE more program.
TYPE-POOLS : slis.
DATA : alvly TYPE slis_layout_alv.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : BEGIN OF itab OCCURS 0,
lt TYPE i,
matnr LIKE mara-matnr,
END OF itab.
END-OF-SELECTION.
itab-lt = 1.
APPEND itab.
itab-lt = 2.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 1.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.
itab-lt = 3.
APPEND itab.
alvly-lights_fieldname = 'LT'.
alvly-lights_tabname = 'ITAB'.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = alvfc
is_layout = alvly
i_save = 'A'
TABLES
t_outtab = itab.
reward points if u find useful
Regards,
nagaraj
2007 Sep 05 12:29 PM
report zskc_test1.
type-pools : icon.
parameters : p type i default 3.
SELECTION-SCREEN COMMENT /1(5) cm_icon.
at selection-screen.
case p.
when 1.
move icon_red_light to cm_icon.
when 2.
move icon_yellow_light to cm_icon.
when 3.
move icon_green_light to cm_icon.
endcase.
Copy this into a prog -- u will understand automatically.
If you are interested in putting this into an ALV grid column - then passing of value will remain the same, in fuield catalog of that column set ICON = 'X'. You can pass the values like ICON_RED_LIGHT provided you ihave included the type pool ICON.
and U can refer to dbtable ICON for viewing icons.
Cheers
SKC.