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: 

search help

Former Member
0 Kudos
95

i have to use reuse_alv_popup_to_select FM in search help

plz tell me how its possible ?

1 ACCEPTED SOLUTION

Former Member
0 Kudos
63

<REMOVED BY MODERATOR>

-



REPORT z_alv_grid_and_popup.
*---------------------------------------------------------------------*
* This program is an example with a Grid list and a Popup list        *
* The Sales Orders are displayed in the first list                    *
* When a line is selected, the items of the order are displayed in    *
* a popup list                                                        *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 19-Nov-07                           *
* HomePage : http://www.geocities.com/mpioud                          *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_fieldcat.
  add 1 to ls_fieldcat-col_pos.
  ls_fieldcat-fieldname   = &1.
  ls_fieldcat-ref_tabname = &2.
  append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
CONSTANTS :
  c_x VALUE 'X'.
*---------------------------------------------------------------------*
TYPE-POOLS: slis.                      " ALV Global types

TYPES:
* Data displayed in the first list
  BEGIN OF ty_vbak,
    vkorg TYPE vbak-vkorg,             " Sales organization
    kunnr TYPE vbak-kunnr,             " Sold-to party
    vbeln TYPE vbak-vbeln,             " Sales document
    netwr TYPE vbak-netwr,             " Net Value of the Sales Order
  END OF ty_vbak,

* Data displayed in the popup list
  BEGIN OF ty_vbap,
    posnr  TYPE vbap-posnr,            " Sales document item
    matnr  TYPE vbap-matnr,            " Material number
    arktx  TYPE vbap-arktx,            " Short text for sales order item
    kwmeng TYPE vbap-kwmeng,           " Order quantity
    netwr  TYPE vbap-netwr,            " Net value of the order item
  END OF ty_vbap.

*---------------------------------------------------------------------*
DATA :
  g_vkorg TYPE vbak-vkorg,
  g_kunnr TYPE vbak-kunnr,
  g_vbeln TYPE vbak-vbeln,
  gt_vbak TYPE TABLE OF ty_vbak,
  gt_vbap TYPE TABLE OF ty_vbap.

*---------------------------------------------------------------------*
SELECT-OPTIONS :
  s_vkorg FOR g_vkorg,                 " Sales organization
  s_kunnr FOR g_kunnr,                 " Sold-to party
  s_vbeln FOR g_vbeln.                 " Sales document

SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of records to read'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data_vbak.

  PERFORM f_display_data_vbak.

*---------------------------------------------------------------------*
*      Form  f_read_data_vbak
*---------------------------------------------------------------------*
FORM f_read_data_vbak.

  SELECT vkorg kunnr vbeln netwr
    INTO TABLE gt_vbak
    FROM vbak
      UP TO p_max ROWS
   WHERE kunnr IN s_kunnr
     AND vbeln IN s_vbeln
     AND vkorg IN s_vkorg.

ENDFORM.                               " F_READ_DATA_VBAK
*---------------------------------------------------------------------*
*      Form  f_display_data_vbak
*---------------------------------------------------------------------*
FORM f_display_data_vbak.

  DATA:
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'VKORG' 'VBAK'.
  m_fieldcat 'KUNNR' 'VBAK'.
  m_fieldcat 'VBELN' 'VBAK'.
  m_fieldcat 'NETWR' 'VBAK'.

* Display the first list
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-cprog
      i_callback_user_command = 'USER_COMMAND'
      it_fieldcat             = lt_fieldcat
    TABLES
      t_outtab                = gt_vbak.

ENDFORM.                               " F_DISPLAY_DATA_VBAK
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm     TYPE sy-ucomm
                        us_selfield TYPE slis_selfield.     "#EC CALLED

  DATA:
    ls_vbak TYPE ty_vbak.

  CASE u_ucomm.
    WHEN '&IC1'.
      READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.
      CHECK sy-subrc EQ 0.
      PERFORM f_read_data_vbap         " Read data from VBAP
        USING ls_vbak-vbeln.
      PERFORM f_display_data_vbap.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
