F4 Input Help To Show Customer Number

How to code this in ABAP:

tables: kna1.
parameters: country type kna1-land1.
parameters: custno for kna1-kunnr.

when input value in the country field, the F4 input help should show customer number of that country only.   This should occur on the selection screen.
 

Here is the complete code for your reference:

First it will fetches the data that user had selected for the country using the function module "DYNP_VALUES_READ" and store the values in the scrnvalues table for the field name 'country'.  From there we read the values of the field using the field name fldvalues-fieldvalue and check for the table KNA1 and store it in the itab.  Then we call the function module " F4IF_INT_TABLE_VALUE_REQUEST" and pass the itab to display for the help.  All these are done on the event AT SELECTION-SCREEN ON VALUE-REQUEST.

See the sample code below....

******
REPORT  YF4CUSTOMER
                          .
tables: kna1.
parameters: country type kna1-land1.
parameters: custno type kna1-kunnr.
data: begin of itab occurs 0,
        kunnr like kna1-kunnr,
      end of itab.

*** INTERMEDIATE VARAIBLE TO STORE THE VALUES OF SELECTED FIELDS*** 
DATA : SCRNVALUES TYPE TABLE OF DYNPREAD,
       FLDVALUES LIKE LINE OF SCRNVALUES.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR CUSTNO.
***TO RETERIVE THE VALUES FOR THE CHECK INPUT *****
  FLDVALUES-FIELDNAME = 'COUNTRY'.
  APPEND FLDVALUES TO SCRNVALUES.
***TO GET THE VALUES STORED IN THE PARTICULAR FIELD **** 
CALL FUNCTION 'DYNP_VALUES_READ'
  EXPORTING
    DYNAME                         = SY-REPID
    DYNUMB                         = SY-DYNNR
*   TRANSLATE_TO_UPPER             = ' '
*   REQUEST                        = ' '
*   PERFORM_CONVERSION_EXITS       = ' '
*   PERFORM_INPUT_CONVERSION       = ' '
*   DETERMINE_LOOP_INDEX           = ' '
  TABLES
    DYNPFIELDS                     = SCRNVALUES
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

*** SINCLE WE HAVE 1 FIELD RETREIVE THE VALUE AT INDEX ROW 1.
READ TABLE SCRNVALUES INDEX 1 INTO FLDVALUES.

** STORE THE RETERIVED VALUES IN THE INTERNAL TABLE****
select kunnr from kna1 into table itab where land1 eq
FLDVALUES-FIELDVALUE.

** FUNCTION TO ATTACH THE INTERNAL TABLE WITH FIELD VALUE ***
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
  EXPORTING
*   DDIC_STRUCTURE         = ' '
    RETFIELD               = 'kunnr'
*   PVALKEY                = ' '
   DYNPPROG               = sy-repid
   DYNPNR                 = sy-dynnr
   DYNPROFIELD            = 'custno'
*   STEPL                  = 0
*   WINDOW_TITLE           =
*   VALUE                  = ' '
   VALUE_ORG              = 'S'
*   MULTIPLE_CHOICE        = ' '
*   DISPLAY                = ' '
*   CALLBACK_PROGRAM       = ' '
*   CALLBACK_FORM          = ' '
*   MARK_TAB               =
* IMPORTING
*   USER_RESET             =
  TABLES
    VALUE_TAB              = itab.

start-of-selection.
write:/ 'OUTPUTS

--> End of Abap coding

ABAP

See Also:
ABAP Function Example - HR_IN_CHG_INR_WRDS

Tables
Database Table

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.