2007 Oct 01 6:56 AM
Hi all,
i need to put Status icons (Traffic lights Green, yellow, red) based on some condition in one of coloumn of ALV grid. Plese send me a sample code to put status icons in ALV grid.
Thanks in advance.
Regards,
Suresh.
2007 Oct 01 6:58 AM
Hi,
chek the below code..
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
Reward points if u find useful..
Regards,
Nagaraj
2007 Oct 01 6:58 AM
Hi,
chek the below code..
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
Reward points if u find useful..
Regards,
Nagaraj
2007 Oct 01 6:59 AM
u can do it with <b>TYPE-POOLS: ICON</b>
WHAT U CAN DO IS.,
declare another variable in the internal table of character type.
now include that variable too in the fieldcatalog along with the other variables , in the right place.
while filling the internal table, fill the variable with the required icon.
check the typ-pools icon.
example:
data icon1(50).
move ICON_GREEN_LIGHT to icon1.
write icon1.
Message was edited by:
Hymavathi Oruganti
2007 Oct 01 7:00 AM
hi suresh,
check out this code.
&----
*& Report ZST_TEST
*&
&----
*&
*&
&----
REPORT ZST_TEST.
type-pools: icon,col.
types: begin of ty_itab,
pernr type persno,
lights type char1,
color type i,
tabcol type lvc_t_scol,
id type char25,
end of ty_itab.
data: itab type table of ty_itab.
data: cust type ref to cl_gui_custom_container,
grid type ref to cl_gui_alv_grid.
data: wa_layout type lvc_s_layo.
data: fcat type lvc_t_fcat.
data: fcat1 type lvc_s_fcat.
start-of-selection.
wa_layout-EXCP_FNAME = 'LIGHTS'.
wa_layout-CTAB_FNAME = 'TABCOL'.
call screen 100.
&----
*& Module cancel INPUT
&----
text
----
MODULE cancel INPUT.
leave program.
ENDMODULE. " cancel INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS space.
if cust is initial.
CREATE OBJECT CUST
EXPORTING
CONTAINER_NAME = 'CUST'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5
others = 6
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT GRID
EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
I_PARENT = cust
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
EXCEPTIONS
ERROR_CNTL_CREATE = 1
ERROR_CNTL_INIT = 2
ERROR_CNTL_LINK = 3
ERROR_DP_CREATE = 4
others = 5
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
select pernr from pa0001 into corresponding fields of table itab
up to 10 rows.
data: col type lvc_s_scol.
data: l_ind type i.
field-symbols: <outtab> type ty_itab.
loop at itab assigning <outtab>.
l_ind = sy-tabix.
<outtab>-id = '@2K\QICON_SYSTEM_OKAY@'.
<outtab>-color = l_ind mod 7 + 1.
<outtab>-lights = l_ind mod 3 + 1.
col-fname = 'Color'.
col-color-col = l_ind mod 7 + 1.
append col to <outtab>-tabcol.
modify itab index sy-tabix..
endloop.
clear fcat1.
fcat1-fieldname = 'LIGHTS'.
fcat1-inttype = 'C'.
append fcat1 to fcat.
clear fcat1.
fcat1-fieldname = 'COLOR'.
fcat1-inttype = 'I'.
append fcat1 to fcat.
clear fcat1.
fcat1-fieldname = 'PERNR'.
fcat1-tabname = 'ITAB'.
append fcat1 to fcat.
fcat1-fieldname = 'ID'.
fcat1-tabname = 'ITAB'.
append fcat1 to fcat.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_BUFFER_ACTIVE =
I_BYPASSING_BUFFER =
I_CONSISTENCY_CHECK =
I_STRUCTURE_NAME =
IS_VARIANT =
I_SAVE =
I_DEFAULT = 'X'
IS_LAYOUT = wa_layout
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
IR_SALV_ADAPTER =
CHANGING
IT_OUTTAB = itab[]
IT_FIELDCATALOG = fcat[]
IT_SORT =
IT_FILTER =
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endif.
SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0100 OUTPUT
regards,
Santosh Thorat
2007 Oct 01 7:00 AM
Check this sample code:
populate led for eff. int. rate
WRITE l_wrk_output_result-err_eff_int DECIMALS 2 TO l_txt_1 .
IF l_wrk_output_result-err_eff_int <= p_g_high.
l_icon_name = icon_led_green.
CONCATENATE text-t01 l_txt_1 '%'
INTO l_icon_text.
ELSEIF l_wrk_output_result-err_eff_int <= p_y_high.
l_icon_name = icon_led_yellow.
CONCATENATE text-t01 l_txt_1 '%' INTO l_icon_text.
ELSE.
l_icon_name = icon_led_red.
CONCATENATE text-t01 l_txt_1 '%'
INTO l_icon_text.
ENDIF.
PERFORM create_icon USING
l_icon_name
l_icon_text
CHANGING
l_icon_res.
l_wrk_output_result-icon_eff_int = l_icon_res.
***
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name = u_icon_name
text = icon_text
info = u_icon_text
ADD_STDINF = 'X'
IMPORTING
RESULT = c_icon_res
EXCEPTIONS
icon_not_found = 1
outputfield_too_short = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.