sitemap
SapMaterial.com
Creating a combobox

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
All of the  product names here are trademarks of their respective companies.  The site
www.allsaplinks.com no way affiliated with SAP AG. We have made every effort for the content
integrity.  Information used on this site is at your own risk.
ABAP TECHNICAL

SAP Introduction

sap abap faq

sap Tables

SAP Transaction codes

Internal tables

data dictionary

performance tuning

transports & Requests

Sap scripts

Smartforms

lsmw

reports

sap Workflow

module pool/ dialog
programming

table control

user exits

sap memory

abap memory

alv reports

ABAP ADVANCED

IDOC

ALE

BAPI

BADI

RFC


FUNCTIONAL SIDE

Materials Management

FICO

Human Resources

BIW / BW / SEM


Free Documentation
Abap Material

Ale Material

BAPI Material

BC Material

IDOC Material

R/3 Database Management

SAP material

RFC

Transport

Sales & Distribution Material

Basic Data and Function
Material

Basis (BC) Material

Billing Material

CA Material

CATT : Computer Aided Test
Tool

Capacity Evaluation and
leveling Material

Capacity Planning Material

Cross Application Material

Countries

Customer Service Material

Enterpise  Material

Financial / Controlling (FICO)

Internet Time Sheet

Inspection Material

HR Material

Material Management
Material

Payments Material

Payroll Material

Pension Fund

Production Planning and
Control

Plant Maintenance

Quality Management Material

Real Estate Material

SAP material

Wage Types