Posted: Mon Sep 03, 2007 10:46 pm Post subject: Object Oriented ALV-Using two Containers.
Code:
*&---------------------------------------------------------------------*
*& Report Z_OO_ALV
*&
*&---------------------------------------------------------------------*
*& We can Use Two containers in OOALV
*&
*&---------------------------------------------------------------------*
REPORT z_oo_alv LINE-COUNT 50.
*types gt_struct type sflight.
DATA BEGIN OF gt_struct.
INCLUDE STRUCTURE sflight.
DATA rcol(4) TYPE c.
DATA colors TYPE lvc_t_scol.
DATA END OF gt_struct.
*ALV GRIDs
DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
DATA gr_alvgrid1 TYPE REF TO cl_gui_alv_grid.
DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
DATA gc_custom_control_name1 TYPE scrfname VALUE 'CC_ALV1'.
*CONTAINERs
DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
DATA gr_ccontainer1 TYPE REF TO cl_gui_custom_container.
*FIELDCATALOGs
DATA gt_fieldcat TYPE lvc_t_fcat WITH HEADER LINE.
DATA gt_fieldcat1 TYPE lvc_t_fcat WITH HEADER LINE.
*LAYOUTs
DATA gs_layout TYPE lvc_s_layo.
DATA gs_layout1 TYPE lvc_s_layo.
"internal table declaration to be passed.
DATA pt_exclude TYPE ui_functions.
*DATA pt_cell TYPE lvc_t_cell with header line.
DATA : gt_list LIKE gt_struct OCCURS 50 WITH HEADER LINE,
gt_list1 LIKE gt_struct OCCURS 50 WITH HEADER LINE.
*&---------------------------------------------------------------------*
*& Module PAI INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE pai INPUT.
CASE sy-ucomm.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'PICK'.
PERFORM cell_info.
ENDCASE.
ENDMODULE. " PAI INPUT
*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM display_alv.
DATA: is_stable TYPE lvc_s_stbl.
*&---------------------------------------------------------------------*
*& Form prepare_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->GS_LAYOUT text
*----------------------------------------------------------------------*
FORM prepare_layout CHANGING gs_layout TYPE lvc_s_layo.
*&---------------------------------------------------------------------*
*& Form data_retrival
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM data_retrival.
SELECT carrid
connid
price
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE gt_list
UP TO 50 ROWS.
ENDFORM. "data_retrival
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
CALL METHOD gr_ccontainer->free.
CALL METHOD gr_ccontainer1->free.
LEAVE TO SCREEN 0.
ENDFORM. "exit_program
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STAT'.
* SET TITLEBAR 'xxx'.
* IF W_CUSTOM_CONTAINER IS INITIAL.
*
**sets TITLEBAR
* PERFORM TITLEBAR.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Form prepare_field_catalog1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->GT_FIELDCAT text
*----------------------------------------------------------------------*
FORM prepare_field_catalog1 CHANGING pgt_fieldcat1 TYPE lvc_t_fcat.
DATA ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-tabname = 'gt_list1'.
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-scrtext_m = 'MAX. SEATS'.
ls_fieldcat-col_pos = 0.
ls_fieldcat-outputlen = 10.
* ls_fieldcat-emphasize = 'C400'.
* ls_fieldcat-key = ' '.
APPEND ls_fieldcat TO pgt_fieldcat1.
*&---------------------------------------------------------------------*
*& Form prepare_layout1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->GS_LAYOUT text
*----------------------------------------------------------------------*
FORM prepare_layout1 CHANGING gs_layout1 TYPE lvc_s_layo.
*&---------------------------------------------------------------------*
*& Form data_retrival1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM data_retrival1.
SELECT seatsmax
seatsocc
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE gt_list1
UP TO 50 ROWS.
ENDFORM. "data_retrival
*&---------------------------------------------------------------------*
*& Form exclude_tb_functions
*&---- subroutine to exclude toolbar options --------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_EXCLUDE text
*----------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_maximum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_minimum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sort.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_mb_filter.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "data_retrival1
*&---------------------------------------------------------------------*
*& Form cell_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM cell_info. "CHANGING pt_cell TYPE lvc_t_cell.
DATA lt_cell TYPE lvc_t_cell WITH HEADER LINE.
CALL METHOD gr_alvgrid->get_selected_cells
IMPORTING
et_cell = lt_cell[].
LOOP AT lt_cell.
WRITE : lt_cell-col_id , lt_cell-row_id.
ENDLOOP.
* MODIFY pt_cell[] from lt_cell[].
ENDFORM. "cell_info
*&---------------------------------------------------------------------*
*& Form set_col
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_col .
DATA ls_cellcolor TYPE lvc_s_scol.
LOOP AT gt_list.
IF gt_list-price GT 500.
ls_cellcolor-fname = 'PRICE'.
ls_cellcolor-color-col = 5.
ls_cellcolor-color-int = 1.
ls_cellcolor-color-inv = 0.
APPEND ls_cellcolor TO gt_list-colors.
ELSE.
ls_cellcolor-fname = 'PRICE'.
ls_cellcolor-color-col = 3.
ls_cellcolor-color-int = 1.
APPEND ls_cellcolor TO gt_list-colors.
ENDIF.
MODIFY gt_list.
ENDLOOP.
ENDFORM. "set_col
*&---------------------------------------------------------------------*
*& Form set_col1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM set_col1.
DATA : ind TYPE sy-tabix,
indx TYPE sy-tabix.
LOOP AT gt_list1.
ind = sy-tabix / 2.
indx = sy-tabix - ind.
IF indx EQ ind.
gt_list1-rcol = 'C500'.
ENDIF.
MODIFY gt_list1.
ENDLOOP.
ENDFORM. "set_col
*FORM TITLEBAR.
*SET TITLEBAR 'TITLE'.
*ENDFORM.
*double click on TITLE and write ur title
Code:
* screen 0100 contains two custom containers: CC_ALV, CC_ALV1.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
MODULE display_alv.
*
PROCESS AFTER INPUT.
MODULE pai.
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.