Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

LIST BOX

herzelhaimharel_gilor
Participant
0 Likes
1,027

HI Folkes ,

would someone let me know what should be done to cause field appaer as an listbox in ALV Grid ?

Thx All .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
957

HI

you have to handle drop down table in the alv

for ex.

data: lt_dropdown type lvc_t_drop,

ls_dropdown type lvc_s_drop.

  • First listbox (handle '1').

ls_dropdown-handle = '1'.

ls_dropdown-value = 'KG'.

append ls_dropdown to lt_dropdown.

ls_dropdown-handle = '1'.

ls_dropdown-value = 'G'.

append ls_dropdown to lt_dropdown.

call method g_grid->set_drop_down_table

exporting it_drop_down = lt_dropdown.

you can refer to BCALV_EDIT_06 & BCALV_EDIT_07

regards

kishore

HI Folkes ,

would someone let me know what should be done to cause field appaer as an listbox in ALV Grid ?

Thx All .

7 REPLIES 7
Read only

Former Member
0 Likes
957

Hi,

check these examples...

BCALV_EDIT_06

BCALV_EDIT_07.

Regards

vijay

Read only

Former Member
0 Likes
957

Hi,

check this thread here i gave an example also..

Regards

vijay

Read only

0 Likes
957

Hi,

you can see samples from these threads

Regards

vijay

Read only

Former Member
0 Likes
958

HI

you have to handle drop down table in the alv

for ex.

data: lt_dropdown type lvc_t_drop,

ls_dropdown type lvc_s_drop.

  • First listbox (handle '1').

ls_dropdown-handle = '1'.

ls_dropdown-value = 'KG'.

append ls_dropdown to lt_dropdown.

ls_dropdown-handle = '1'.

ls_dropdown-value = 'G'.

append ls_dropdown to lt_dropdown.

call method g_grid->set_drop_down_table

exporting it_drop_down = lt_dropdown.

you can refer to BCALV_EDIT_06 & BCALV_EDIT_07

regards

kishore

Read only

0 Likes
957

HI ,

thanks a lot .

i need to know how can i catch the event when data is changed within the drop down list .

which event in CL_GUI_ALV_GRID handle this situation ?

Thx .

Read only

Former Member
0 Likes
957

Hi Herzel,

Just go through this document. This will contain details as to how to make ALV fields appear as dropdown box.

http://www.esnips.com/doc/2d953590-e8c5-490c-a607-d1ab7cf517d7/ALV.pdf

Regards,

SP

Read only

Former Member
0 Likes
957

Hii Herzel ,

check this program for drop down list

REPORT Z_NARESH_DROPDOWN_LIST .

************************************************************************

  • TABLES DECLARATION *

************************************************************************

TABLES :BKPF, " Accounting document header

BSEG, " Accounting document segment

LFA1, " Vendor master

SKAT. "G/L Account Master Record (Chart of Accounts:Desc)

************************************************************************

  • INTERNAL TABLES DECLARATION

************************************************************************

DATA : BEGIN OF IT_BKPF OCCURS 0,

BUKRS LIKE BKPF-BUKRS, "Company code

BELNR LIKE BKPF-BELNR, "Document number

GJAHR LIKE BKPF-GJAHR, "Fiscal year

BLDAT LIKE BKPF-BLDAT, "Vendor invoice date

BUDAT LIKE BKPF-BUDAT, "System entered date

BLART LIKE BKPF-BLART, "Document type

END OF IT_BKPF.

DATA : BEGIN OF IT_BSEG OCCURS 0,

BUKRS LIKE BSEG-BUKRS, "Company code

BELNR LIKE BSEG-BELNR, "G/L doc number

GJAHR LIKE BSEG-GJAHR, "Fiscal year

BUZEI LIKE BSEG-BUZEI, "# of line item with in accounting doc.

KOART LIKE BSEG-KOART, "Account type

WRBTR LIKE BSEG-WRBTR, "Invoice $

VBUND LIKE BSEG-VBUND, "Company id

HKONT LIKE BSEG-HKONT, "G/L Account

LIFNR TYPE BSEG-LIFNR, "Vendor number

EBELN TYPE BSEG-EBELN, "Po number

END OF IT_BSEG.

DATA : BEGIN OF IT_SKAT OCCURS 0,

SAKNR LIKE SKAT-SAKNR, "G/L Account number

TXT20 LIKE SKAT-TXT20, "G/L short text

TXT50 LIKE SKAT-TXT50, "G/L long text

END OF IT_SKAT.

  • Get the Vendor name & A/C Group from LFA1

DATA : BEGIN OF IT_VENDOR OCCURS 0,

LIFNR LIKE LFA1-LIFNR, "Vendor number

NAME1 LIKE LFA1-NAME1, "Vendor name

KTOKK LIKE LFA1-KTOKK, "Vendor account group

END OF IT_VENDOR.

DATA : BEGIN OF IT_BASIC OCCURS 0,

BLDAT LIKE BKPF-BLDAT, "Vendor invoice date

BUDAT LIKE BKPF-BUDAT, "System entered date

NAME1 TYPE LFA1-NAME1, "Vendor name

WRBTR LIKE BSEG-WRBTR, "Invoice $

EBELN TYPE BSEG-EBELN, "Po number

BUKRS LIKE BKPF-BUKRS, "Company code

