Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in Filling Listbox on some event

Hi All,

I am building a Module pool on which i have two pictures now the requirement is that when the user clicks on the picture then the list box should fill with the values. I have developed the program seeing :

DEMO_DYNPRO_DROPDOWN_LISTBOX

DEMO_DROPDOWN_LIST_BOX

You can see the code below.

&----


*& Report Z_PM_PICTURE

*&

&----


*&

*&

&----


REPORT Z_PM_PICTURE.

tables : itob,

viqmel.

TYPE-POOLS : vrm.

*Class Defination

CLASS C_EVENT_RECEIVER DEFINITION.

PUBLIC SECTION.

METHODS EVENT_HANDLER_PICTURE_DBLCLICK

FOR EVENT PICTURE_DBLCLICK OF CL_GUI_PICTURE

IMPORTING MOUSE_POS_X MOUSE_POS_Y SENDER.

ENDCLASS. "c_event_receiver DEFINITION

*Data that is to be used in class or on screen like

  • custom controls, buttons etc

DATA : FUNCTION LIKE SY-UCOMM,

pic_container(10) type c,

URL TYPE CNDP_URL,

URL2 TYPE CNDP_URL,

PICTURE_CONTROL_1 TYPE REF TO CL_GUI_PICTURE,

PICTURE_CONTROL_2 TYPE REF TO CL_GUI_PICTURE,

CONTAINER_1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

CONTAINER_2 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

EVENT_RECIEVER TYPE REF TO C_EVENT_RECEIVER, "Variable of class type

EVENT_TAB TYPE CNTL_SIMPLE_EVENTS,

EVENT_TAB_LINE TYPE CNTL_SIMPLE_EVENT,

RETURN TYPE I.

data : begin of it_equipment occurs 0.

include STRUCTURE viqmel.

data : end of it_equipment.

  • *Data for list selection

DATA : name TYPE vrm_id,

list TYPE vrm_values,

value LIKE LINE OF list.

DATA : rd1 TYPE c,

rd2 TYPE c.

data flag type i.

name = 'VIQMEL-EQUNR'.

value-key = 'A'.

append value to list.

call screen 200.

&----


*& Class (Implementation) C_EVENT_RECEIVER

&----


  • Text

----


class C_EVENT_RECEIVER implementation.

METHOD EVENT_HANDLER_PICTURE_DBLCLICK.

  • Decleration of variables that we have to import

DATA : POS_X(5) TYPE C,

POS_Y(5) TYPE C.

MOUSE_POS_X = POS_X.

MOUSE_POS_Y = POS_Y.

IF SENDER = PICTURE_CONTROL_1.

flag = 1.

perform fill_list1.

  • pic_container = SENDER.

  • select equnr from itob where itob-strot = '

  • MESSAGE I000(OK) WITH

  • 'Double Click' 'Upper Picture' POS_X POS_Y.

ENDIF.

ENDMETHOD.

endclass. "C_EVENT_RECEIVER

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


module STATUS_0200 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

  • perform fill_list.

IF PICTURE_CONTROL_1 IS INITIAL.

  • Create Controls

CREATE OBJECT CONTAINER_1

EXPORTING CONTAINER_NAME = 'PICTURE_CONTROL_1'.

CREATE OBJECT CONTAINER_2

EXPORTING CONTAINER_NAME = 'PICTURE_CONTROL_2'.

CREATE OBJECT PICTURE_CONTROL_1

EXPORTING PARENT = CONTAINER_1.

CREATE OBJECT PICTURE_CONTROL_2

EXPORTING PARENT = CONTAINER_2.

  • Registering Events

EVENT_TAB_LINE-EVENTID = CL_GUI_PICTURE=>EVENTID_PICTURE_DBLCLICK. "evnt_id_picture_dblclcick is in attributes of cl_gui_picture

APPEND EVENT_TAB_LINE TO EVENT_TAB.

CALL METHOD picture_control_1->set_registered_events

EXPORTING

events = event_tab.

call METHOD picture_control_2->set_registered_events

exporting

events = event_tab.

*Create the event_receiver object and set the handlers for the

*events of the picture control.

create object event_reciever.

