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_create probleam

Former Member
0 Kudos

hi,

i am using a fm icon_create . but here the icon is not populating in my alv output.

but if i am writing write:/ result , then i am getting the icon.please let me know any probleam if i will use this FM in alv report.

help...

CALL FUNCTION 'ICON_CREATE'

EXPORTING

name = 'ICON_ACTIVE_INACTIVE'

IMPORTING

RESULT = RESULT.

ENDIF.

MOVE result TO gs_final-result.

ENDIF.

7 REPLIES 7

Former Member
0 Kudos

I think, you have use the icon type-pools in your report.

TYPE-POOLS: icon.

0 Kudos

hi,

no it doesnot solve my probleam..

please let me know this is a alv report so may be this is the probleam.

can u tell me how to display icons in alv output.

this should help for me

former_member195698
Active Contributor
0 Kudos

You can check the standard Programs in the Package SLIS.

Check this one - BCALV_TREE_06

You have to also set the flag ICON field in the field catalog. Just check how the program is preparing the data.

Former Member
0 Kudos

Hi,

Please try this peace of code in your program it might be helpful.

TYPE-POOLS: sym.

INCLUDE .

WRITE: ICON_SORT_DOWN

AS icon to itab-temp.

append itab.

Above code explains how to implement Symbols and ICONs in ALV output. Please check the same to your program.

Thanks

Raghavendra.D.S

former_member787646
Contributor
0 Kudos

Hi,

Add the following include in your code.

INCLUDE <icon>.

Next add a field in your ALV grid structue as below.

flag LIKE icon-name

and add the icon to the ALV grid like shown below.

WRITE ICON_ACTIVE_INACTIVE TO i_alv-flag.

Hope it helps.

Murthy

Former Member
0 Kudos

Hello ramkunat

First check that the size of field, you are using for the icon should be 44 chars & then mark the property ICON of corresponding field catalog entry as 'X'. It would work.

Best regards

Anand

[How2SAP.com|http://www.how2sap.com/blog/category/alv/]

venkat_o
Active Contributor
0 Kudos

Hi Ram, Try this way to create icon on ALV.


 REPORT ZVENKAT_ALV_TRAFFIC_LIGHTS .
TYPE-POOLS:icon.
DATA:BEGIN OF IT_LIGHTS OCCURS 0,
       MATNR  TYPE MARD-MATNR,
       WERKS  TYPE MARD-WERKS,
       LGORT  TYPE MARD-LGORT,
       LIGHTS TYPE CHAR4,       "Variable is needs to be declared with length 4 char
      END OF IT_LIGHTS.
TYPE-POOLS:SLIS.
TYPES:T_FIELDCAT         TYPE SLIS_FIELDCAT_ALV,
      T_EVENTS           TYPE SLIS_ALV_EVENT,
      T_LAYOUT           TYPE SLIS_LAYOUT_ALV.
DATA:W_FIELDCAT         TYPE T_FIELDCAT,
     W_EVENTS           TYPE T_EVENTS,
     W_LAYOUT           TYPE T_LAYOUT.
DATA:I_FIELDCAT         TYPE STANDARD TABLE OF T_FIELDCAT,
     I_EVENTS           TYPE STANDARD TABLE OF T_EVENTS.

START-OF-SELECTION.
  SELECT MATNR WERKS LGORT FROM MARD INTO CORRESPONDING FIELDS OF TABLE IT_LIGHTS UP TO 10 ROWS.
  IF IT_LIGHTS[] IS INITIAL.
    DO 10 TIMES.
      IT_LIGHTS-MATNR = SY-INDEX.
      IT_LIGHTS-WERKS = SY-INDEX + 1.
      IT_LIGHTS-LGORT = SY-INDEX + 2.
      APPEND IT_LIGHTS TO IT_LIGHTS.
      CLEAR  IT_LIGHTS.
    ENDDO.
  ENDIF.
  "Just pass 1=red or 2=yellow or 3=green to lights fields
  LOOP AT IT_LIGHTS INTO IT_LIGHTS.
    IF SY-TABIX BETWEEN 1 AND 3.
      IT_LIGHTS-LIGHTS = '1'.
    ELSEIF SY-TABIX BETWEEN 4 AND 7.
      IT_LIGHTS-LIGHTS = '2'.
    ELSEIF SY-TABIX BETWEEN 8 AND 10.
      IT_LIGHTS-LIGHTS = '3'.
    ENDIF.
    MODIFY IT_LIGHTS FROM IT_LIGHTS INDEX SY-TABIX TRANSPORTING LIGHTS.
  ENDLOOP.
  DEFINE FIELDCAT.
    W_FIELDCAT-FIELDNAME = &1.
    W_FIELDCAT-TABNAME   = &2.
    W_FIELDCAT-SELTEXT_M = &3.
    APPEND W_FIELDCAT TO I_FIELDCAT.
    CLEAR  W_FIELDCAT.
  END-OF-DEFINITION.
  FIELDCAT: 'MATNR'  'IT_LIGHTS' 'MARD-MATNR',
            'WERKS'  'IT_LIGHTS' 'MARD-WERKS',
            'LGORT'  'IT_LIGHTS' 'MARD-LGORT'.
  W_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
  W_LAYOUT-ZEBRA             = 'X'.
  W_LAYOUT-LIGHTS_FIELDNAME  = 'LIGHTS'.
  W_LAYOUT-LIGHTS_TABNAME    = 'I_LIGHTS'.
  DATA:L_PROGRAM TYPE SY-REPID VALUE SY-REPID.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = L_PROGRAM
      IS_LAYOUT          = W_LAYOUT
      IT_FIELDCAT        = I_FIELDCAT
    TABLES
      T_OUTTAB           = IT_LIGHTS.
Thanks Venkat.O