Simple Program for Custom Search Help

REPORT  ysearchhelp.
*--------------------------------------------------------------*
*Data Declaration
*--------------------------------------------------------------*
DATA: BEGIN OF t_matnr OCCURS 0,
      matnr TYPE makt-matnr,
      maktx TYPE makt-maktx,
      END OF t_matnr.

DATA: t_return  TYPE TABLE OF ddshretval WITH HEADER LINE.

*--------------------------------------------------------------*
*Selection-Screen
*--------------------------------------------------------------*
PARAMETERS: p_matnr TYPE mara-matnr.

*--------------------------------------------------------------*
*Selection-Screen on Value-Request
*--------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
  REFRESH t_matnr.
  t_matnr-matnr = 'AAA'.
  t_matnr-maktx = 'Dummy Material 1'.
  APPEND t_matnr.

  t_matnr-matnr = 'BBB'.
  t_matnr-maktx = 'Dummy Material 2'.
  APPEND t_matnr.

  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = 'MATNR'
      value_org       = 'S'
    TABLES
      value_tab       = t_matnr
      return_tab      = t_return
    EXCEPTIONS
      parameter_error = 1
      no_values_found = 2
      OTHERS          = 3.

  READ TABLE t_return INDEX 1.
  IF sy-subrc = 0.
    p_matnr = t_return-fieldval.
  ENDIF.
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