*For picture_control_1

set HANDLER event_reciever->event_handler_picture_dblclick

for picture_control_1.

*For picture_control_2

set HANDLER event_reciever->event_handler_picture_dblclick

for picture_control_2.

*Set the display mode to 'normal'

call METHOD picture_control_1->set_display_mode

exporting display_mode = cl_gui_picture=>display_mode_normal.

call METHOD picture_control_2->set_display_mode

EXPORTING display_mode = cl_gui_picture=>display_mode_normal.

  • Set 3D Border

CALL METHOD picture_control_1->set_3d_border

EXPORTING border = 1.

CALL METHOD picture_control_2->set_3d_border

exporting border = 2.

  • FM for loading the picture URL and then we wil call

  • method LOAD_PICTURE_FROM_URL_ASYNC of PICTURE_CONTROL_1

  • similarly we will do it for PICTURE_CONTRIL_2.

CALL FUNCTION 'DP_PUBLISH_WWW_URL'

EXPORTING

OBJID = 'ZBHILAI_LOGO'

LIFETIME = cndp_lifetime_transaction

IMPORTING

URL = url

EXCEPTIONS

OTHERS = 1

.

IF SY-SUBRC = 0.

call method picture_control_1->load_picture_from_URL_ASYNC

exporting url = url.

ENDIF.

CALL FUNCTION 'DP_PUBLISH_WWW_URL'

EXPORTING

OBJID = 'BHILAI_STEEL_HEADER'

LIFETIME = cndp_lifetime_transaction

IMPORTING

URL = url2

EXCEPTIONS

OTHERS = 1

.

IF SY-SUBRC = 0.

call method picture_control_2->load_picture_from_url_async

exporting url = url2.

ENDIF.

endif.

endmodule. " STATUS_0200 OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


module USER_COMMAND_0200 input.

if flag = 1.

perform fill_list.

endif.

endmodule. " USER_COMMAND_0200 INPUT

&----


*& Module fill_listbox INPUT

&----


  • text

----


*module fill_listbox input.

  • select equnr into CORRESPONDING FIELDS OF TABLE it_equipment from itob.

*

*CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

  • EXPORTING

    • DDIC_STRUCTURE = ' '

  • retfield = 'EQUNR'

    • PVALKEY = ' '

    • DYNPPROG = ' '

    • DYNPNR = ' '

    • DYNPROFIELD = ' '

    • STEPL = 0

    • WINDOW_TITLE =

    • VALUE = ' '

  • value_org = 'S'

    • MULTIPLE_CHOICE = ' '

    • DISPLAY = ' '

    • CALLBACK_PROGRAM = ' '

    • CALLBACK_FORM = ' '

    • MARK_TAB =

    • IMPORTING

    • USER_RESET =

  • TABLES

  • value_tab = it_equipment

    • FIELD_TAB =

    • RETURN_TAB =

    • 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.

*endmodule. " fill_listbox INPUT

&----


*& Form fill_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_list .

SELECT equnr

FROM viqmel

INTO CORRESPONDING FIELDS OF it_equipment.

value-key = it_equipment-equnr.

if value-key <> ''.

APPEND value TO list.

endif.

ENDSELECT.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = name

values = list

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.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

retfield = 'VIQMEL-EQUNR'

  • PVALKEY = ' '

  • DYNPPROG = ' '

  • DYNPNR = ' '

DYNPROFIELD = 'VIQMEL-EQUNR '

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

VALUE_ORG = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

tables

value_tab = list[]

  • FIELD_TAB =

  • RETURN_TAB =

  • 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.

endform. " fill_list

&----


*& Form fill_list1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fill_list1 .

if flag = 1.

PERFORM fill_list.

endif.

endform. " fill_list1

You can see that i have commented the module_fill_list i have seen this logic in program RSDEMO_DROPDOWN_LISTBOX but here its not working. So i have written a perfrom fill_list in which i am using VRM_SET_VALUES and also F4IF_INT_TABLE_VALUE_REQUEST FM its working but i m getting a F4 help screen after i click the picture i don't want it.

Please suggest what can i do.

Thanks and Regards,

Rachit Khanna

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question