Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Icon Display in ALV Report

Former Member
0 Kudos
2,039

Hi,

I need to display an ALV report with purchase order detials and items. for each Purchase order number an Icon needs to be displayed when the user clicks the icon it must move to another transaction.

1 ACCEPTED SOLUTION
6 REPLIES 6

Former Member
0 Kudos
354

Add a new field to your output internal table for ICON, "icon_f TYPE icon-name,".

Popolate the required icon value to this field, example "itab-icon_f = '@16@'."

Now you can pass the same Itab to FM, as below.

CALL METHOD gr_alvgrid1->set_table_for_first_display

EXPORTING

is_layout = gs_layout1

CHANGING

it_outtab = itab2[]

it_fieldcatalog = gt_fieldcat1

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

METHOD handle_double_click.

IFsy-dynnr eq 'screen##' and

e_column-fieldname = 'ICON_F'.

perform on_f4_help.

ENDIF.

ENDMETHOD. "handle_double_click

Regards,

Vishal

0 Kudos
354

Vishal,

Thanks for ur reply, can you please given me a sample program. I have not worked on ALV report before, if u are able to provide a sample program with the icon i can go through it and can have a better understanding

Former Member
0 Kudos
354

Hi Joseph,

<b> PO alv report u can find it below</b>


* THIS DEFINES GLOBAL TYPES FOR ALV.
TYPE-POOLS: slis.

* TRANSPARENT TABLES USED FOR DATA FETCHING
TABLES: ekko,ekpo,eket,lfa1,ekbe.

DATA : i_fieldcat TYPE slis_t_fieldcat_alv," FOR FIELDCATALOG
i2_fieldcat TYPE slis_t_fieldcat_alv,"FOR FIELDCATALOG 2
i3_fieldcat TYPE slis_t_fieldcat_alv, "FOR FIELDCATALOG 3
i_eventcat TYPE slis_t_event, "FOR EVENTCATALOG
i_layout TYPE slis_layout_alv, "FOR LAYOUT
i_sortinfo TYPE slis_t_sortinfo_alv. "FOR SORTING

* VARIABLE FOR COUNT OF PO
DATA: n TYPE i ,
i TYPE i,
po_item TYPE ebelp,
v_count(1) VALUE 'N'.
*********************************************************************
*-----------------------TYPES---------------------------------------*
*********************************************************************

*-----------------DATA DECLARATION FOR VENDOR MASTER------------*
TYPES: BEGIN OF t_lfa1,
lifnr TYPE lifnr, "VENDOR CODE
name1 TYPE name1_gp, "VENDOR NAME
END OF t_lfa1.

*----------------DATA DECLARATION FOR HEADER(EKKO)------------------*
TYPES: BEGIN OF t_ekko,
ebeln TYPE ebeln, "PURCHASE ORDER NUMBER
lifnr TYPE elifn, "VENDOR CODE
c TYPE i, "PURCHASE ORDER COUNT
END OF t_ekko.