BELNR LIKE BKPF-BELNR, "Document number

BLART LIKE BKPF-BLART, "Document type

HKONT LIKE BSEG-HKONT, "G/L Account

TXT20 LIKE SKAT-TXT20, "G/L short text

KOART LIKE BSEG-KOART, "Account type

END OF IT_BASIC.

DEFINE lb_macro_KOART.

selection-screen begin of line.

selection-screen comment 1(31) &3.

parameters: &1 as listbox visible length &2 obligatory.

selection-screen end of line.

END-OF-DEFINITION.

DEFINE lb_macro_BLART.

selection-screen begin of line.

selection-screen comment 1(31) &3.

parameters: &1 as listbox visible length &2 obligatory.

selection-screen end of line.

END-OF-DEFINITION.

************************************************************************

  • TYPES DECLARATION *

************************************************************************

TYPE-POOLS: SLIS.

************************************************************************

  • VARIABLE DECLARATION

************************************************************************

DATA : V_FLG_ERROR_OPEN(1) TYPE C. " Flag

*--DATA RELATED TO ALV'S

<b>DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

  • IT_OUTTAB LIKE IT_DATA OCCURS 0 WITH HEADER LINE, "#EC *

V_REPID LIKE SY-REPID,

V_LAYOUT TYPE SLIS_LAYOUT_ALV,

IT_EVENTS TYPE SLIS_T_EVENT,

V_PAGE_HEADER TYPE SLIS_FORMNAME VALUE 'PAGE_HEADER',

V_CALLBACK_USER_COMMAND(30) VALUE 'USER_COMMAND'.</b>

************************************************************************

  • CONSTANTS

************************************************************************

*CONSTANTS

************************************************************************

  • SELECTION-SCREEN *

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK S1 WITH FRAME TITLE TEXT-001.

PARAMETERS :

P_KOKRS LIKE BSEG-KOKRS, "Controlling Area

P_BUKRS LIKE BKPF-BUKRS, "Company Code

P_GSBER LIKE BSEG-GSBER. "Business Area

SELECT-OPTIONS:

S_KOSTL FOR BSEG-KOSTL NO-EXTENSION, "Cost Center

S_LIFNR FOR BSEG-LIFNR. "Vendor

  • S_KOART FOR BSEG-KOART. "Account type (Drop down)

lb_macro_KOART mylist(1) 5 comment.

PARAMETERS :

P_GJAHR LIKE BKPF-GJAHR, "Fiscal Year

P_MONAT LIKE BKPF-MONAT, "Posting Period

P_BUDAT LIKE BKPF-BUDAT, "Posting date in the document

P_ZUONR LIKE BSEG-ZUONR. "Account Assignement

  • P_BLART LIKE BKPF-BLART. "Doc type. (Drop down)

lb_macro_BLART mylist1(1) 6 comment1.

SELECTION-SCREEN END OF BLOCK S1.

***********************************************************************

  • INITIALIZATION

************************************************************************

INITIALIZATION.

V_REPID = SY-REPID.

at selection-screen.

************************************************************************

  • AT SELECTION - SCREEN

************************************************************************

at selection-screen OUTPUT.

perform add_values_to_koart.

comment = 'Account type'.

perform add_values_to_blart.

comment1 = 'Document type'.

start-of-selection.

end-of-selection.

&----


*& Form add_values_to_koart

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM add_values_to_koart .

TYPE-POOLS: vrm.

DATA: my_list TYPE vrm_values,

value LIKE LINE OF my_list.

  • i_tab TYPE TABLE OF bseg WITH HEADER LINE.

data : begin of i_tab occurs 0 ,

koart type c,

end of i_tab.

clear i_tab.

i_tab-koart = 'A'.

append i_tab.

clear i_tab.

i_tab-koart = 'D'.

append i_tab.

clear i_tab.

i_tab-koart = 'K'.

append i_tab.

clear i_tab.

i_tab-koart = 'M'.

append i_tab.

clear i_tab.

i_tab-koart = 'S'.

append i_tab.

clear i_tab.

  • SELECT koart FROM bseg INTO CORRESPONDING FIELDS OF TABLE i_tab.

&----


*& Filling the list structure with values from MARA table

&----


LOOP AT i_tab.

value-key = sy-tabix.

value-text = i_tab-koart.

APPEND value TO my_list.

ENDLOOP.

&----


*& Finally calling the function module to create the list box.

&----


CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'MYLIST'

values = my_list.

ENDFORM. " add_values_to_koart

&----


*& Form add_values_to_blart

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM add_values_to_blart .

TYPE-POOLS: vrm.

DATA: my_list1 TYPE vrm_values,

value1 LIKE LINE OF my_list1,

i_tab1 TYPE TABLE OF T003 WITH HEADER LINE.

SELECT blart FROM T003 INTO CORRESPONDING FIELDS OF TABLE i_tab1.

&----


*& Filling the list structure with values from MARA table

&----


LOOP AT i_tab1.

value1-key = sy-tabix.

value1-text = i_tab1-blart.

APPEND value1 TO my_list1.

ENDLOOP.

&----


*& Finally calling the function module to create the list box.

&----


CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'MYLIST1'

values = my_list1.

ENDFORM. " add_values_to_blart

Reward points if helpful

Regards

Naresh