SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Create a ComboBox



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Sep 22, 2007 6:51 pm    Post subject: Create a ComboBox Reply with quote

Code:
OCX -Control ( Combobox)
 
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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.