*----------------DATA DECLARATION FOR DETAIL(EKPO)------------------*
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ebeln, "PURCHASE ORDER NUMBER
ebelp TYPE ebelp, "PURCHASE ORDER ITEM
menge TYPE bstmg, "PURCHASE ORDER QTY
END OF t_ekpo,
*---------------DATA DECLARATION FOR EKET TABLE----------------------*
BEGIN OF t_eket,
ebeln TYPE ebeln, "PURCHASE ORDER NUMBER
ebelp TYPE ebelp, "PURCHASE ORDER ITEM
etenr TYPE eeten, "DELIVERY SCHEDULE LINE COUNTER
wemng TYPE weemg, "QUANTITY OF GOODS RECIEVED
END OF t_eket ,
*---------------DATA DECLARATION FOR FINAL TABLE(FIRST
*SCREEN)----------*
BEGIN OF t_tab,
lifnr TYPE elifn,
ebeln TYPE ebeln,
name1 TYPE name1_gp,
ebelp TYPE ebelp,
menge TYPE bstmg,
etenr TYPE eeten,
wemng TYPE weemg,
c TYPE i,
END OF t_tab.
*---------------DATA DECLARATION FOR FINAL TABLE (SECOND SCREEN)-----*
TYPES: BEGIN OF t_vendor,
lifnr TYPE elifn,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
menge TYPE bstmg,
wemng TYPE p,
END OF t_vendor,
*---------------DATA DECLARATION FOR EKBE-----------------------*
BEGIN OF t_ekbe,
ebeln TYPE ebeln,
ebelp TYPE ebelp,
bwart TYPE bwart,
menge TYPE menge_d,
END OF t_ekbe.
*********************************************************************
*-----------------------WORK AREA------------------------------------*
*********************************************************************
DATA : wa_lfa1 TYPE t_lfa1,
wa_ekko TYPE t_ekko,
wa_ekpo TYPE t_ekpo,
wa_eket TYPE t_eket,
wa_tab TYPE t_tab,
wa_vendor TYPE t_vendor,
wa_ekbe TYPE t_ekbe,
wa_grn TYPE t_ekbe,
wa_full TYPE t_vendor.

*********************************************************************
*-------------------INTERNAL TABLES----------------------------------*
*********************************************************************
DATA: it_lfa1 TYPE STANDARD TABLE OF t_lfa1 WITH HEADER LINE ,
it_ekko TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE ,
it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE,
it_eket TYPE STANDARD TABLE OF t_eket WITH HEADER LINE,
it_tab TYPE STANDARD TABLE OF t_tab WITH HEADER LINE,
it_vendor TYPE STANDARD TABLE OF t_vendor WITH HEADER LINE,
it_ekbe TYPE STANDARD TABLE OF t_ekbe WITH HEADER LINE,
it_grn TYPE STANDARD TABLE OF t_ekbe WITH HEADER LINE,
it_full TYPE STANDARD TABLE OF t_vendor WITH HEADER LINE.

DATA: vendor TYPE elifn.
DATA: qty TYPE p,
c TYPE i.
*********************************************************************
*-----------------------SELECTION SCREEN----------------------------*
**********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr OBLIGATORY.
SELECTION-SCREEN END OF BLOCK main.

*********************************************************************
*-------------------AT SELECTION-SCREEN----------------------------*
*********************************************************************

AT SELECTION-SCREEN.
SELECT lifnr INTO (it_lfa1-lifnr) FROM lfa1 WHERE lifnr IN
s_lifnr.
ENDSELECT.
IF sy-subrc <> 0.
MESSAGE e001.
ENDIF.

*********************************************************************
*-------------------START-OF-SELECTION------------------------------*
*********************************************************************

START-OF-SELECTION.

* FETCH RECORDS FROM THE DATABASE INTO THE INTERNAL TABLE.
PERFORM zf_select_it_tab.

* PREPARE FIELDCATALOG FOR THE MAIN (1ST LIST) REPORT.
PERFORM zf_build_fieldcat USING i_fieldcat.

* DEFINE EVENT TABLE
PERFORM build_eventcat USING i_eventcat.


* DETERMINE THE SORTING SEQUENCE.
PERFORM build_sort USING i_sortinfo.

* DISPLAY ALV GRID.
PERFORM zf_display_alv_list.




