Application Development and Automation 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: 
Read only

sorting in drop down

Former Member
0 Likes
2,362

hello,  i have designed a module pool program.i have two drop downs for two fields.now my aim is that when i select field1 then the contents of field2 are sorted according to field1.

i have applied F4IF_INT_TABLE_VALUE_REQUEST for this but it is not working.kindly suggest me how to clear this doubt.

1 ACCEPTED SOLUTION
Read only

kerem_kayacan
Active Participant
0 Likes
1,847

Did you assign a function code to the first field? Otherwise PAI will not get triggered.

13 REPLIES 13
Read only

Former Member
0 Likes
1,847

This thread: http://scn.sap.com/thread/2128554 should have the answer you looking for, otherwise kindly revert back with more specify query.

Regards,

Xavier

Read only

Former Member
0 Likes
1,847

Use the following Function Module VRM_SET_VALUES

Pass the list after sorting on the basis of condition ( by checking the first drop down)

Sample Code

sort_key = drop_down_first .

Sort list by sort_key .

  call function 'VRM_SET_VALUES'

       exporting

            id     = drop_down_second_id

            values = list.

Hope this help you...

Read only

0 Likes
1,847

MODULE GET OUTPUT Is my module for drop down first.and get1 is for drop down second.i have attached the both the modules.please tell how to proceed.

MODULE get OUTPUT.

  IF a = 0.

    wa-key = 'NORTH'.

*WA-TEXT = 'NORTH'.

    APPEND wa TO etab.

    CLEAR wa.

    wa-key = 'EAST'.

*WA-TEXT = 'EAST'.

    APPEND wa TO etab.

    CLEAR wa.

    wa-key = 'SOUTH'.

*WA-TEXT = 'SOUTH'.

    APPEND wa TO etab.

    CLEAR wa.

    wa-key = 'WEST'.

*WA-TEXT = 'WEST'.

    APPEND wa TO etab.

    CLEAR wa.

**    wa-key = 'ALL'.

***WA-TEXT = 'ALL'.

**    APPEND wa TO etab.

**    CLEAR wa.

    CALL FUNCTION 'VRM_SET_VALUES'

      EXPORTING

        id     = 'ZBS1_BRAND-ZONE1'

        values = etab.

* EXCEPTIONS

*   ID_ILLEGAL_NAME       = 1

*   OTHERS                = 2

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    a = 1.

  ENDIF.

ENDMODULE.                 " GET  OUTPUT

MODULE get1 OUTPUT.

  IF a1 = 0.

    SELECT  state

       FROM  zbs_state

       INTO  CORRESPONDING FIELDS OF itab1.

      wa1-key  = itab1-state.

      APPEND wa1 TO etab1.

      CLEAR wa1.

    ENDSELECT.

    CALL FUNCTION 'VRM_SET_VALUES'

      EXPORTING

        id     = 'ZBS_STATE-STATE'

        values = etab1.

* EXCEPTIONS

*   ID_ILLEGAL_NAME       = 1

*   OTHERS                = 2

    .

    IF sy-subrc <> 0.

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

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

    ENDIF.

    a1 = 1.

  ENDIF.

ENDMODULE.                 " GET1  OUTPUT

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,847

hello,  i have designed a module pool program.i have two drop downs for two fields.now my aim is that when i select field1 then the contents of field2 are sorted according to field1.

Do you mean filtered according to field1 ?

Regards,

Raymond

Read only

0 Likes
1,847

yes.i have a table in which both the fields are stored.now i want to filter field2 according to field1 selected in first drop down.

Read only

0 Likes
1,847

So

- use VRM_SET_VALUES to fill both list of values in PBO using the current value of field1 for the list of field2.

- Add a function code to field1 so it will trigger a PAI/PBO cycle when a value is selected, so field2 list will be updated.

- Of course in PAI user command module, ignore this function code to stay on same dynpro (or use it to bypass any other check/action)

Regards,

Raymond

Read only

kerem_kayacan
Active Participant
0 Likes
1,848

Did you assign a function code to the first field? Otherwise PAI will not get triggered.

Read only

0 Likes
1,847

i have assigned but i dont know how to work on that.

Read only

0 Likes
1,847

Function code is only useful to trigger PAI and PBO. You have to sort your table according to your requirement in every screen cycle. If you are already doing this, it should work. Is it clear?

Read only

0 Likes
1,847

Function code is use to triggered PAI and PBO module as said by Kerem.

Check sy-ucomm in orde to check the fucntion code value.

Data: lv_syucomm type sy-ucomm.

v_syucomm = sy=ucomm.  " This must be your first line in PAI

case lv_syucomm.

   

    case  'lv_functioncode'   ''The function code you have assigned

                 here you can re arrange the list as per the per value of First Drop Down List

   case

..... . . so on

endcase.

Hope you now able to check

Read only

0 Likes
1,847

i have done in the similar way but still its not working for this.

Read only

0 Likes
1,847

Follwing is the code

Proram Code

Data Declarations

TYPE-POOLS vrm.
DATA:  ok_code TYPE sy-ucomm,
             save_ok TYPE sy-ucomm.
DATA:   wa_first TYPE vrm_value,
             it_first TYPE vrm_values.
DATA:  wa_second TYPE vrm_value,
             it_second TYPE vrm_values.
DATA: drp_first_id TYPE vrm_id,
            drp_second_id TYPE vrm_id.
DATA: drp_first TYPE char1,
            drp_second TYPE char2.

Notes: drp_first and drp_second is the same name of list box on a screen. Also drp_first is having Function Code "SELECT" .

Note: Following is the code for PBO

MODULE status_1000 OUTPUT.

drp_first_id = 'DRP_FIRST'.
drp_second_id = 'DRP_SECOND'.

Note: Above mentioned variables is assigned the name of list box shown on a Screen . Names are in CAPS ON


*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.
IF it_first IS INITIAL.
    wa_first-text = 'Ascending'.
    wa_first-key = 'A'.
    APPEND wa_first TO it_first.

    wa_first-text = 'Descending'.
    wa_first-key = 'D'.
    APPEND wa_first TO it_first.

ENDIF.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = drp_first_id
      values          = it_first
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

IF it_second IS INITIAL.
    wa_second-text = 'First'.
    wa_second-key = 'F'.

    APPEND wa_second TO it_second.
    wa_second-text = 'Second'.
    wa_second-key = 'S'.
    APPEND wa_second TO it_second.
    CALL FUNCTION 'VRM_SET_VALUES'
      EXPORTING
        id              = drp_second_id
        values          = it_second
      EXCEPTIONS
        id_illegal_name = 1
        OTHERS          = 2.
  ENDIF.
ENDMODULE

Note: Following is the code for the PAI

MODULE user_command_1000 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.

   Note: Following is the code that contains the logic for sorting the values for second drop down list on the basis of selection of first drop down list. The variable drp_first will contains the Key of the value selected by the user
    WHEN 'SELECT'.
      CASE drp_first.
        WHEN 'A'.
          SORT it_second BY text ASCENDING .
        WHEN 'D'.
          SORT it_second BY text DESCENDING.
      ENDCASE.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id              = drp_second_id
          values          = it_second
        EXCEPTIONS
          id_illegal_name = 1
          OTHERS          = 2.
  ENDCASE.
ENDMODULE.

Following is the flow logic

process before output.
module status_1000.
process after input.
module exit at exit-command.
module user_command_1000.

I here used PAI module . It is better to use Process on Value Request. The overall logic will remain same.

Happy coding

Sandeep

Read only

0 Likes
1,847

thank you Mr.Sandeep for your response.although the concept is working but when i am taking fields from data dictionary its not working.