Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding the selecting field values (Select Options) is getting refreshed each time u press the F4help button

0 Kudos
118

Hi Team,

I have created an F4 help for the select option.

Please find the below code.

   REPORT ytest.
DATA: v_field TYPE fieldname.

SELECT-OPTIONS: s_field FOR v_field NO INTERVALS.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name = 'S_FIELD-LOW'.
      screen-input = '0'.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_field-low.

* Local type declarations
  TYPES : BEGIN OF t_flds,
    tabname   TYPE dfies-tabname,
    fieldname TYPE dfies-fieldname,
    keyflag   TYPE dfies-keyflag,
    fieldtext TYPE dfies-fieldtext,
  END OF t_flds.

  CONSTANTS: lc_field TYPE fieldname  VALUE 'FIELDNAME'.

* Local data declarations
  DATA:
        ls_flds TYPE t_flds,
        lt_flds TYPE STANDARD TABLE OF t_flds,
        ls_values TYPE ddshretval,
        lt_values TYPE STANDARD TABLE OF ddshretval,
        l_values  TYPE STANDARD TABLE OF ddshretval,
        lt_dfies TYPE TABLE OF dfies,
        ls_dfies TYPE dfies.

* Get field details of the Table
  CALL FUNCTION 'DDIF_FIELDINFO_GET'
    EXPORTING
      tabname        = 'MARC''
      langu          = sy-langu
    TABLES
      dfies_tab      = lt_dfies
    EXCEPTIONS
      not_found      = 1
      internal_error = 2
      OTHERS         = 3.
  IF sy-subrc = 0.
    LOOP AT lt_dfies  INTO ls_dfies WHERE fieldname NE 'MANDT'.
      MOVE-CORRESPONDING ls_dfies TO ls_flds.
      APPEND ls_flds TO lt_flds.
    ENDLOOP.
  ELSE.
    EXIT.
  ENDIF.
  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      retfield        = lc_field
      window_title    = 'Select the Table Field'(001)
      dynpprog        = sy-repid
      dynpnr          = sy-dynnr
      dynprofield     = 'S_FIELD-LOW'
      value_org       = 'S'
      multiple_choice = 'X'
      display         = 'F'
    TABLES
      value_tab       = lt_flds
      return_tab      = lt_values.

  IF sy-subrc EQ 0.
    l_values[] = lt_values[].
  ENDIF.


  s_field-sign    = 'I'.
  s_field-option  = 'EQ'.

  LOOP AT l_values INTO ls_values .
    s_field-low = ls_values-fieldval.
    APPEND s_field.
  ENDLOOP.

  DATA: lt_dynpread   TYPE STANDARD TABLE OF dynpread,
        lwa_dynpread  TYPE dynpread.

  READ TABLE s_field INDEX 1.
  IF sy-subrc = 0.
    lwa_dynpread-fieldname  = 'S_FIELD-LOW'.
    lwa_dynpread-fieldvalue = s_field-low.
    APPEND lwa_dynpread TO lt_dynpread.

*  Update the screen field values
    CALL FUNCTION 'DYNP_VALUES_UPDATE'
      EXPORTING
        dyname               = sy-repid
        dynumb               = sy-dynnr
      TABLES
        dynpfields           = lt_dynpread
      EXCEPTIONS
        invalid_abapworkarea = 1
        invalid_dynprofield  = 2
        invalid_dynproname   = 3
        invalid_dynpronummer = 4
        invalid_request      = 5
        no_fielddescription  = 6
        undefind_error       = 7
        OTHERS               = 8.
    IF sy-subrc NE 0.

    ENDIF.

  ENDIF.

It will show checkboxes for the fields when you execute the program. once you select the field and go back again to update your selection it will get refreshed and the field which you selected initially will be unchecked. I need to retain my first selection and it should not get unchecked.

Please let me know how can we go about it.

Regards

Sunil Kumar

1 ACCEPTED SOLUTION

Former Member
0 Kudos
65

Hi Sunil,


Use the MARK_TAB import parameter of FM F4IF_INT_TABLE_VALUE_REQUEST. It accepts row numbers which you want to be marked. You will have to write a logic to see which ones were marked the last time you ran it. 

Regards,

Shravan

5 REPLIES 5

Former Member
0 Kudos
66

Hi Sunil,


Use the MARK_TAB import parameter of FM F4IF_INT_TABLE_VALUE_REQUEST. It accepts row numbers which you want to be marked. You will have to write a logic to see which ones were marked the last time you ran it. 

Regards,

Shravan

0 Kudos
65

Hi Shravan,

Thanks for your response but mark_tab is not getting filled with any sort of information. I did include the same in the export parameter and when I check @runtime it is blank.

Please advise.

Regards

Sunil Kumar.

0 Kudos
65

Hi Sunil,

I meant you need to populate the mark_tab in your program. It is an importing parameter for the FM. Add the bold piece of code into your test program and you will see what I mean. The older selections will already be there in S_FIELD. Based on the older selection just edit your mark_tab. 

   DATA mark_tab TYPE ddshmarks.

   DATA mark_str TYPE LINE OF ddshmarks.

   LOOP AT lt_flds INTO ls_flds.

     IF ls_flds-fieldname IN s_field AND NOT s_field[] IS INITIAL.

       mark_str = sy-tabix.

       APPEND mark_str TO mark_tab.

     ENDIF.

   ENDLOOP.


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

     EXPORTING

       retfield        = lc_field

       window_title    = 'Select the Table Field'(001)

       dynpprog        = sy-repid

       dynpnr          = sy-dynnr

       dynprofield     = 'S_FIELD-LOW'

       value_org       = 'S'

       multiple_choice = 'X'

       display         = 'F'

       mark_tab        = mark_tab

     TABLES

       value_tab       = lt_flds

       return_tab      = lt_values.

Regards,

Shravan

0 Kudos
65

Hi Sravan,

Thanks a lot and my problem resolved.

Sunil Kumar.

Former Member
0 Kudos
65

I copied your program in my system and ran it. I doubt if it is possible to tick mark those fields.

But when you click on "More button" next to fields, you do get all the fields. So, whatever you had selected, is retained, just the selection has gone.

Also, this seems right.

When you go for search help of standard programs, you never get the selected entries as pre-populated.

So, just delete duplicates from the s_fields during the event AT SELECTION SCREEN OUTPUT.

That wont bother you much on technical side.