*&---------------------------------------------------------------------*
*& Form ZF_SELECT_IT_TAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
*SELECTING DATA FROM IT_LFA1 TABLE
FORM zf_select_it_tab .
SELECT lifnr
name1
INTO TABLE it_lfa1
FROM lfa1
WHERE lifnr IN s_lifnr.
IF sy-subrc = 0.
SORT it_lfa1 BY lifnr.
ENDIF.
*SELECTING DATA FROM EKKO TABLE
IF NOT it_lfa1[] IS INITIAL.
SELECT
ebeln
lifnr
FROM ekko
INTO TABLE it_ekko
FOR ALL ENTRIES IN it_lfa1
WHERE lifnr = it_lfa1-lifnr.
IF sy-subrc = 0.
SORT it_ekko BY ebeln.
ENDIF.
ENDIF.
*SELECTING DATA FROM EKPO TABLE
IF NOT it_ekko[] IS INITIAL.
SELECT
ebeln
ebelp
menge
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln = it_ekko-ebeln.
IF sy-subrc = 0.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
ENDIF.
*SELECTING DATA FROM EKET TABLE
IF NOT it_ekpo[] IS INITIAL.
SELECT
ebeln
ebelp
etenr
wemng
FROM eket
INTO TABLE it_eket
FOR ALL ENTRIES IN it_ekpo
WHERE ebeln = it_ekpo-ebeln
AND ebelp = it_ekpo-ebelp.
SORT it_eket BY ebeln ebelp etenr.
ENDIF.
*SELECTING DATA FROM EKBE TABLE
IF NOT it_eket[] IS INITIAL.
SELECT
ebeln
ebelp
bwart
menge
FROM ekbe
INTO TABLE it_ekbe
FOR ALL ENTRIES IN it_eket
WHERE ebelp = it_eket-ebelp
AND ebeln = it_eket-ebeln
AND bwart = '101'.
ENDIF.

*********************************************************
* THIS BLOCK MOVES THE FIELDS FROM DIFFERENT *
* TABLES(EKKO,LFA1,EKPO,EKET) INTO A FINAL TABLE IT_TAB *
* *
*********************************************************
CLEAR wa_tab.
CLEAR it_tab.
LOOP AT it_lfa1 INTO wa_lfa1.
READ TABLE it_ekko INTO wa_ekko WITH KEY lifnr = wa_lfa1-lifnr
BINARY SEARCH.


READ TABLE it_lfa1 INTO wa_lfa1
WITH KEY lifnr = wa_lfa1-lifnr
BINARY SEARCH.
IF sy-subrc = 0.
MOVE: wa_lfa1-name1 TO wa_tab-name1.
MOVE: wa_lfa1-lifnr TO wa_tab-lifnr.

ENDIF.
APPEND wa_tab TO it_tab.
CLEAR : wa_tab,wa_lfa1.
ENDLOOP.

**READ FOR SECOND SCREEN

REFRESH it_full.
CLEAR : wa_full,
wa_eket,
wa_ekpo.
LOOP AT it_eket INTO wa_eket.

READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_eket-ebeln
ebelp = wa_eket-ebelp
BINARY SEARCH.
IF sy-subrc = 0.

READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln =
wa_ekpo-ebeln
BINARY SEARCH.
IF sy-subrc = 0.

READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr
BINARY SEARCH.

IF sy-subrc = 0.

wa_full-ebelp = wa_ekpo-ebelp.
wa_full-menge = wa_ekpo-menge.
wa_full-lifnr = wa_lfa1-lifnr.
wa_full-ebeln = wa_ekko-ebeln.
wa_full-wemng = wa_eket-wemng.

ENDIF.
ENDIF.
ENDIF.
APPEND wa_full TO it_full.
CLEAR : wa_ekko,wa_ekpo,wa_eket,wa_full.
ENDLOOP.


* COUNT OF PO
LOOP AT it_tab.

LOOP AT it_ekko WHERE lifnr = it_tab-lifnr.

c = c + 1.

ENDLOOP.
it_tab-c = c.
MODIFY it_tab TRANSPORTING c.
CLEAR c.
ENDLOOP.


