ABAP – Using a Dropdown to Populate Multiple Fields

Home / SAP / ABAP Coding / ABAP – Using a Dropdown to Populate Multiple Fields

Now, since I’ve been on a roll talking about the VALUE-REQUEST and some of the fun tricks I’ve been discovering.  Today, I’m going to give you some sample code to populate multiple values with a single dropdown.  Often, when I create a screen, I’m using some combination like sales order & line item, material & plant, etc…  so I wanted to know how I could use a single dropdown to populate multiple fields.  Here you go.  This is for VBELN & POSNR.  Now, keep in mind, I used the trick from yesterday to get the sales order number (if it’s populated) so that the pull down will work smarter.

SELECT vbeln posnr
FROM vbap
INTO TABLE lt_sh
UP TO 200 ROWS
WHERE VBELN = GV_VBELN.

” Set return fields

” Order
CLEAR ls_map.
ls_map-fldname = ‘F0001’.        ” Set that field 1
ls_map-dyfldname = ‘GV_VBELN’.
APPEND ls_map TO lt_map.
” Item
CLEAR ls_map.
ls_map-fldname = ‘F0002’.        ” Set that field 2
ls_map-dyfldname = ‘GV_POSNR’.
APPEND ls_map TO lt_map.

” Call Search Help Popup Function
CALL FUNCTION ‘F4IF_INT_TABLE_VALUE_REQUEST’
EXPORTING
retfield        = ‘POSNR’
dynpprog        = sy-repid
dynpnr          = sy-dynnr
dynprofield     = ‘VBAP-POSNR’
value_org       = ‘S’
TABLES
value_tab       = lt_sh
dynpfld_mapping = lt_map
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS          = 3.

That’s all there is to it.  You’ll still need to review my previous posts: dropdown list for characteristic values and dropdown list along with reading a dynpro value to pull it all together, but it should give you all the tricks you’ll ever need to use the VALUE-REQUEST.  I hope this makes sense on how you can use a dropdown to populate multiple fields.  Thanks for reading.

As always, thanks for reading and don't forget to check out our SAP Service Management Products at my other company JaveLLin Solutions,
Mike

Leave a Reply

Your email address will not be published. Required fields are marked *