SAP ABAP : Attach a Search Help to the Screen Field

I have a requirement to attach a search help to the screen field. When I click on the drop-down list, it should automatically pick the company code that is already displayed on the screen and show the results.
 
It dosent make any sense for search help to wait for user to input the same company code which is already displayed.

Use this functionality to get help.

FORM HELP_CHECK.
*-- Set up fields to retrieve data

  ltab_fields-tabname    = 'ZFI_PMNTADV'.
  ltab_fields-fieldname  = 'CHECT'.
  ltab_fields-selectflag = 'X'.
  APPEND ltab_fields.

  ltab_fields-tabname    = 'ZFI_PMNTADV'.
  ltab_fields-fieldname  = 'PMNT_ADV'.
  ltab_fields-selectflag = 'X'.
  APPEND ltab_fields.

  SORT ltab_fields.
  DELETE ADJACENT DUPLICATES FROM ltab_fields.

*-- Fill values
  SELECT chect
  INTO TABLE ltab_values
         FROM zfi_pmntadv
            WHERE pmnt_adv NE space.
  SORT ltab_values.
  DELETE ADJACENT DUPLICATES FROM ltab_values.

CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
     EXPORTING
          fieldname                 = 'chect'
          tabname                   = 'zfi_pmntadv'
          title_in_values_list      = 'Select a value'
     IMPORTING
          select_value              = so_chect
     TABLES
          fields                    = ltab_fields
          valuetab                  = ltab_values
     EXCEPTIONS
          field_not_in_ddic         = 01
          more_then_one_selectfield = 02
          no_selectfield            = 03.
 

ENDFORM.                    "fiscal_year

ABAP Tips by :  Anil Khandelwal

Fast Links:
Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

ABAP Tips
ABAP Forum for Discussion and Samples Program Codes for Abapers

Best regards,
SAP Basis, ABAP Programming and Other IMG Stuff
http://www.erpgreat.com

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.