ENDFORM. " ZF_SELECT_IT_TAB
*&---------------------------------------------------------------------*
*& Form ZF_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* FIELD CATALOG FOR FIRST SCREEN
*----------------------------------------------------------------------*
* -->P_I_FIELDCAT text
*----------------------------------------------------------------------*
FORM zf_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv.
REFRESH p_i_fieldcat.
DATA: l_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '1'.
l_fieldcat-fieldname = 'LIFNR'.
l_fieldcat-tabname = 'IT_TAB'.
l_fieldcat-key = 'X'.
l_fieldcat-emphasize = 'C410'.
l_fieldcat-seltext_l = 'VENDOR CODE'.
l_fieldcat-outputlen = 20.

APPEND l_fieldcat TO p_i_fieldcat.
CLEAR l_fieldcat.

l_fieldcat-col_pos = '2'.
l_fieldcat-fieldname = 'NAME1'.
l_fieldcat-tabname = 'IT_TAB'.
l_fieldcat-emphasize = 'C410'.
l_fieldcat-seltext_l = 'VENDOR NAME'.
l_fieldcat-outputlen = 20.

APPEND l_fieldcat TO p_i_fieldcat.
CLEAR l_fieldcat.

l_fieldcat-col_pos = '3'.
l_fieldcat-fieldname = 'C'.
l_fieldcat-tabname = 'IT_TAB'.
l_fieldcat-emphasize = 'C410'.
l_fieldcat-seltext_l = 'PO COUNT'.
l_fieldcat-outputlen = 10.
APPEND l_fieldcat TO p_i_fieldcat.


ENDFORM. " ZF_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form ZF_DISPLAY_ALV_LIST
*&---------------------------------------------------------------------*
* CALLING FUNCTION FOR ALV GRID DISPLAY
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf_display_alv_list .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'
i_callback_user_command = 'USER_COMMAND'
is_layout = i_layout
it_fieldcat = i_fieldcat
it_events = i_eventcat
TABLES
t_outtab = it_tab
* 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. " ZF_DISPLAY_ALV_LIST
*&---------------------------------------------------------------------*
*& Form BUILD_SORT
*&---------------------------------------------------------------------*
* SORTING OUTPUT BY PURCHASE ORDER AND LINE ITEM
*----------------------------------------------------------------------*
* -->P_I_SORTINFO text
*----------------------------------------------------------------------*
FORM build_sort USING p_i_sortinfo TYPE slis_t_sortinfo_alv.
REFRESH p_i_sortinfo.
DATA: l_sortinfo TYPE slis_sortinfo_alv.

CLEAR l_sortinfo.
l_sortinfo-spos = '1'.
l_sortinfo-fieldname = 'LIFNR'.
l_sortinfo-tabname = 'IT_VENDOR'.
l_sortinfo-up = 'X'.
l_sortinfo-group = 'UL'.
APPEND l_sortinfo TO p_i_sortinfo.


CLEAR l_sortinfo.
l_sortinfo-spos = '2'.
l_sortinfo-fieldname = 'EBELN'.
l_sortinfo-tabname = 'IT_VENDOR'.
l_sortinfo-up = 'X'.
l_sortinfo-group = 'UL'.
APPEND l_sortinfo TO p_i_sortinfo.

ENDFORM. " BUILD_SORT
*&---------------------------------------------------------------------*
*& Form BUILD_EVENTCAT
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
* -->P_I_EVENTCAT text
*----------------------------------------------------------------------*
FORM build_eventcat USING p_i_eventcat TYPE slis_t_event.
REFRESH p_i_eventcat.
DATA: i_event TYPE slis_alv_event.

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 i_event.
READ TABLE p_i_eventcat WITH KEY name = slis_ev_user_command INTO
i_event.
IF sy-subrc = 0.
MOVE 'USER_COMMAND' TO i_event-form.
APPEND i_event TO p_i_eventcat.
ENDIF.

ENDFORM. " BUILD_EVENTCAT

*&---------------------------------------------------------------------*
*& FORM USER_COMMAND
*&---------------------------------------------------------------------*
FORM user_command USING p_ucomm TYPE sy-ucomm
p_selfield TYPE slis_selfield.


