Add user favorite Tcode using Function Module

Pada SAP, terdapat menu favorite yang berisi list tcode masing-masing user. Cara menambahkan tcode pada menu favorite ini biasanya dilakukan secara manual dengan klik kanan menu favorite lalu pilih insert transaction.

Tetapi bagaimana bila ada kebutuhan dimana ada ratusan user yang perlu ditambahkan tcode ke dalam menu favorite-nya? Dengan memberitahu masing-masing user untuk melakukan secara manual? Takes time!

Ada cara yang lebih mudah dengan menggunakan function module GUI_ADD_TCODE_TO_FAVORITES.

DATA: t_uname LIKE usr02-bname OCCURS 0 WITH HEADER LINE,
      t_tcode LIKE tstc-tcode OCCURS 0 WITH HEADER LINE.

SELECT-OPTIONS: s_uname FOR sy-uname,
                s_tcode FOR sy-tcode.

START-OF-SELECTION.
  SELECT bname FROM usr02 INTO TABLE t_uname
    WHERE bname IN s_uname.

  SELECT tcode FROM tstc INTO TABLE t_tcode
    WHERE tcode IN s_tcode.

  LOOP AT t_uname.
    LOOP AT t_tcode.
      CALL FUNCTION 'GUI_ADD_TCODE_TO_FAVORITES'
        EXPORTING
          transaction_to_add = t_tcode
          user_name          = t_uname
          no_par_tcode       = 'X'.
    ENDLOOP.
  ENDLOOP.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s