Problem solve Get help with specific problems with your technologies, process and projects.

OCX -Control ( Combobox)

This is an example program to create a combobox in your ABAP program.

This is an example program to create a combobox in your ABAP program. You have to create screen ID as 1000 and...

call PBO and PAI (combopbo output and comboclick input)modules to get the proper result.


 REPORT ZCOMBOBOX.
tables usr03.
data : itabitems like listitem occurs 0 with header line,
       dname like usr03-bname,
       indx type i,
       itemname(256) type c,
       first(4) type c value 'true'.

TYPES: BEGIN OF CNTL_FONT,
         INIT(1) TYPE C,
         F_TYPE  TYPE I,
         BOLD    TYPE I,
         ITALIC  TYPE I,
         SIZE    TYPE I,
       END OF CNTL_FONT.

TYPES: BEGIN OF CNTL_HANDLE,
         OBJ LIKE OBJ_RECORD,
         SHELLID TYPE I,
         PARENTID TYPE I,
         C_TYPE(4) TYPE C,"CNTL_TYPE,
         CLSID  LIKE CNTLSTRLIS-NAME,
         ORIGIN LIKE SY-REPID,
         HANDLE_TYPE(10) TYPE C,
         LIFETIME TYPE I,
         PROGRAM LIKE SY-REPID,
         DYNNR LIKE SY-DYNNR,
         IMODE TYPE I,
         DYNPRO_POS TYPE I,
         GUID TYPE I,
       END OF CNTL_HANDLE.

data : CNTL_FONT_DEFAULTS TYPE CNTL_FONT.
data : CNTL_HANDLE_TEST TYPE CNTL_HANDLE.

cntl_font_defaults-f_type = 0.
cntl_font_defaults-bold = 1.
cntl_font_defaults-italic = 0.
cntl_font_defaults-size = 0.
cntl_font_defaults-init = ''.


select bname from usr03 into itabitems-item.
     append itabitems.
endselect.

call screen 1000.
*&---------------------------------------------------------------------*
*&      Module  COMBOCLICK  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE COMBOCLIK INPUT.

CALL FUNCTION 'COMBOBOX_GET_SELECTION'
     EXPORTING
          HANDLE            = CNTL_HANDLE_TEST
    IMPORTING
         INDEX             = indx
         ITEM              = itemname
    EXCEPTIONS
         CNTL_SYSTEM_ERROR = 1
         CNTL_ERROR        = 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.

message ID SY-MSGID TYPE 'E' NUMBER 1
        with itemname.


ENDMODULE.                 " COMBOCLICK  INPUT

*&---------------------------------------------------------------------*
*&      Module  COMBOPBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE COMBOPBO OUTPUT.

IF First = 'true'.
   First = 'false'.
   CALL FUNCTION 'OCX_COMBOBOX'
    EXPORTING
         LEFT            = 100
         TOP             = 20
         WIDTH           = 280
         HEIGHT          = 16
         FONT            = CNTL_FONT_DEFAULTS
         VISIBLE         = 'X'
         DISP_SCREEN     = '1000'
    IMPORTING
         COMBOBOX_HANDLE = CNTL_HANDLE_TEST
     TABLES
          LIST_ITEMS      = itabitems
    EXCEPTIONS
         LINK_ERROR      = 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.

ENDIF.

ENDMODULE.                 " COMBOPBO  OUTPUT
This was last published in September 2001

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close