CASE p_ucomm.
WHEN '&IC1'.


READ TABLE it_tab INTO wa_tab INDEX p_selfield-tabindex.


IF p_selfield-fieldname = 'LIFNR'.

vendor = p_selfield-value.
PERFORM zf_vendor_details.
PERFORM zf2_build_fieldcat USING i2_fieldcat.
PERFORM zf_display_grid.
ENDIF.

CLEAR p_selfield.


ENDCASE.
ENDFORM. " ZF_USER_COMMAND

*&---------------------------------------------------------------------*
*& Form ZF_VENDOR_DETAILS
*&---------------------------------------------------------------------*
* THIS FORM IS USED FOR MOVING DATA FROM IT_TAB TO IT_VENDOR
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf_vendor_details .
CLEAR wa_ekko.
CLEAR it_ekko.
REFRESH it_vendor.
LOOP AT it_full INTO wa_full WHERE lifnr = vendor.
MOVE :
wa_full-lifnr TO wa_vendor-lifnr,
wa_full-ebeln TO wa_vendor-ebeln,
wa_full-ebelp TO wa_vendor-ebelp,
wa_full-menge TO wa_vendor-menge,
wa_full-wemng TO wa_vendor-wemng.
APPEND wa_vendor TO it_vendor.
CLEAR : wa_vendor.
ENDLOOP.

ENDFORM. " ZF_VENDOR_DETAILS

*&---------------------------------------------------------------------*
*& Form ZF2_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* THIS FORM IS USED FOR CATALOG SCREEN 2
*----------------------------------------------------------------------*
* -->P_I_FIELDCAT text
*----------------------------------------------------------------------*
FORM zf2_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv.
REFRESH p_i_fieldcat.
DATA: l2_fieldcat TYPE slis_fieldcat_alv.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '1'.
l2_fieldcat-fieldname = 'LIFNR'.
l2_fieldcat-tabname = 'IT_VENDOR'.
l2_fieldcat-key = 'X'.
l2_fieldcat-emphasize = 'C410'.
l2_fieldcat-seltext_l = 'VENDOR CODE'.
l2_fieldcat-outputlen = 20.


APPEND l2_fieldcat TO p_i_fieldcat.
CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '2'.
l2_fieldcat-fieldname = 'EBELN'.
l2_fieldcat-tabname = 'IT_VENDOR'.
l2_fieldcat-key = 'X'.
l2_fieldcat-emphasize = 'C410'.
l2_fieldcat-seltext_l = 'PURCHASE ORDER NUMBER'.

l2_fieldcat-outputlen = 20.


APPEND l2_fieldcat TO p_i_fieldcat.
CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '3'.
l2_fieldcat-fieldname = 'EBELP'.
l2_fieldcat-tabname = 'IT_VENDOR'.
l2_fieldcat-key = 'X'.
l2_fieldcat-emphasize = 'C710'.
l2_fieldcat-seltext_l = 'PO ITEM'.
l2_fieldcat-outputlen = 20.


APPEND l2_fieldcat TO p_i_fieldcat.
CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '4'.
l2_fieldcat-fieldname = 'MENGE'.
l2_fieldcat-tabname = 'IT_VENDOR'.
l2_fieldcat-key = 'X'.
l2_fieldcat-emphasize = 'C410'.
l2_fieldcat-seltext_l = 'PO QTY'.
l2_fieldcat-outputlen = 20.


APPEND l2_fieldcat TO p_i_fieldcat.
CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '5'.
l2_fieldcat-fieldname = 'WEMNG'.
l2_fieldcat-tabname = 'IT_VENDOR'.
l2_fieldcat-key = 'X'.
l2_fieldcat-emphasize = 'C450'.
l2_fieldcat-seltext_l = 'QTY RECIEVED'.
l2_fieldcat-outputlen = 20.


