2012 Oct 17 10:08 AM
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.
2012 Oct 17 11:11 AM
Did you assign a function code to the first field? Otherwise PAI will not get triggered.
2012 Oct 17 10:19 AM
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
2012 Oct 17 10:23 AM
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...
2012 Oct 17 10:41 AM
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
2012 Oct 17 10:46 AM
2012 Oct 17 10:49 AM
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.
2012 Oct 17 10:58 AM
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
2012 Oct 17 11:11 AM
Did you assign a function code to the first field? Otherwise PAI will not get triggered.
2012 Oct 17 11:25 AM
2012 Oct 17 11:42 AM
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?
2012 Oct 18 5:32 AM
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
2012 Oct 19 6:36 AM
i have done in the similar way but still its not working for this.
2012 Oct 19 10:24 AM
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
2012 Oct 20 6:54 AM
thank you Mr.Sandeep for your response.although the concept is working but when i am taking fields from data dictionary its not working.