Menampilkan hari sesuai input tanggal

terkadang kebutuhan untuk menampilkan nama hari pada suatu program dibutuhkan. berikut ini contoh program untuk menampilkan nama hari dengan menggunakan function module DAY_IN_WEEK :

REPORT ytest_get_hari.

DATA : d_hari(6),
       d_day TYPE p.

PARAMETERS : p_date TYPE sy-datum.

START-OF-SELECTION.
  PERFORM f_get_hari.

END-OF-SELECTION.
  WRITE: 'tanggal', p_date, 'jatuh pada hari', d_hari.


*&---------------------------------------------------------------------*
*&      Form  f_get_hari
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f_get_hari.
  CALL FUNCTION 'DAY_IN_WEEK'
    EXPORTING
      datum = p_date
    IMPORTING
      wotnr = d_day.

  CASE d_day.
    WHEN 1.
      d_hari = 'Senin'.
    WHEN 2.
      d_hari = 'Selasa'.
    WHEN 3.
      d_hari = 'Rabu'.
    WHEN 4.
      d_hari = 'Kamis'.
    WHEN 5.
      d_hari = 'Jumat'.
    WHEN 6.
      d_hari = 'Sabtu'.
    WHEN 7.
      d_hari = 'Minggu'.
  ENDCASE.

ENDFORM.                    "f_get_hari
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