APPEND l2_fieldcat TO p_i_fieldcat.
CLEAR l2_fieldcat.
ENDFORM. "ZF2_BUILD_FIELDCAT

*&---------------------------------------------------------------------*
*& Form ZF_DISPLAY_ALV_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf_display_grid .


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'
* I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND1'
it_fieldcat = i2_fieldcat
it_sort = i_sortinfo
* IMPORTING
TABLES
t_outtab = it_vendor
* 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. "ZF_DISPLAY_GRID




*&---------------------------------------------------------------------*
*& FORM USER_COMMAND1
*&---------------------------------------------------------------------*
FORM user_command1 USING p_ucomm TYPE sy-ucomm
p_selfield TYPE slis_selfield.

CASE p_ucomm.
WHEN '&IC1'.
READ TABLE it_vendor INTO wa_vendor INDEX p_selfield-tabindex.
IF p_selfield-fieldname = 'WEMNG'.
po_item = wa_vendor-ebelp.
PERFORM zf_grn.
PERFORM zf3_build_fieldcat USING i3_fieldcat.
PERFORM zf1_display_grid.
ENDIF.
ENDCASE.
ENDFORM. " ZF_USER_COMMAND




*&---------------------------------------------------------------------*
*& Form ZF3_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* FIELD CATALOG FOR THIRD SCREEN
*----------------------------------------------------------------------*
* -->P_I3_FIELDCAT text
*----------------------------------------------------------------------*
FORM zf3_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv
.


REFRESH p_i_fieldcat.
DATA: l3_fieldcat TYPE slis_fieldcat_alv.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '1'.
l3_fieldcat-fieldname = 'EBELN'.
l3_fieldcat-tabname = 'IT_GRN'.
l3_fieldcat-key = 'X'.
l3_fieldcat-emphasize = 'C410'.
l3_fieldcat-seltext_l = 'P.O. NO'.
l3_fieldcat-outputlen = 20.


APPEND l3_fieldcat TO p_i_fieldcat.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '2'.
l3_fieldcat-fieldname = 'EBELP'.
l3_fieldcat-tabname = 'IT_GRN'.
l3_fieldcat-key = 'X'.
l3_fieldcat-emphasize = 'C410'.
l3_fieldcat-seltext_l = 'P.O.ITEM'.
l3_fieldcat-outputlen = 20.


APPEND l3_fieldcat TO p_i_fieldcat.
CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '3'.
l3_fieldcat-fieldname = 'BWART'.
l3_fieldcat-tabname = 'IT_GRN'.
l3_fieldcat-key = 'X'.
l3_fieldcat-emphasize = 'C410'.
l3_fieldcat-seltext_l = 'MOVEMENT TYPE'.
l3_fieldcat-outputlen = 20.


APPEND l3_fieldcat TO p_i_fieldcat.
CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '4'.
l3_fieldcat-fieldname = 'MENGE'.
l3_fieldcat-tabname = 'IT_GRN'.
l3_fieldcat-key = 'X'.
l3_fieldcat-emphasize = 'C410'.
l3_fieldcat-seltext_l = 'GR QUANTITY'.
l3_fieldcat-outputlen = 20.


APPEND l3_fieldcat TO p_i_fieldcat.
CLEAR l3_fieldcat.

ENDFORM. " ZF3_BUILD_FIELDCAT
*&---------------------------------------------------------------------*
*& Form ZF1_DISPLAY_GRID
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf1_display_grid .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'
it_fieldcat = i3_fieldcat
* IMPORTING
TABLES
t_outtab = it_grn
* 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. " ZF1_DISPLAY_GRID
*&---------------------------------------------------------------------*
*& Form ZF_GRN
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM zf_grn .


CLEAR wa_eket .
CLEAR it_eket.
REFRESH it_grn.
LOOP AT it_vendor INTO wa_vendor WHERE ebelp = po_item.
IF sy-subrc = 0.
READ TABLE it_ekbe INTO wa_ekbe WITH KEY
ebeln = wa_vendor-ebeln
ebelp = wa_vendor-ebelp.