*---------------------------------------------------------------------*
*      Form  f_read_data_vbap
*---------------------------------------------------------------------*
FORM f_read_data_vbap USING u_vbeln TYPE vbeln_va.

  SELECT posnr matnr arktx kwmeng netwr
    INTO TABLE gt_vbap
    FROM vbap
   WHERE vbeln = u_vbeln.

ENDFORM.                               " F_READ_DATA_VBAP
*---------------------------------------------------------------------*
*      Form  f_display_data_vbap
*---------------------------------------------------------------------*
FORM f_display_data_vbap.

  DATA:
    ls_private  TYPE slis_data_caller_exit,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'POSNR'  'VBAP'.
  m_fieldcat 'MATNR'  'VBAP'.
  m_fieldcat 'ARKTX'  'VBAP'.
  m_fieldcat 'KWMENG' 'VBAP'.
  m_fieldcat 'NETWR'  'VBAP'.

  ls_private-columnopt = c_x.          " Optimize width

* Display items in a POPUP
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_selection = ' '
      i_tabname   = 'GT_VBAP'
      it_fieldcat = lt_fieldcat
      is_private  = ls_private
    TABLES
      t_outtab    = gt_vbap.

ENDFORM.                               " F_DISPLAY_DATA_VBAP
**************** END OF PROGRAM Z_ALV_GRID_AND_POPUP ******************

Edited by: Alvaro Tejada Galindo on Feb 6, 2008 11:13 AM

5 REPLIES 5

Former Member
0 Kudos
64

<REMOVED BY MODERATOR>

-



REPORT z_alv_grid_and_popup.
*---------------------------------------------------------------------*
* This program is an example with a Grid list and a Popup list        *
* The Sales Orders are displayed in the first list                    *
* When a line is selected, the items of the order are displayed in    *
* a popup list                                                        *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 19-Nov-07                           *
* HomePage : http://www.geocities.com/mpioud                          *
*---------------------------------------------------------------------*
* Macro definition
DEFINE m_fieldcat.
  add 1 to ls_fieldcat-col_pos.
  ls_fieldcat-fieldname   = &1.
  ls_fieldcat-ref_tabname = &2.
  append ls_fieldcat to lt_fieldcat.
END-OF-DEFINITION.
*---------------------------------------------------------------------*
CONSTANTS :
  c_x VALUE 'X'.
*---------------------------------------------------------------------*
TYPE-POOLS: slis.                      " ALV Global types

TYPES:
* Data displayed in the first list
  BEGIN OF ty_vbak,
    vkorg TYPE vbak-vkorg,             " Sales organization
    kunnr TYPE vbak-kunnr,             " Sold-to party
    vbeln TYPE vbak-vbeln,             " Sales document
    netwr TYPE vbak-netwr,             " Net Value of the Sales Order
  END OF ty_vbak,

* Data displayed in the popup list
  BEGIN OF ty_vbap,
    posnr  TYPE vbap-posnr,            " Sales document item
    matnr  TYPE vbap-matnr,            " Material number
    arktx  TYPE vbap-arktx,            " Short text for sales order item
    kwmeng TYPE vbap-kwmeng,           " Order quantity
    netwr  TYPE vbap-netwr,            " Net value of the order item
  END OF ty_vbap.

*---------------------------------------------------------------------*
DATA :
  g_vkorg TYPE vbak-vkorg,
  g_kunnr TYPE vbak-kunnr,
  g_vbeln TYPE vbak-vbeln,
  gt_vbak TYPE TABLE OF ty_vbak,
  gt_vbap TYPE TABLE OF ty_vbap.

*---------------------------------------------------------------------*
SELECT-OPTIONS :
  s_vkorg FOR g_vkorg,                 " Sales organization
  s_kunnr FOR g_kunnr,                 " Sold-to party
  s_vbeln FOR g_vbeln.                 " Sales document

SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.    "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.

*---------------------------------------------------------------------*
INITIALIZATION.

  v_1 = 'Maximum of records to read'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data_vbak.

  PERFORM f_display_data_vbak.

*---------------------------------------------------------------------*
*      Form  f_read_data_vbak
*---------------------------------------------------------------------*
FORM f_read_data_vbak.

  SELECT vkorg kunnr vbeln netwr
    INTO TABLE gt_vbak
    FROM vbak
      UP TO p_max ROWS
   WHERE kunnr IN s_kunnr
     AND vbeln IN s_vbeln
     AND vkorg IN s_vkorg.

