I've used the exit MM06E005 for adding custom fields at header and item levels on the purchase order screens. I want to populate certain custom fields at item level based on the material number entered by the user. I tried using DYNP_READ_VALUES but the FM is giving an error all the time even when I tried passing different values for DYNAME and DYNUMB. The FM is called from different screens in different situations, so i'm not sure what value to pass for DYNNR. Once i get the value of material number entered by the user at the current line item i want to read a z-table to populate the custom fields i've added. Below is my code written in the Items PAI function module EXIT_SAPMM06E_017:
data: scr_fields type table of dynpread WITH HEADER LINE.
scr_fields-fieldname = 'EMATN'.
append scr_fields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
DYNAME = 'SAPLXM06'
DYNUMB = '0014'
* TRANSLATE_TO_UPPER = ' '
* REQUEST = ' '
* PERFORM_CONVERSION_EXITS = ' '
* PERFORM_INPUT_CONVERSION = ' '
* DETERMINE_LOOP_INDEX = ' '
* 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 = scr_fields
EXCEPTIONS
INVALID_ABAPWORKAREA = 1
INVALID_DYNPROFIELD = 2
INVALID_DYNPRONAME = 3
INVALID_DYNPRONUMMER = 4
INVALID_REQUEST = 5
NO_FIELDDESCRIPTION = 6
INVALID_PARAMETER = 7
UNDEFIND_ERROR = 8
DOUBLE_CONVERSION = 9
STEPL_NOT_FOUND = 10
OTHERS = 11
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Any valuable leads will be greatly appreciated.