Skip to Content
author's profile photo Former Member
Former Member

How to populate dropdown without triggering PAI event ?


I have a screen with two fields- One input field and one drop down list field which has to be populated based on the value given in the first field.

How can I populate the drop down list dynamically based on first input field without pressing enter ( i.e with out triggering PAI event ) . I tried using DYNP_VALUES_READ in value request event.

Please give me your suggestions .

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on Mar 10, 2010 at 08:11 AM

    Refer to this program demo_dynpro_dropdown_listbox . It does what you need.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2010 at 12:47 AM

    If your first field is a simple input field then you will need to enter PAI so that the application server gets the field value in order for your ABAP logic to know what new values to put in the listbox.

    ( The demo program mentioned above does enter PAI by putting a user-command of "CARRIER" on the first listbox... that causes it to call screen 200 with the second listbox on )


    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 11, 2010 at 02:49 AM

    Hhhhmm, I thought initially it should work, but I must admit I couldn't get it to work with a listbox. I just tried a simple report with selection screen, see below. Just enter something for the first parameter and then choose the value help for the second field. You will see that it will pick up the value from the first field, if we don't use a listbox.

    Once you comment in the coding the LISTBOX and replace it with the normal field, you can see that the value help works as one would hope. It seems that the problem is that the values for the dropdown list get populated too early (i.e. start-up of the report). I don't have the time at the moment to check this out further, but I'm assuming others must have tried this before. Any comments?

    REPORT zvaluehelp.
      p_statva TYPE stacust-statva,
      p_status TYPE stacust-status AS LISTBOX VISIBLE LENGTH 3. " Doesn't work
    *  p_status TYPE char1. " Value-help works for this
      PERFORM value_help.
    FORM value_help.
        dynpread TYPE dynpread,
        dynpread_tab TYPE STANDARD TABLE OF dynpread,
        stacust TYPE stacust,
        stacust_tab TYPE STANDARD TABLE OF stacust.
      dynpread-fieldname = 'P_STATVA'.
      APPEND dynpread TO dynpread_tab.
          dyname                   = sy-repid
          dynumb                   = sy-dynnr
          perform_conversion_exits = 'X'
          dynpfields               = dynpread_tab
          OTHERS                   = 1.
      CHECK sy-subrc = 0.
      READ TABLE dynpread_tab INTO dynpread INDEX 1.
      CHECK dynpread-fieldvalue IS NOT INITIAL.
      SELECT * FROM stacust INTO TABLE stacust_tab
               WHERE statva = dynpread-fieldvalue.
      CHECK sy-subrc = 0.
          ddic_structure = 'STACUST'
          retfield       = 'STATUS'
          dynpprog       = sy-repid
          dynpnr         = sy-dynnr
          dynprofield    = 'P_STATUS'
          value_org      = 'S'
          value_tab      = stacust_tab
          OTHERS         = 0.

    The coding above was just intended as a quick test - so I know it's not proper (i.e. check of return codes, etc.).

    Cheers, harald

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 11, 2010 at 06:04 AM

    HI Kusuma,

    Check the Below threads, Let us know if you have any issues

    There is no way you can trigger PAI without entering with an Input Field but there is a work around

    in PBO

    refresh fields.
    clear fields.
    fields-tabname = 'MARA'. " Just Copy and Execute this
    fields-fieldname = 'MATNR'.
    fields-field_obl = 'X'. " To make this Field mandatory
    APPEND fields.
    *   NO_VALUE_CHECK        = ' '
        popup_title           = 'Give your Title'
    *   START_COLUMN          = '5'
    *   START_ROW             = '5'
    *   RETURNCODE            = RETURNCODE
        fields                = fields " For more info Take Where used List on this FM
    *   ERROR_IN_FIELDS       = 1
    *   OTHERS                = 2
    " By the time you call the List Box FM(VRM_SET_VALUES) the value entered is available to you

    Then as mentioned in the below threads Populate your List Box

    I have successfully implemented this in 2 objects

    how to trigger PAI

    populate drop down menu based on entry in another field

    In the second thread dropdown based on another Dropdown but you can adopt the Second drop down based on the First input Field.

    Hope this serves your purpose.



    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 12, 2010 at 06:45 AM

    Hi Kusuma,

    Try this FM SAPGUI_SET_FUNCTIONCODE before your code for drop-down population. This actually gives the funtionality of ENTER within the program itself. Here is the sample code:



    functioncode = '/00'


    function_not_supported = 1.

    IF sy-subrc <> 0.

    MESSAGE w000 WITH text-001.


    '/00' is the code for ENTER.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.