ENDFORM.                               " F_READ_DATA_VBAK
*---------------------------------------------------------------------*
*      Form  f_display_data_vbak
*---------------------------------------------------------------------*
FORM f_display_data_vbak.

  DATA:
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'VKORG' 'VBAK'.
  m_fieldcat 'KUNNR' 'VBAK'.
  m_fieldcat 'VBELN' 'VBAK'.
  m_fieldcat 'NETWR' 'VBAK'.

* Display the first list
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-cprog
      i_callback_user_command = 'USER_COMMAND'
      it_fieldcat             = lt_fieldcat
    TABLES
      t_outtab                = gt_vbak.

ENDFORM.                               " F_DISPLAY_DATA_VBAK
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm     TYPE sy-ucomm
                        us_selfield TYPE slis_selfield.     "#EC CALLED

  DATA:
    ls_vbak TYPE ty_vbak.

  CASE u_ucomm.
    WHEN '&IC1'.
      READ TABLE gt_vbak INDEX us_selfield-tabindex INTO ls_vbak.
      CHECK sy-subrc EQ 0.
      PERFORM f_read_data_vbap         " Read data from VBAP
        USING ls_vbak-vbeln.
      PERFORM f_display_data_vbap.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
*---------------------------------------------------------------------*
*      Form  f_read_data_vbap
*---------------------------------------------------------------------*
FORM f_read_data_vbap USING u_vbeln TYPE vbeln_va.

  SELECT posnr matnr arktx kwmeng netwr
    INTO TABLE gt_vbap
    FROM vbap
   WHERE vbeln = u_vbeln.

ENDFORM.                               " F_READ_DATA_VBAP
*---------------------------------------------------------------------*
*      Form  f_display_data_vbap
*---------------------------------------------------------------------*
FORM f_display_data_vbap.

  DATA:
    ls_private  TYPE slis_data_caller_exit,
    ls_fieldcat TYPE slis_fieldcat_alv,
    lt_fieldcat TYPE slis_t_fieldcat_alv.

* Build the field catalog
  m_fieldcat 'POSNR'  'VBAP'.
  m_fieldcat 'MATNR'  'VBAP'.
  m_fieldcat 'ARKTX'  'VBAP'.
  m_fieldcat 'KWMENG' 'VBAP'.
  m_fieldcat 'NETWR'  'VBAP'.

  ls_private-columnopt = c_x.          " Optimize width

* Display items in a POPUP
  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_selection = ' '
      i_tabname   = 'GT_VBAP'
      it_fieldcat = lt_fieldcat
      is_private  = ls_private
    TABLES
      t_outtab    = gt_vbap.

ENDFORM.                               " F_DISPLAY_DATA_VBAP
**************** END OF PROGRAM Z_ALV_GRID_AND_POPUP ******************

Edited by: Alvaro Tejada Galindo on Feb 6, 2008 11:13 AM

Former Member
0 Kudos
63

Hi,

Please refer to the SAP Standard demo program:


BALV_POPUP_TO_SELECT
BALV_POPUP_TO_SELECT_2

Thanks,

Sriram Ponna.

Former Member
0 Kudos
63

'REUSE_ALV_POPUP_TO_SELECT'

And pass the table that you want to serve as search help.

Of course there will be better andf more state of the art methods using OOPS.

A sample that I used:

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

i_title = 'Send Orders to SQL'

i_checkbox_fieldname = 'CHECKBOX'

i_tabname = 'TLINE'

it_fieldcat = fieldcat[]

it_excluding = extab[]

IMPORTING

e_exit = e_exit

TABLES

t_outtab = tline

EXCEPTIONS

program_error = 1

OTHERS = 2.

<REMOVED BY MODERATOR>

Edited by: Alvaro Tejada Galindo on Feb 6, 2008 11:14 AM

0 Kudos
63

plz elborate further because i want a pop up alv when i press f4 on selection screen feild .

Former Member
0 Kudos
63

RESOLVED