This tip has been copied from SearchSap.com
Tip submitted by: srini s
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.
Code
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
Tuesday, July 15, 2008
sitemap SapMaterial.com Creating a combobox
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2009
(81)
-
▼
June
(81)
- Lists in Unicode Systems
- The File Interface in Unicode Programs
- Character String and Byte String Processing in Uni...
- Structure Enhancements and Unicode Programs
- Structure Typing in Unicode Programs
- Conversion of Structures in Unicode Programs
- Access to memory sequences in Unicode programs
- Offset and Length Specifications in Unicode Programs
- Alignment in Unicode Systems
- Operand Types in Unicode Programs
- Names in Unicode Programs
- Comments and Literals in Non-Unicode Programs
- Differences between Unicode and Non-Unicode Programs
- Unicode - Overview
- Statements in Class and Interface Pools
- Statements for Defining Classes and Interfaces
- ABAP Objects - Keywords
- Inheritance Events
- Inheritance and Events
- Inheritance and Instantiation
- Inheritance and Constructors
- Inheritance and Static Components
- Inheritance and the Component Namespace
- Inheritance and Visibility
- Inheritance and Interfaces
- Inheritance and Polymorphism
- Abstract and Final Methods and Classes
- Redefining Methods
- Inheritance
- Definition of Classes and Interfaces
- Object Orientation
- CLASS-METHODS - FOR EVENT
- CLASS-METHODS - class_constructor
- CLASS-METHODS - RETURNING
- METHODS - IMPORTING, EXPORTING, CHANGING, RAISING
- CLASS-METHODS - IMPORTING, EXPORTING, CHANGING, RA...
- CLASS-METHODS
- Kernel Methods
- The C Destructor in Methods
- Interface Parameters in Methods
- Data Types and Constants
- Events In Components of classes
- Constructors In Components of Classes
- Methods in Components of classes
- Attributes
- Visibility Sections in Classes
- Components of Classes
- Classes
- ABAP Objects
- ABAP Programming Language - Overview
- Example of a Logical Database
- Logical Databases
- Position of the Basis System Within the R/3 System
- Running ABAP Programs
- Calling ABAP Dialog Modules
- Data Types in the ABAP Dictionary
- Pushbuttons on the Screen
- Processing Input/Output Fields
- Processing Screen
- Screens
- ABAP User Dialogs
- Reduce the Database Load
- Minimize the Search Overhead
- Minimize the Number of Data Transfers
- Minimize the Amount of Data Transferred
- Keep the Result Set Small
- Performance Notes
- Committing Database Changes
- Inserting or Changing Lines
- Deleting Lines
- Changing Line
- Inserting Lines into Tables
- Changing Data
- Reading Data
- Open SQL
- Checking User Authorizations
- Accessing the Database in the R/3 System
- ABAP Database Access
- ABAP HR Programming
- ABAP Tutorials for Beginners
- Download Abap certification material
-
▼
June
(81)
