2010 Jun 30 9:41 AM
Hi,
i have a problem to insert value in drop down list in ALV. (I want to use this call function CALLFUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' or 'REUSE_ALV_GRID_DISPLAY)
How can i insert directly in ABAP 3 value. Example of code you can test this :
report ZCO_AFFACT_TEST.
*&---------------------------------------------------------------------*
* type pools
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS.
*&---------------------------------------------------------------------*
* declarations for alv and internal tables
*----------------------------------------------------------------------*
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT,
WA_LAYOUT TYPE LVC_S_LAYO,
V_POSITION TYPE I ,
LS_CELLCOLOR TYPE LVC_S_SCOL,
L_INDEX TYPE SY-TABIX.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
flag LIKE ztypfac-flag,
CELLCOLOR TYPE LVC_T_SCOL,
END OF IT_VBAP.
*&---------------------------------------------------------------------*
* start of selection
*----------------------------------------------------------------------*
start-of-selection .
*---get data from db table
perform get_data .
*---build layout for alv
perform build_layout .
*---build fieldcat for alv
perform build_fieldcat .
*---modify fieldcat for colors in alv
Perform modify_fieldcat .
*---display alv
perform display_alv .
*&---------------------------------------------------------------------*
*& Form get_data
*----------------------------------------------------------------------*
FORM get_data .
SELECT VBELN
POSNR
UP TO 25 ROWS
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*----------------------------------------------------------------------*
FORM build_fieldcat .
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-REPTEXT = 'VBELN'.
WA_FIELDCAT-edit = 'X'.
WA_FIELDCAT-drdn_hndl = '1'. "I have had
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-REPTEXT = 'POSNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'FLAG'.
WA_FIELDCAT-REPTEXT = 'FLAG'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " build_fieldcat
*&---------------------------------------------------------------------*
*& Form build_layout
*----------------------------------------------------------------------*
FORM build_layout .
WA_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form modify_fieldcat
*----------------------------------------------------------------------*
FORM modify_fieldcat .
LOOP AT IT_VBAP.
L_INDEX = SY-TABIX.
if l_index = 5 or l_index = 15.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.
if l_index = 10 or l_index = 20.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '4'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.
if it_vbap-VBELN is initial .
delete it_vbap.
endif.
ENDLOOP.
ENDFORM. " modify_fieldcat
*&---------------------------------------------------------------------*
*& Form display_alv
*----------------------------------------------------------------------*
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_VBAP .
ENDFORM. " display_alv
Thank you for your answers!
Edited by: Emilien P. on Jun 30, 2010 10:42 AM
Hi,
i have a problem to insert value in drop down list in ALV. (I want to use this call function CALLFUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' or 'REUSE_ALV_GRID_DISPLAY)
How can i insert directly in ABAP 3 value. Example of code you can test this :
report ZCO_AFFACT_TEST.
*&---------------------------------------------------------------------*
* type pools
*----------------------------------------------------------------------*
TYPE-POOLS: SLIS.
*&---------------------------------------------------------------------*
* declarations for alv and internal tables
*----------------------------------------------------------------------*
DATA: IT_FIELDCAT TYPE LVC_T_FCAT,
WA_FIELDCAT TYPE LVC_S_FCAT,
WA_LAYOUT TYPE LVC_S_LAYO,
V_POSITION TYPE I ,
LS_CELLCOLOR TYPE LVC_S_SCOL,
L_INDEX TYPE SY-TABIX.
DATA: BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
flag LIKE ztypfac-flag,
CELLCOLOR TYPE LVC_T_SCOL,
END OF IT_VBAP.
*&---------------------------------------------------------------------*
* start of selection
*----------------------------------------------------------------------*
start-of-selection .
*---get data from db table
perform get_data .
*---build layout for alv
perform build_layout .
*---build fieldcat for alv
perform build_fieldcat .
*---modify fieldcat for colors in alv
Perform modify_fieldcat .
*---display alv
perform display_alv .
*&---------------------------------------------------------------------*
*& Form get_data
*----------------------------------------------------------------------*
FORM get_data .
SELECT VBELN
POSNR
UP TO 25 ROWS
INTO CORRESPONDING FIELDS OF TABLE IT_VBAP
FROM VBAP.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*----------------------------------------------------------------------*
FORM build_fieldcat .
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-REPTEXT = 'VBELN'.
WA_FIELDCAT-edit = 'X'.
WA_FIELDCAT-drdn_hndl = '1'. "I have had
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-REPTEXT = 'POSNR'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
WA_FIELDCAT-FIELDNAME = 'FLAG'.
WA_FIELDCAT-REPTEXT = 'FLAG'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " build_fieldcat
*&---------------------------------------------------------------------*
*& Form build_layout
*----------------------------------------------------------------------*
FORM build_layout .
WA_LAYOUT-CTAB_FNAME = 'CELLCOLOR'.
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form modify_fieldcat
*----------------------------------------------------------------------*
FORM modify_fieldcat .
LOOP AT IT_VBAP.
L_INDEX = SY-TABIX.
if l_index = 5 or l_index = 15.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '6'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.
if l_index = 10 or l_index = 20.
LS_CELLCOLOR-FNAME = 'VBELN'.
LS_CELLCOLOR-COLOR-COL = '4'.
LS_CELLCOLOR-COLOR-INT = '1'.
APPEND LS_CELLCOLOR TO IT_VBAP-CELLCOLOR.
MODIFY IT_VBAP INDEX L_INDEX TRANSPORTING CELLCOLOR.
endif.
if it_vbap-VBELN is initial .
delete it_vbap.
endif.
ENDLOOP.
ENDFORM. " modify_fieldcat
*&---------------------------------------------------------------------*
*& Form display_alv
*----------------------------------------------------------------------*
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT_LVC = WA_LAYOUT
IT_FIELDCAT_LVC = IT_FIELDCAT
TABLES
T_OUTTAB = IT_VBAP .
ENDFORM. " display_alv
Thank you for your answers!
Edited by: Emilien P. on Jun 30, 2010 10:42 AM
2010 Jun 30 10:09 AM
Hi,
Please go thorugh SAP wiki link which is very much explainatory...
http://wiki.sdn.sap.com/wiki/display/Snippets/DropdownsinALV
You have to fill all drop down values ls_dropdown-value as below.
Write below sample code in aftre populating fieldcatalogue
*--It means count the number of Sales Order.
data num(5) type .
Describe table i_vbap lines num.
DATA: it_dropdown TYPE lvc_t_drop,
wa_dropdown TYPE lvc_s_drop.
DO num times.
l_index = sy-index
read table it_vbap with index l_index.
wa_dropdown-handle = '1'.
wa_dropdown-value = it_vap-vbeln.
append wa_dropdown to it_dropdown.
clear wa_dropdown.
ENDDO.
I hope this should solve your problem
Cheers,
Pramod
2010 Jun 30 12:34 PM
With this article : http://wiki.sdn.sap.com/wiki/display/Snippets/DropdownsinALV
I am obliged to use the g_grid TYPE REF TO cl_gui_alv_grid and i want to use 'REUSE_ALV_GRID_DISPLAY_LVC'
If you test the program which i pasted in the last thread, the drop down is visible but there isn't have value.
And in the saptechnical i don't find a response of my problem!
Edited by: Emilien P. on Jun 30, 2010 1:35 PM
2010 Jun 30 7:13 PM
2010 Jul 01 3:04 PM
Finaly i have user OO because all the example use the Object...
With my old ALV i have used User command and Hotspot, it is very easy to use.
Now with the OO i have a problem to manage the hot spot and a cell, when i am in mode debug /h when i click on the cell with the hotspot nothing happen !!! I don't undertand what is missing
report ZCO_AFFACT_TEST.
Tables : VBRK, VBRP,ZTYPFAC.
*-- Global data definitions for ALV
*--- ALV Grid instance reference
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .
*--- Name of the custom control added on the screen
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV' .
*--- Custom container instance reference
DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .
*--- Field catalog table
DATA gt_fieldcat TYPE lvc_t_fcat .
*--- Layout structure
DATA gs_layout TYPE lvc_s_layo.
types : begin of wls_facture,
... END OF wls_facture.
types : begin of wls_resultat,
... END OF wls_resultat.
data : wlt_facture type TABLE OF wls_facture,
wls_facture type wls_facture,
wlt_final type TABLE OF wls_resultat,
wls_final type wls_resultat.
PERFORM BUILD_DATA.
PERFORM display_alv.
end-of-selection.
call SCREEN 1000.
"display_alv OUTPUT
*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_alv .
IF gr_alvgrid IS INITIAL .
*----Creating custom container instance
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gc_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
others = 6.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5.
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
*----Preparing field catalog.
PERFORM prepare_field_catalog CHANGING gt_fieldcat .
*----Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout .
PERFORM prepare_drilldown_values.
*----Here will be additional preparations
*--e.g. initial sorting criteria, initial filtering criteria, excluding
*--functions
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = wlt_final
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4 .
IF sy-subrc <> 0.
*--Exception handling
ENDIF.
ELSE .
CALL METHOD gr_alvgrid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2 .
ENDIF .
ENDFORM . "display_alv
If anybody have an idea Thanks a lot !
Emilien
Edited by: Emilien P. on Jul 1, 2010 4:21 PM
2010 Jul 01 3:22 PM
the rest of the code. Thanks a lot for your answers.
*&---------------------------------------------------------------------*
*& Form prepare_field_catalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_FIELDCAT text
*----------------------------------------------------------------------*
FORM prepare_field_catalog CHANGING t_catalogue_pv TYPE lvc_t_fcat .
...
d_ligne_catalogue_pv-tabname = 'wlt_final'.
d_ligne_catalogue_pv-fieldname = 'VBELN'.
d_ligne_catalogue_pv-hotspot = 'X'.
append d_ligne_catalogue_pv to t_catalogue_pv.
...
ENDFORM. "prepare_field_catalog
*&---------------------------------------------------------------------*
*& Form handle_hotspot_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_ROW_ID text
* -->I_COLUMN_ID text
* -->IS_ROW_NO text
*----------------------------------------------------------------------*
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.
DATA: s_final like wls_final.
break epetrini.
READ TABLE wlt_final INDEX is_row_no-row_id into s_final.
IF sy-subrc = 0 AND i_column_id-fieldname = 'BELNR'.
"CHECK NOT wlt_final-BELNR IS INITIAL.
SET PARAMETER ID 'BLN' FIELD s_final-BELNR.
SET PARAMETER ID 'BUK' FIELD s_final-BUKRS.
SET PARAMETER ID 'GJR' FIELD s_final-GJAHR.
CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.
elseif sy-subrc = 0 AND i_column_id-fieldname = 'VBELN'.
"CHECK NOT wlt_final-BELNR IS INITIAL.
SET PARAMETER ID 'VF' FIELD s_final-VBELN.
CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
ENDIF.
ENDFORM . "handle_hotspot_click
*----------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
DATA gr_event_handler TYPE REF TO lcl_event_handler .
METHODS:
"Hotspot click control
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no.
ENDCLASS. "lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
"Handle Hotspot Click
METHOD handle_hotspot_click .
CREATE OBJECT gr_event_handler .
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
ENDMETHOD. "handle_hotspot_click
endclass.Edited by: Emilien P. on Jul 1, 2010 4:23 PM
2010 Jun 30 10:27 AM
Hi emilien,
i would suggest u go through the saptechnical they have come up with good example for the same .