IF sy-subrc = 0.
IF wa_ekbe-bwart = '101'.
MOVE: wa_ekbe-ebeln TO wa_grn-ebeln,
wa_ekbe-ebelp TO wa_grn-ebelp,
wa_ekbe-bwart TO wa_grn-bwart,
wa_ekbe-menge TO wa_grn-menge.

APPEND wa_grn TO it_grn.
CLEAR wa_ekbe.
CLEAR wa_grn.
ELSE.
MESSAGE e001.
ENDIF.
ENDIF.

ENDIF.
ENDLOOP.

ENDFORM. " ZF_GRN

<b>Reward pts if found usefull :)</b>

Regards

Sathish

Former Member
0 Kudos
354

hi,

while creating field catalog, you pass the value 'X' to the ICON option of the field of the field catalog. then the oupt will be displayed as ICON.

This is very easy. IN your status field in your internal table, you simply write the icon to it. Make sure that the status field is defined as a character field with a length of 4. Then write the icon to it.

<b>Type-pools: icon.</b>

.....

write icon_green_light as icon to itab-status.

...

Then when filling the field catalog, set the ICON flag. This puts the icon in the center of the cell in ALV.

....

<b>xfc-icon = 'X'.</b> "field catalog workarea

append xfc to ifc. " field catalog body

If this field is set, the column contents of the output table are output as an icon. The column contents must consist of valid icon strings ( @xx@ or @xx\Q <Quickinfo> @ ).

for more information follow this link....

http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649baf17411d2b486006094192fe3/content.htm

regards,

Ashok Reddy

Message was edited by:

Ashok Reddy

0 Kudos
354

Hi,

the way to display icons in ALV is as follow...

Define a field in the internal table LIKE ICON-ID, not char(4).

For example...


DATA: BEGIN OF ITAB... 
icon_field LIKE ICON-ID, 
... 
END OF ITAB.

Then fill the field icon, for example...

itab-icon_field = @0A@ "Red light

Preparing the fieldcatalog...

wa_fieldcat-tabname = 'ITAB'. 
wa_fieldcat-fieldname = 'ICON_FIELD'. 
wa_fieldcat-icon = 'X'. 

There is another way to display icons, but is only for lights... 
icon_field(1) TYPE C. 

itab-icon_field = '1'. "Red 
itab-icon_field = '2'. "Yellow 
itab-icon_field = '3'. "Green 

wa_layout-lights_tabname = 'ITAB'. 
wa_layout-lights_fieldname = 'ICON_FIELD'.

Report for Traffic lights

TYPES: BEGIN OF st_sflight. 
        INCLUDE STRUCTURE zsflight. 
TYPES:  traffic_light TYPE c. 
´TYPES: END OF st_sflight. 
TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight. 
DATA: gi_sflight TYPE tt_sflight. 


*   Set the exception field of the table 
    LOOP AT gi_sflight INTO g_wa_sflight. 
      IF g_wa_sflight-paymentsum < 100000. 
        g_wa_sflight-traffic_light = '1'. 
      ELSEIF g_wa_sflight-paymentsum => 100000 AND 
             g_wa_sflight-paymentsum < 1000000. 
        g_wa_sflight-traffic_light = '2'. 
      ELSE. 
        g_wa_sflight-traffic_light = '3'. 
      ENDIF. 
      MODIFY gi_sflight FROM g_wa_sflight. 
    ENDLOOP. 
*   Name of the exception field (Traffic light field) 
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'. 
*   Grid setup for first display 
    CALL METHOD go_grid->set_table_for_first_display 
      EXPORTING i_structure_name = 'SFLIGHT' 
                              is_layout               = gs_layout 
      CHANGING  it_outtab                 = gi_sflight. 

Reward all helpfull answers

Regards

Pavan