Skip to Content
0
Mar 03, 2009 at 10:11 AM

Change field length dynamically

719 Views

Hi,

I have created a customized infotype with several fields to which dropdown facility should be provided.

I am getting the details of dropdown from a Z-table and storing it in an internal table , later I am passing the internal table contents to below function module.

I am using the function module F4IF_INT_TABLE_VALUE_REQUEST in POV block for a field to provide F4 functionality.

*Requirement:The user wants the screen field length to change dynamically based on the maximum length of the dropdown it has.*

Solution: I have written the below code in Process on value request block for the input field:

P9011-ELIGIBILITY.

SELECT zbkey zekey zedescription

FROM zeoptions

INTO TABLE gt_zeoptions.

REFRESH gt_return.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = 'ZEDESCRIPTION'

  • PVALKEY = ' '

dynpprog = sy-cprog

dynpnr = sy-dynnr

dynprofield = 'P9011-ELIGIBILITY'

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

value_org = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

TABLES

value_tab = gt_zeoptions

  • FIELD_TAB =

return_tab = gt_return

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 2

  • OTHERS = 3

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*

LOOP AT SCREEN.

CHECK screen-name = 'P9011-ELIGIBILITY'.

READ TABLE gt_return INTO gs_return INDEX 1.

IF sy-subrc = 0.

screen-length = STRLEN( gs_return-fieldval ).

MODIFY SCREEN.

ENDIF.

ENDLOOP.

This code will change the screen length dynamically based on the input text length.

But on hitting ENTER,the screen field length is defaulting to original length.

Pease help how to set the length back to the input text field length?