Application Development and Automation 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: 
Read only

​How to retrieve data from a search help click into a table control?

Former Member
0 Likes
1,573

Hi
There is a search help, 'Z15_SH_PRO'. It's attached to a field(ID) in table control. I'm trying to achieve is, when the user clicks the search help popup and selects a particular row, all the remaing fields(Description, Unit etc) have to be imported into the table control.

For that I created a search help exit, which is given below.

FUNCTION z15_sh_pro_exit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     REFERENCE(SHLP) TYPE  SHLP_DESCR
*"     REFERENCE(CALLCONTROL) TYPE  DDSHF4CTRL
*"----------------------------------------------------------------------
  " SHLP_TAB   - will have the search help that is attached to the corresponding field.
  " RECORD_TAB - will hold the data that is to be displayed.

  DATA: t_record_tab LIKE TABLE OF seahlpres.
  DATA: it_dynp TYPE STANDARD TABLE OF dynpread.
  DATA: wa_dynp TYPE dynpread.

  IF callcontrol-step = 'RETURN'. "When user selection is completed !?
    READ TABLE shlp_tab. 
    
    record_tab[] = t_record_tab[]. 
    "When debugged, the record_tab's 'RECORD_TAB-STRING' holds data. 
    "Bt didn't know how to retrieve.

    IF shlp_tab-shlpname EQ 'Z15_SH_PRO'. 
      wa_dynp-fieldname = 'WA_SO_IT-DESCRIPTION'.
      wa_dynp-fieldvalue = 'Hello'. " Dummy value. Need to fill with actual value from search help.
      APPEND wa_dynp TO it_dynp.

      wa_dynp-fieldname = 'WA_SO_IT-UNIT_MES'.
      wa_dynp-fieldvalue = 'World'. " Dummy value. Need to fill with actual value from search help.

      APPEND wa_dynp TO it_dynp.
      CLEAR wa_dynp.

      " This updated the table control with the dummy value.
      " But didn't know how to fill at the same row where the user clicks the search help.
      " Currently it's always filled at the bottom of table control.
      CALL FUNCTION 'DYNP_UPDATE_FIELDS'
        EXPORTING
          dyname                         = 'SAPMZ_15081947_SO' " Module Pool name
          dynumb                         = '9000' "Screen Number
          request                        = 'A'
*         START_SEARCH_IN_CURRENT_SCREEN = ' '
*         START_SEARCH_IN_MAIN_SCREEN    = ' '
*         START_SEARCH_IN_STACKED_SCREEN = ' '
*         START_SEARCH_ON_SCR_STACKPOS   = ' '
*         SEARCH_OWN_SUBSCREENS_FIRST    = ' '
*         SEARCHPATH_OF_SUBSCREEN_AREAS  = ' '
        TABLES
          dynpfields                     = it_dynp
        EXCEPTIONS
          invalid_abapworkarea           = 1
          invalid_dynprofield            = 2
          invalid_dynproname             = 3
          invalid_dynpronummer           = 4
          invalid_request                = 5
          no_fielddescription            = 6
          undefind_error                 = 7
          OTHERS                         = 8.
      IF sy-subrc <> 0.
        * Implement suitable error handling here
        MESSAGE 'Error in updating the fields' TYPE 'E'.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFUNCTION.

When debugged, the record_tab's 'RECORD_TAB-STRING' holds data. But didn't know how to retrieve. 'DYNP_UPDATE_FIELDS' function module updated the table control with the dummy value. But didn't know how to fill at the same row where the user clicks the search help. Currently when selected the search help, it's always filled at the bottom of table control. Is there another function module available to update table control?

Hi
There is a search help, 'Z15_SH_PRO'. It's attached to a field(ID) in table control. I'm trying to achieve is, when the user clicks the search help popup and selects a particular row, all the remaing fields(Description, Unit etc) have to be imported into the table control.

For that I created a search help exit, which is given below.

