This website is not affiliated with, sponsored by, or approved by SAP AG.

Printing icons

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Printing icons

Postby Guest » Wed Nov 26, 2003 2:32 am

Hi All,

I've noticed that attempting to print icons in SAP results in something like # # or @1U@. There's a Sapnote stating that with most device types it is impossible to print icons.

However I've got a standard ALV Grid program where the field catalog defines a column as icon='X', but the column displays icons OR plain text (when on screen). In actual printing - only meaningless garvage is printed.

How can I make the plain text to print?
Since the column is in icon mode, it all prints as # # - even the plain text.
Also, the exact number of bytes in affecting the column width. For example an icon field is char(4). If the plain text is 'OK', it is only 2 bytes, so the column is too short by 2 characters - thus ruining the whole printed page layout. It looks like this:
Code: Select all
Col 1 | Col 2 |ICON| Col 4
28    | f     |# # | 954
5     | f     |# #| 955   <- too short because data is 'OK' instead of '@1U@'
941   | f     |# # | 956
Guest
 

Postby Remus » Wed Nov 26, 2003 7:58 pm

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'.
Remus
 
Posts: 62
Joined: Wed Nov 26, 2003 6:32 pm

Re: Printing icons

Postby naveen9 » Fri Aug 01, 2008 11:04 pm

Hi Remus,

As mentioned by you, Red light has a value of @0A@. Is there any table which has this characterset information? I need to know the characterset for other Icons.

Thanks
Naveen
naveen9
 
Posts: 24
Joined: Mon Jul 10, 2006 5:43 pm

Re: Printing icons

Postby Remus » Sat Aug 02, 2008 3:54 pm

Hi Naveen,

The table is: ICON. Use the matchcode from the SE16 to get the code from the icon you need.

Regards,
Remus
Remus
 
Posts: 62
Joined: Wed Nov 26, 2003 6:32 pm

Re: Printing icons

Postby naveen9 » Fri Aug 22, 2008 2:54 pm

Thanks Remus.

Naveen
Naveen
naveen9
 
Posts: 24
Joined: Mon Jul 10, 2006 5:43 pm

Re: Printing icons

Postby Rich » Thu Aug 28, 2008 1:31 am

Remus wrote:Hi Naveen,

The table is: ICON. Use the matchcode from the SE16 to get the code from the icon you need.

Regards,
Remus


See programs RSTXICON and RSZICON as well.
Regards

Rich

Image
Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com
Rich
 
Posts: 7112
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool

Re: Printing icons

Postby rhartogs » Mon Sep 08, 2008 11:56 am

Hello all,
this piece of code produces a nicer list of all available icons, with blank lines in between so that 'tall' icons don't overlap.
Sorry if it looks clunky, I'm sure it could be written more elegantly nowadays. Enjoy anyway!
<code begin>
Code: Select all
*
REPORT ZRUBICON LINE-SIZE 132.
*
TABLES: ICON.

PARAMETERS: PCOLUMNS(1) TYPE N DEFAULT 8.

DATA: BEGIN OF W_ID,
       DASH1 VALUE '[',
       ID(4),
       DASH2 VALUE ']',
       END OF W_ID,

       BEGIN OF T_ICONS OCCURS 0,
         ID(4),
       END OF T_ICONS,

       W_COLLEN TYPE I,
       W_ROWIX LIKE SY-INDEX,
       W_COLIX LIKE SY-INDEX,
       W_INDEX TYPE I,
       W_ICONS TYPE I.

SELECT ID FROM ICON INTO T_ICONS.
    APPEND T_ICONS.
    ADD 1 TO W_ICONS.
ENDSELECT.

W_COLLEN = ( W_ICONS - 1 ) DIV PCOLUMNS + 1.

DO W_COLLEN TIMES.
   W_ROWIX = SY-INDEX.
   NEW-LINE.
   DO PCOLUMNS TIMES.
     W_COLIX = SY-INDEX.
     W_INDEX = ( ( W_ROWIX - 1 ) * PCOLUMNS )  + W_COLIX.
     IF W_INDEX > W_ICONS.
       EXIT.
     ENDIF.
     READ TABLE T_ICONS INDEX W_INDEX.
     W_ID-ID = T_ICONS-ID.
     WRITE: W_ID, '=', T_ICONS-ID, ' '.
   ENDDO.
   SKIP.
ENDDO.
<code end>

[code block added - mod]
rhartogs
 
Posts: 1
Joined: Mon Sep 08, 2008 11:48 am

Re: Printing icons

Postby abap_doctor » Mon Sep 08, 2008 12:05 pm

Less clunky select:

Code: Select all
SELECT id
FROM icon
INTO TABLE t_icons.

w_icons = sy-dbcnt.


Although I get a more surreal feeling from:

Code: Select all
DATA : tab_icon LIKE icon OCCURS 0 WITH HEADER LINE.
  DATA : v_rand(5).

  SELECT * INTO TABLE tab_icon FROM icon.

  DO 2000 TIMES.

    CALL FUNCTION 'RSEC_GENERATE_PASSWORD'
      EXPORTING
        alphabet      = '0123456789'
        output_length = 3
      IMPORTING
        output        = v_rand
      EXCEPTIONS
        some_error    = 1
        OTHERS        = 2.

    READ TABLE tab_icon INDEX v_rand.

    WRITE : tab_icon-id.

  ENDDO.
The Doc
Tuly Idiot Magna Grand Docot Image
abap_doctor
 
Posts: 6955
Joined: Thu Mar 25, 2004 11:29 am
Location: Airstrip One


Return to ABAP

Who is online

Users browsing this forum: No registered users and 8 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.