FUNCTION z15_sh_pro_exit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      SHLP_TAB TYPE  SHLP_DESCT
*"      RECORD_TAB STRUCTURE  SEAHLPRES
*"  CHANGING
*"     REFERENCE(SHLP) TYPE  SHLP_DESCR
*"     REFERENCE(CALLCONTROL) TYPE  DDSHF4CTRL
*"----------------------------------------------------------------------
  " SHLP_TAB   - will have the search help that is attached to the corresponding field.
  " RECORD_TAB - will hold the data that is to be displayed.

  DATA: t_record_tab LIKE TABLE OF seahlpres.
  DATA: it_dynp TYPE STANDARD TABLE OF dynpread.
  DATA: wa_dynp TYPE dynpread.

  IF callcontrol-step = 'RETURN'. "When user selection is completed !?
    READ TABLE shlp_tab. 
    
    record_tab[] = t_record_tab[]. 
    "When debugged, the record_tab's 'RECORD_TAB-STRING' holds data. 
    "Bt didn't know how to retrieve.

    IF shlp_tab-shlpname EQ 'Z15_SH_PRO'. 
      wa_dynp-fieldname = 'WA_SO_IT-DESCRIPTION'.
      wa_dynp-fieldvalue = 'Hello'. " Dummy value. Need to fill with actual value from search help.
      APPEND wa_dynp TO it_dynp.

      wa_dynp-fieldname = 'WA_SO_IT-UNIT_MES'.
      wa_dynp-fieldvalue = 'World'. " Dummy value. Need to fill with actual value from search help.

      APPEND wa_dynp TO it_dynp.
      CLEAR wa_dynp.

      " This updated the table control with the dummy value.
      " But didn't know how to fill at the same row where the user clicks the search help.
      " Currently it's always filled at the bottom of table control.
      CALL FUNCTION 'DYNP_UPDATE_FIELDS'
        EXPORTING
          dyname                         = 'SAPMZ_15081947_SO' " Module Pool name
          dynumb                         = '9000' "Screen Number
          request                        = 'A'
*         START_SEARCH_IN_CURRENT_SCREEN = ' '
*         START_SEARCH_IN_MAIN_SCREEN    = ' '
*         START_SEARCH_IN_STACKED_SCREEN = ' '
*         START_SEARCH_ON_SCR_STACKPOS   = ' '
*         SEARCH_OWN_SUBSCREENS_FIRST    = ' '
*         SEARCHPATH_OF_SUBSCREEN_AREAS  = ' '
        TABLES
          dynpfields                     = it_dynp
        EXCEPTIONS
          invalid_abapworkarea           = 1
          invalid_dynprofield            = 2
          invalid_dynproname             = 3
          invalid_dynpronummer           = 4
          invalid_request                = 5
          no_fielddescription            = 6
          undefind_error                 = 7
          OTHERS                         = 8.
      IF sy-subrc <> 0.
        * Implement suitable error handling here
        MESSAGE 'Error in updating the fields' TYPE 'E'.
      ENDIF.
    ENDIF.
  ENDIF.
ENDFUNCTION.

When debugged, the record_tab's 'RECORD_TAB-STRING' holds data. But didn't know how to retrieve. 'DYNP_UPDATE_FIELDS' function module updated the table control with the dummy value. But didn't know how to fill at the same row where the user clicks the search help. Currently when selected the search help, it's always filled at the bottom of table control. Is there another function module available to update table control?

2 REPLIES 2
Read only

Sandra_Rossi
Active Contributor
1,331

You can do it with DDIC only, no need of ABAP.

All the screen fields in your table control must be named as components of the same DDIC structure, let's name it ZSTR_15081947_SO, instead of WA_SO_IT.

Your search help Z15_SH_PRO must have the fields ID, DESCRIPTION and UNIT_MES defined as EXPORTING.

Define the fields of ZSTR_15081947_SO as follows:

  • ID : here attach the search help Z15_SH_PRO, and link its exporting fields ID, DESCRIPTION and UNIT_MES to the eponymous fields of the structure.
  • DESCRIPTION (no need to attach search help)
  • UNIT_MES (no need to attach search help)

When you press F4 on field ZSTR_15081947_SO-ID and you select one entry, the three screen fields ID, DESCRIPTION, UNIT_MES are automatically filled with the selected entry.

Read only

DoanManhQuynh
Active Contributor
0 Likes
1,331

as i remember you should find a sample demo about search help in table control, try search program name DEMO_DYNPRO*... or package SABAPDEMOS.