Set_table_for_first_display : Conflicts of layouts
Hello folks,
I am displaying the ALV using the method - set_table_for_first_display.
The scenario is that I have multiple ALV's to be displayed for different conditions with the same sy-repid and hence the layout that i save for one ALV is being shown when I try to save the layout for another ALV.
I tried by passing i_default = space as well as 'X'. Still that didnt help.
I am passing the sy-repid value to the is_variant-report as of now.
Please suggest a solution for this!
Thanks,
Safeer.
Hello Safeer,
I am Sending Code To display ALV In Multiple Tables.
*& Report ZALVMLTP PAVAN
REPORT ZALVMLTP.
DATA: Splitter_1 TYPE REF TO cl_gui_splitter_container,
Splitter_2 TYPE REF TO cl_gui_splitter_container,
Container TYPE REF TO cl_gui_custom_container,
Container_1 TYPE REF TO cl_gui_container,
Container_2 TYPE REF TO cl_gui_container,
Container_3 TYPE REF TO cl_gui_container,
Grid1 TYPE REF TO cl_gui_alv_grid,
Grid2 TYPE REF TO cl_gui_alv_grid,
Grid3 TYPE REF TO cl_gui_alv_grid.
DATA: Gt_sflight_1 TYPE TABLE OF sflight,
Gt_sflight_2 TYPE TABLE OF sflight,
Gt_sflight_3 TYPE TABLE OF sflight,
G_container TYPE scrfname VALUE 'CCONTAINER'.
DATA: ok_code TYPE sy-ucomm.
fetching data from table for different internal tables
SELECT * FROM sflight INTO TABLE gt_sflight_1.
SELECT * FROM sflight INTO TABLE gt_sflight_2 UP TO 18 ROWS.
SELECT * FROM sflight INTO TABLE gt_sflight_3 UP TO 9 ROWS.
CALL SCREEN 9010.
*& Module STATUS_9010 OUTPUT *
MODULE status_9010 OUTPUT.
SET PF-STATUS 'TEST'.
*creating object reference for container
CREATE OBJECT container
EXPORTING
container_name = 'CCONTAINER'.
*splitting the main container into 1 row & 2 coloum
CREATE OBJECT splitter_1
EXPORTING
Parent = container
Rows = 1
Columns = 2.
*getting the reference for the splited container (row 1 & col 1 container)
CALL METHOD splitter_1->get_container
EXPORTING
Row = 1
Column = 1
RECEIVING
Container = container_1.
*getting the reference for the splited container (row 1 & col 2 container)
CALL METHOD splitter_1->get_container
EXPORTING
Row = 1
Column = 2
RECEIVING
Container = container_2.
*splitting the 2nd coloum container in to 2 rows & 1 coloum
CREATE OBJECT splitter_2
EXPORTING
Parent = container_2
Rows = 2
Columns = 1.
*getting the reference for the splited container2 (row 1 & col 2 container)
CALL METHOD splitter_2->get_container
EXPORTING
Row = 1
Column = 1
RECEIVING
Container = container_2.
*getting the reference for the splited container2 (row 2 & col 1 container)
CALL METHOD splitter_2->get_container
EXPORTING
Row = 2
Column = 1
RECEIVING
Container = container_3.
*populating first internal table to the container
CREATE OBJECT container
EXPORTING
container_name = g_container.
CREATE OBJECT grid1
EXPORTING
i_parent = container_1.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight_1.
*populating second internal table
CREATE OBJECT container
EXPORTING
container_name = g_container.
CREATE OBJECT grid2
EXPORTING
i_parent = container_2.
CALL METHOD grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight_2.
*populating third internal table
CREATE OBJECT container
EXPORTING
container_name = g_container.
CREATE OBJECT grid3
EXPORTING
i_parent = container_3.
CALL METHOD grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
it_outtab = gt_sflight_3.
ENDMODULE.
*& Module EXIT INPUT *
MODULE exit INPUT.
*free the container memory when exit
CALL METHOD container->free.
LEAVE PROGRAM.
ENDMODULE.
*& Module USER_COMMAND_9010 INPUT *
MODULE user_command_9010 INPUT.
CALL METHOD cl_gui_cfw=>dispatch.
CASE SY-UCOMM.
WHEN 'BACK'.
LEAVE SCREEN.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE SCREEN.
ENDCASE.
ENDMODULE.
WarmRegards,
PavanKumar.G
Similar Messages
-
From ALV output list to selection screen
Hi,
I created one ALV report.
After executing the program, it displays an ALV list.
When I click on the back/exit/cancel buttons on the screen, it should take me to the selection screen.
But that is not happening. it is taking to one screen which shows the report heading. IF i click back/cancel/exit buttons in this screen, it is taking me to the selection screen.
I checked the program for any write statement, but therre are no write statements.
Even i tried to remove the end-of-selection event in the program. but not working.
Can any one help me on this how to overcome this issue.
Thank you.
Kumarhi check this example...
REPORT zalv_sel_screen .TABLES: mara.DATA: BEGIN OF i_alv OCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END OF i_alv.DATA: alv_container TYPE REF TO cl_gui_docking_container.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: layout TYPE lvc_s_layo.
DATA: fieldcat TYPE lvc_t_fcat.PARAMETERS: p_check.INITIALIZATION. PERFORM get_data.AT SELECTION-SCREEN OUTPUT. DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid. repid = sy-repid. variant-report = sy-repid.
variant-username = sy-uname. layout-zebra = 'X'.
layout-edit_mode = 'X'. CHECK alv_container IS INITIAL. CREATE OBJECT alv_container
EXPORTING repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_left
extension = 1500. CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.* ALV Specific. Data selection.
Populate Field Catalog
PERFORM get_fieldcatalog. CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
START-OF-SELECTION.
FORM GET_DATA
FORM get_data. SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
FROM mara
INNER JOIN makt
ON maramatnr = maktmatnr
UP TO 100 ROWS
WHERE makt~spras = sy-langu. SORT i_alv ASCENDING BY matnr.ENDFORM. "get_data***************************************************************
Form Get_Fieldcatalog - Set Up Columns/Headers
FORM get_fieldcatalog. DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'. ls_fcat-col_pos = '4'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'. ls_fcat-col_pos = '5'.
APPEND ls_fcat TO fieldcat.ENDFORM. "get_fieldcatalog
regards,
venkat -
Double click on list field in ALV grid control
Hello all,
I developed a report with a ALV grid control. I would like to move some functionality from marking a line and pressing a button in the status line to double clicking a specific field in the output list and execute a command there (i.e. double click on PO number and go to PO display TAC then). Can anybody provide some example coding for that?
Thanks so much for your help!
TorstenHere is your sample program. Copy this code into a z program. Create the screen 100 with a container in it and name it "ALV_CONTAINER". Create the gui-status with "BACK".
report zrich_0001.
tables: ekko.
data: begin of i_alv occurs 0,
ebeln type ekko-ebeln,
end of i_alv.
* CLASS cl_event_receiver DEFINITION Handles Double Click
class cl_event_receiver definition.
public section.
methods handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
private section.
endclass.
* CLASS CL_EVENT_RECEIVER IMPLEMENTATION Handles Double Click
class cl_event_receiver implementation.
method handle_double_click.
perform drill_down using e_row-index.
endmethod.
endclass.
data: alv_container type ref to cl_gui_custom_container.
data: event_receiver type ref to cl_event_receiver.
data: alv_grid type ref to cl_gui_alv_grid.
data: layout type lvc_s_layo.
data: fieldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001 .
select-options: s_ebeln for ekko-ebeln.
selection-screen end of block b1.
start-of-selection.
perform get_data.
call screen 100.
* Module status_0100 OUTPUT
module status_0100 output.
set pf-status '0100'.
set titlebar '0100'.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
* Create Controls
create object alv_container
exporting
container_name = 'ALV_CONTAINER'.
create object alv_grid
exporting
i_parent = alv_container.
* Create Event Receiver
create object event_receiver.
* Populate Field Catalog
perform get_fieldcatalog.
call method alv_grid->set_table_for_first_display
exporting
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
* handler for ALV grid
set handler event_receiver->handle_double_click for alv_grid.
endmodule.
* Module USER_COMMAND_0100 INPUT
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
when 'EXIT'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
leave program.
endcase.
endmodule.
* FORM GET_DATA
form get_data.
select * into corresponding fields of table i_alv
from ekko
where ebeln in s_ebeln.
sort i_alv ascending by ebeln.
endform.
* Form Get_Fieldcatalog - Set Up Columns/Headers
form get_fieldcatalog.
data: ls_fcat type lvc_s_fcat.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'PO Number'.
ls_fcat-coltext = 'PO Number'.
ls_fcat-fieldname = 'EBELN'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
endform.
* DRILL_DOWN
form drill_down using index.
read table i_alv index index.
if sy-subrc = 0.
set parameter id 'BES' field i_alv-ebeln.
call transaction 'ME23' and skip first screen.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
endif.
endform.
Regards,
Rich Heilman -
Can i use classes or grid control (alv) in normal report
Hai,
Can i use Grid control or classes in normal report.If yes what are the steps that i have to go for.
thanks
kiranSure... here is a sample of an ALV in a report. All you need to do is call a screen. I believe that there is also a way to do it without having to create a screen.
REPORT ZRICH_0001.
DATA: BEGIN OF I_ALV OCCURS 0,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF I_ALV.
DATA: ALV_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: LAYOUT TYPE LVC_S_LAYO.
DATA: FIELDCAT TYPE LVC_T_FCAT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
SELECT-OPTIONS: S_MATNR FOR i_ALV-MATNR.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM GET_DATA.
CALL SCREEN 100.
* Module status_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
DATA: VARIANT TYPE DISVARIANT.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
* Create Controls
CREATE OBJECT ALV_CONTAINER
EXPORTING
CONTAINER_NAME = 'ALV_CONTAINER'.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = ALV_CONTAINER.
* ALV Specific. Data selection.
* Populate Field Catalog
PERFORM GET_FIELDCATALOG.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
IS_VARIANT = VARIANT
I_SAVE = 'U'
I_STRUCTURE_NAME = 'I_ALV'
CHANGING
IT_OUTTAB = I_ALV[]
IT_FIELDCATALOG = FIELDCAT[].
ENDMODULE.
* Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR 'CANC'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
IF SY-SUBRC = 0.
SET SCREEN 0.
LEAVE SCREEN.
ELSE.
LEAVE PROGRAM.
ENDIF.
WHEN 'EXIT'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
* FORM GET_DATA
FORM GET_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
FROM MARA
INNER JOIN MAKT
ON MARA~MATNR = MAKT~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MAKT~SPRAS = SY-LANGU.
SORT I_ALV ASCENDING BY MATNR.
ENDFORM.
* Form Get_Fieldcatalog - Set Up Columns/Headers
FORM GET_FIELDCATALOG.
DATA: LS_FCAT TYPE LVC_S_FCAT.
REFRESH: FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Number'.
LS_FCAT-COLTEXT = 'Material Number'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-COL_POS = 1.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Description'.
LS_FCAT-COLTEXT = 'Material Description'.
LS_FCAT-FIELDNAME = 'MAKTX'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '40'.
LS_FCAT-COL_POS = 2.
APPEND LS_FCAT TO FIELDCAT.
ENDFORM.
Regards,
Rich Heilman -
How can I use hotspot click in an ALV grid?
Hello,
I have a table that is displayed in an ALV grid and I would like to have one of the columns as clickable icons.
For example:
Print | Doc. Type | Name
(icon) | .docx | first
(icon) | .pdf | second ... and so on.
I would like to click in the icon (Print column) and execute an action, but no matter what I do I can't set the action.
I know that is not just setting "fieldcatalog-hotspot='X'", but I don't know how to use a hotspot handler.
Here's some of the code I have:
TYPES: BEGIN OF ty_docs,
print LIKE ICON-ID,
doc_type LIKE table_doc-TYPE,
name LIKE table_doc-NAME,
END OF ty_docs.
DATA: oref_dock TYPE REF TO cl_gui_docking_container,
oref_alv TYPE REF TO cl_gui_alv_grid,
i_fieldcat TYPE lvc_t_fcat,
aux_fieldcat TYPE lvc_s_fcat,
aux_lay TYPE lvc_s_layo,
i_exclude TYPE TABLE OF syucomm,
i_docs TYPE ty_docs,
t_docs LIKE TABLE OF i_docs.
AT SELECTION-SCREEN OUTPUT.
APPEND 'ONLI' TO i_exclude.
APPEND 'SJOB' TO i_exclude.
APPEND 'PRIN' TO i_exclude.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS'
EXPORTING
p_status = sy-pfkey
p_program = sy-repid
TABLES
p_exclude = i_exclude.
AT SELECTION-SCREEN.
CHECK sy-ucomm = space.
SELECT
icon~ID AS print
doc~TYPE AS doc_type
doc~NAME as name
INTO CORRESPONDING FIELDS OF TABLE t_docs
FROM table_doc AS doc
INNER JOIN ICON AS icon
ON icon~NAME EQ 'ICON_PRINT'
GROUP BY icon~ID doc~TYPE doc~NAME.
IF sy-subrc = 0.
IF oref_dock IS NOT BOUND.
CREATE OBJECT oref_dock
EXPORTING
repid = sy-repid
dynnr = sy-dynnr
side = cl_gui_docking_container=>dock_at_bottom
ratio = 90
EXCEPTIONS
OTHERS = 1.
ENDIF.
IF oref_alv IS NOT BOUND.
CHECK oref_dock IS BOUND.
CREATE OBJECT oref_alv
EXPORTING
i_parent = oref_dock
EXCEPTIONS
OTHERS = 1.
CHECK oref_alv IS BOUND.
aux_fieldcat-fieldname = 'PRINT'.
aux_fieldcat-coltext = 'Print'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-print'.
aux_fieldcat-edit = ''.
aux_fieldcat-just = 'C'.
aux_fieldcat-hotspot = 'X'.
aux_fieldcat-outputlen = 10.
aux_fieldcat-col_pos = 0.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'TYPE'.
aux_fieldcat-coltext = 'Doc. Type'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-doc_type'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 15.
aux_fieldcat-col_pos = 1.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_fieldcat-fieldname = 'NAME'.
aux_fieldcat-coltext = 'Name'.
aux_fieldcat-ref_table = 't_docs'.
aux_fieldcat-ref_field = 't_docs-name'.
aux_fieldcat-edit = ''.
aux_fieldcat-outputlen = 12.
aux_fieldcat-col_pos = 2.
APPEND aux_fieldcat TO i_fieldcat.
CLEAR aux_fieldcat.
aux_lay-grid_title = 'Docs'.
aux_lay-edit = ''.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ty_docs'
i_internal_tabname = 't_docs'
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
OTHERS = 3.
CALL METHOD oref_alv->set_table_for_first_display
EXPORTING
i_structure_name = 'ty_docs'
is_layout = aux_lay
CHANGING
it_fieldcatalog = i_fieldcat
it_outtab = t_docs
EXCEPTIONS
OTHERS = 1.
ELSE.
CALL METHOD oref_alv->refresh_table_display
EXCEPTIONS
OTHERS = 1.
ENDIF.
ENDIF.
Thank you so much in advance!Hi,
After creating grid set the even handler for hot spot.
SET HANDLER lcl_event_receiver=>handle_hotspot_click FOR alv_grid.
Try this code:
TABLES: mara,t001l.
DATA: BEGIN OF i_alv OCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END OF i_alv.
DATA: wa_alv LIKE LINE OF i_alv.
DATA: alv_container TYPE REF TO cl_gui_docking_container.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: layout TYPE lvc_s_layo.
DATA: fieldcat TYPE lvc_t_fcat.
DATA: gt_t001l TYPE STANDARD TABLE OF t001l.
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
*-->Method for User command
CLASS-METHODS :
handle_hotspot_click FOR EVENT hotspot_click OF
cl_gui_alv_grid
IMPORTING E_ROW_ID e_column_id.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_hotspot_click.
READ TABLE i_alv INTO wa_alv
INDEX e_row_id-index
TRANSPORTING matnr.
SET PARAMETER ID 'MAT' FIELD wa_alv-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
PARAMETERS: p_check TYPE matnr.
INITIALIZATION.
PERFORM get_data.
AT SELECTION-SCREEN OUTPUT.
* START-OF-SELECTION.
DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid.
repid = sy-repid.
variant-report = sy-repid.
variant-username = sy-uname.
layout-zebra = 'X'.
layout-edit_mode = 'X'.
CHECK alv_container IS INITIAL.
CREATE OBJECT alv_container
EXPORTING repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_right
extension = 350.
CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.
* Set event handler
SET HANDLER lcl_event_receiver=>handle_hotspot_click FOR alv_grid.
* ALV Specific. Data selection.
* Populate Field Catalog
PERFORM get_fieldcatalog.
CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
START-OF-SELECTION.
* FORM GET_DATA
FORM get_data.
SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
FROM mara
INNER JOIN makt
ON mara~matnr = makt~matnr
UP TO 100 ROWS
WHERE makt~spras = sy-langu.
SORT i_alv ASCENDING BY matnr.
ENDFORM. "get_data
* Form Get_Fieldcatalog - Set Up Columns/Headers
FORM get_fieldcatalog.
DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-hotspot = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'.
ls_fcat-col_pos = '4'.
APPEND ls_fcat TO fieldcat.
CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = '5'.
APPEND ls_fcat TO fieldcat.
ENDFORM. "get_fieldcatalog
Hope this solves your problem.... -
Grahical reports in abap how to devlop
hi all
can u please tell me how to display reports in graphical form 2d or 3d using abap programmingHi ,
Paste this code in se38,
PERFORM create_chart is important for you.
*& Report ZMM_INV_TURNS_REPORT *
*& Author Vijay Babu Dudla *
*& Date 25th April 2008 *
Description : Inventory Turns Report *
Inputs: *
Tables: *
ECMT - COGS data *
GLTO - Inventory Data *
Parameters: *
From Period *
Year *
To Period *
Year *
Company Code
Parameters: *
N/A *
Outputs: A ALV report is generated to display the Inventory Turns *
External Routines *
Classes: CL_GUI_ALV_GRID *
CL_IGS_CHART *
Transactions : No *
Programs : No *
Return Codes: No *
Ammendments: *
Programmer Date Req. # Action *
================ ========== ====== ==============================*
Vijay Dudla 04/15/2008 RD4K900255 Initial Development *
RMANDAL 05/18/2008 RD4K900419 1) Getting COGS values *
from ZSCOMMON *
2) Displying values in *
Graph *
REPORT zmm_inv_turns_report MESSAGE-ID zi.
*-TYPES Declaration
*- Period Details
TYPES: BEGIN OF ty_period,
perid TYPE fc_perid, " Period
END OF ty_period.
*-Year Details
TYPES: BEGIN OF ty_year,
gjahr TYPE gjahr, " Year
END OF ty_year.
*-Final Display Table
TYPES: BEGIN OF ty_data,
texts(20), " Col Value
per01(20), " Period1
per02(20), " Period2
per03(20), " Period3
per04(20), " Period4
per05(20), " Period5
per06(20), " Period6
per07(20), " Period7
per08(20), " Period8
per09(20), " Period9
per10(20), " Period10
per11(20), " Period11
per12(20), " Period12
year TYPE gjahr,
END OF ty_data.
*-Period Balance information
TYPES: BEGIN OF ty_balance,
period TYPE fc_perid, " Period
gjahr TYPE gjahr, " Year
tslvt TYPE tslxx, " Balance
END OF ty_balance.
*- Period and Year info
TYPES: BEGIN OF ty_per_year,
period TYPE fc_perid, " Period
gjahr TYPE gjahr, " Year
END OF ty_per_year.
*- Field Symbols
FIELD-SYMBOLS: <fs> TYPE ANY.
*- Data Declarations
*- Internal Table Decleations
DATA: it_fieldcat TYPE lvc_t_fcat, " Fieldcatalog
it_per TYPE STANDARD TABLE OF zmm_year_period,
it_year_per TYPE zmm_t_inv_period,
it_final TYPE STANDARD TABLE OF ty_data,
it_year TYPE STANDARD TABLE OF ty_year,
it_period TYPE STANDARD TABLE OF ty_period,
it_common TYPE STANDARD TABLE OF zscommon,
BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
it_common1 TYPE STANDARD TABLE OF zscommon,
END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
it_inv TYPE STANDARD TABLE OF glt0,
it_cogs TYPE STANDARD TABLE OF ecmct,
it_inv_data TYPE STANDARD TABLE OF zfi_year_period,
it_balance TYPE STANDARD TABLE OF ty_balance,
it_peryear TYPE STANDARD TABLE OF ty_per_year
WITH HEADER LINE.
*- Work Area declarations
DATA: wa_fieldcat TYPE lvc_s_fcat,
w_per TYPE zmm_year_period,
w_period TYPE zmm_inv_period,
wa_final TYPE ty_data,
wa_inv TYPE zfi_year_period,
wa_per TYPE ty_period,
wa_balance TYPE ty_balance.
*- Range table Declations
DATA: return TYPE TABLE OF ddshretval WITH HEADER LINE,
r_year TYPE RANGE OF gjahr WITH HEADER LINE,
r_yr TYPE RANGE OF gjahr WITH HEADER LINE,
r_per TYPE RANGE OF fc_perid WITH HEADER LINE,
r_saknr TYPE RANGE OF racct.
*- Variable to Period and Year
DATA: perid TYPE fc_perid,
year TYPE gjahr,
w_bukrs TYPE glt0-bukrs.
*- Graph Display
DATA: g_html TYPE w3htmltabtype,
g_url TYPE w3url.
*-Controls for Displaying the Grpah and ALV Report
DATA: grid TYPE REF TO cl_gui_alv_grid,
split TYPE REF TO cl_gui_splitter_container,
cont TYPE REF TO cl_gui_custom_container,
gridcon TYPE REF TO cl_gui_container,
htmlcon TYPE REF TO cl_gui_container,
html_control TYPE REF TO cl_gui_html_viewer.
*& Selection Screen *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-ttl.
SELECT-OPTIONS: s_per FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
" Period
s_year FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
" Year
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-tt2.
SELECT-OPTIONS: s_per2 FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
" Period
s_year2 FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
" Year
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-tt3 .
PARAMETERS: p_rep RADIOBUTTON GROUP g1 DEFAULT 'X',
p_grp RADIOBUTTON GROUP g1,
p_bot RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b3.
PARAMETERS: p_bukrs LIKE glt0-bukrs DEFAULT '3000' OBLIGATORY.
*& AT SELECTION-SCREEN ON VALUE REQUEST *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_year-low.
*-Value help for year
PERFORM get_hlp_for_year.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_per-low.
*-Value help for Period
PERFORM get_hlp_for_period.
*& AT SELECTION-SCREEN *
AT SELECTION-SCREEN .
*-Validations
*- Per Period should be 1 to 12
LOOP AT s_per.
IF s_per-low GT 12 OR s_per-low LT 1.
MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
ENDIF. " IF s_per-low GT 12 OR s_per-low
IF NOT s_per-high IS INITIAL.
IF s_per-high GT 12 OR s_per-high LT 1.
MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
ENDIF. " IF s_per-high GT 12 OR
ENDIF. " IF NOT s_per-high IS INITIAL
ENDLOOP. " LOOP AT s_per
IF s_per-low GE sy-datum+4(2) AND
s_year-low GE sy-datum+0(4).
MESSAGE e000(zi) WITH text-002 text-003.
ENDIF. " IF s_per-low GE sy-datum+4(2)
LOOP AT s_per2.
IF s_per2-low GT 12 OR s_per2-low LT 1.
MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
ENDIF. " IF s_per2-low GT 12 OR
ENDLOOP. " LOOP AT s_per2.
IF s_per2-low GE sy-datum+4(2) AND
s_year2-low GE sy-datum+0(4).
MESSAGE e000(zi) WITH text-002 text-003.
ENDIF. " IF s_per2-low GE sy-datum+4(2)
Company Code Validation
IF p_bukrs IS NOT INITIAL.
SELECT
SINGLE bukrs " Company Code
FROM t001
INTO w_bukrs
WHERE bukrs = p_bukrs.
IF sy-subrc NE 0.
MESSAGE e000(zi) WITH 'Enter Valid Company code '.
ENDIF. " IF sy-subrc NE 0.
CLEAR w_bukrs.
ENDIF. " IF p_bukrs IS NOT
*& START OF SELECTION *
START-OF-SELECTION.
*-Get the GL Accounts from table ZSCOMMON
PERFORM get_gl_information.
*-Get the Inventory Details
PERFORM get_inventory_data.
*-Get the COGS details
PERFORM get_cogs_data.
*-Population of Period Table
PERFORM populate_period_data.
*-Populate the Final Data
PERFORM populate_final_data.
*& END OF SELECTION *
END-OF-SELECTION.
*-Display the Output
PERFORM display_inv_turn_data.
*& Form get_hlp_for_year
Get the Value help for Year
FORM get_hlp_for_year.
*-Populate the F4 Values for Year
SELECT pabrj
FROM t549q
INTO
TABLE it_year.
IF sy-subrc EQ 0.
SORT it_year.
DELETE it_year WHERE gjahr = ''.
DELETE ADJACENT DUPLICATES FROM it_year
COMPARING gjahr.
*-Attaching the F4 Help to The Selection parameter
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'GJAHR'
dynpprog = sy-repid
dynpnr = sy-dynnr
value_org = 'S'
TABLES
value_tab = it_year
return_tab = return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc EQ 0.
READ TABLE return INDEX 1.
s_year-low = return-fieldval.
ENDIF. " IF sy-subrc EQ 0
ENDIF. " IF sy-subrc EQ 0
ENDFORM. " get_hlp_for_year
*& Form get_hlp_for_period
Get the Search help for Period
FORM get_hlp_for_period.
*-Population of Period to Display the F4 values
CLEAR return[].
wa_per-perid = '001'.
DO 12 TIMES.
APPEND wa_per TO it_period.
wa_per-perid = wa_per-perid + 1.
ENDDO. " DO 12 TIMES.
*-Attaching the F4 values to the selection parameter
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'PERID'
dynpprog = sy-repid
dynpnr = sy-dynnr
value_org = 'S'
TABLES
value_tab = it_period
return_tab = return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc EQ 0.
READ TABLE return INDEX 1.
s_per-low = return-fieldval.
ENDIF. " IF sy-subrc EQ 0
ENDFORM. " get_hlp_for_period
*& Form GET_GL_INFORMATION
Get the GL account Information from ZSCOMMON table
FORM get_gl_information .
DATA: wa_common TYPE zscommon,
wa_saknr LIKE LINE OF r_saknr.
*-GL Accounts from ZSCOMMON
SELECT *
FROM zscommon
INTO
TABLE it_common
WHERE programm = sy-repid AND
code = 'GLAC'.
IF sy-subrc EQ 0.
wa_saknr-sign = 'I'.
wa_saknr-option = 'EQ'.
LOOP AT it_common INTO wa_common.
wa_saknr-low = wa_common-valuestrng.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = wa_saknr-low
IMPORTING
output = wa_saknr-low.
APPEND wa_saknr TO r_saknr.
ENDLOOP. " LOOP AT it_common
ENDIF. " IF sy-subrc EQ 0
ENDFORM. " GET_GL_INFORMATION
*& Form GET_INVENTORY_DATA
Get the Inventory Data
FORM get_inventory_data .
REFRESH r_year.
r_year-sign = 'I'.
r_year-option = 'EQ'.
*-Populate the Year from Selection Parameters
LOOP AT s_year.
r_year-low = s_year-low.
APPEND r_year.
r_year-low = r_year-low - 1.
APPEND r_year.
r_year-low = s_year-low.
IF s_year2-low IS NOT INITIAL.
DO.
r_year-low = r_year-low + 1.
IF r_year-low GT s_year2-low.
EXIT.
ENDIF. " IF r_year-low GT
APPEND r_year.
ENDDO. " DO
ENDIF. " IF s_year2-low IS NOT
ENDLOOP. " LOOP AT s_year
CLEAR r_year.
SORT r_year BY low.
DELETE ADJACENT DUPLICATES FROM r_year COMPARING low.
r_yr-sign = 'I'.
r_yr-option = 'EQ'.
LOOP AT s_year.
r_yr-low = s_year-low.
APPEND r_yr.
IF s_year2-low IS NOT INITIAL.
DO.
r_yr-low = r_yr-low + 1.
IF r_yr-low GT s_year2-low.
EXIT.
ENDIF. " IF r_yr-low GT s_year2-low
APPEND r_yr.
ENDDO. " DO
ENDIF. " IF s_year2-low IS NOT
ENDLOOP. " LOOP AT s_year
*-Get the Inventory Data
SELECT *
FROM glt0
INTO TABLE it_inv
WHERE bukrs = p_bukrs AND
ryear IN r_year AND
racct IN r_saknr.
ENDFORM. " GET_INVENTORY_DATA
*& Form GET_COGS_DATA
Get the COGS data
FORM get_cogs_data .
DATA: s_item TYPE RANGE OF fc_item,
wa_item LIKE LINE OF s_item.
BEGIN OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
data: wa_common1 TYPE zscommon.
SELECT *
FROM zscommon
INTO
TABLE it_common1
WHERE programm = sy-repid AND
code = 'CCOA'.
IF sy-subrc EQ 0.
wa_item-sign = 'I'.
wa_item-option = 'EQ'.
LOOP AT it_common1 INTO wa_common1.
wa_item-low = wa_common1-valuestrng.
APPEND wa_item TO s_item.
ENDLOOP. " LOOP AT it_common1
ENDIF. " IF sy-subrc EQ 0
wa_item-sign = 'I'.
wa_item-option = 'EQ'.
wa_item-low = '0000005000'.
APPEND wa_item TO s_item.
wa_item-low = '0000006100'.
APPEND wa_item TO s_item.
wa_item-low = '0000007900'.
APPEND wa_item TO s_item.
END OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
*-Population of COGS information
SELECT *
FROM ecmct
INTO TABLE it_cogs
WHERE ryear IN r_year AND
rbunit EQ '000000000000003000' AND
ritem IN s_item AND
( ( sityp EQ '2 ' AND
subit EQ '0100 ')
OR
( sityp EQ ' ' AND
subit EQ ' ') ).
IF sy-subrc EQ 0.
ENDIF. " IF sy-subrc EQ 0
ENDFORM. " GET_COGS_DATA
*& Form POPULATE_FINAL_DATA
Population of final Data
FORM populate_final_data .
DATA: inc(2) TYPE n,
w_pert(15),
col(5).
*Field catalog population.
wa_fieldcat-fieldname = 'TEXTS'.
wa_fieldcat-outputlen = 20.
wa_fieldcat-coltext = 'Info'.
APPEND wa_fieldcat TO it_fieldcat.
inc = 1.
DO 12 TIMES.
CONCATENATE 'PER' inc INTO wa_fieldcat-fieldname.
CONCATENATE 'PER' inc INTO wa_fieldcat-coltext.
wa_fieldcat-outputlen = 20.
wa_fieldcat-just = 'R'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat .
inc = inc + 1.
ENDDO. " DO 12 TIMES.
SORT it_per BY year period.
inc = 1.
*-Final Internal table formation
LOOP AT it_per INTO w_per.
READ TABLE it_final WITH KEY year = w_per-year
TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
wa_final-texts = w_per-year.
wa_final-year = w_per-year.
inc = 1.
DO 12 TIMES.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
ASSIGN (w_pert) TO <fs>.
<fs> = inc.
inc = inc + 1.
ENDDO. " DO 12 TIMES
APPEND wa_final TO it_final.
CLEAR wa_final.
inc = w_per-period+1(2).
wa_final-year = w_per-year.
wa_final-texts = 'COGS Tot(12 months)'.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-cogs.
APPEND wa_final TO it_final.
wa_final-texts = 'Inv Total(12 months)'.
wa_final-year = w_per-year.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invtot.
APPEND wa_final TO it_final.
wa_final-texts = 'Inv Avg(monthly)'.
wa_final-year = w_per-year.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invavg.
APPEND wa_final TO it_final.
wa_final-texts = 'Turns(COGS/Inv.Avg)'.
wa_final-year = w_per-year.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invturn.
APPEND wa_final TO it_final.
CLEAR wa_final.
APPEND wa_final TO it_final.
ELSE.
inc = w_per-period+1(2).
wa_final-texts = 'COGS Total(12 months)'.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
CONCATENATE 'PER' inc INTO col.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-cogs.
MODIFY it_final FROM wa_final TRANSPORTING (col)
WHERE texts = 'COGS Tot(12 months)'
AND year = w_per-year.
wa_final-texts = 'Inv Total(12 months)'.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
CONCATENATE 'PER' inc INTO col.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invtot.
MODIFY it_final FROM wa_final TRANSPORTING (col)
WHERE texts = 'Inv Total(12 months)'
AND year = w_per-year .
wa_final-texts = 'Inv Avg(monthly)'.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
CONCATENATE 'PER' inc INTO col.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invavg.
MODIFY it_final FROM wa_final TRANSPORTING (col)
WHERE texts = 'Inv Avg(monthly)'
AND year = w_per-year
wa_final-texts = 'Turns(COGS/Inv.Avg)'.
CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
CONCATENATE 'PER' inc INTO col.
ASSIGN (w_pert) TO <fs>.
<fs> = w_per-invturn.
MODIFY it_final FROM wa_final TRANSPORTING (col)
WHERE texts = 'Turns(COGS/Inv.Avg)'
AND year = w_per-year .
CLEAR wa_final.
ENDIF. " IF sy-subrc NE 0
ENDLOOP. " LOOP AT it_per INTO
ENDFORM. " POPULATE_FINAL_DATA
*& Form DISPLAY_INV_TURN_DATA
Display Inventory Turns Report
FORM display_inv_turn_data .
IF NOT it_final IS INITIAL.
*-Save the Data
PERFORM save_data.
CALL SCREEN 100.
ELSE.
MESSAGE s000(zi) WITH 'No data for selection'.
ENDIF. " IF NOT it_final
ENDFORM. " DISPLAY_INV_TURN_DATA
*& Form POPULATE_PERIOD_DATA
Populate the Period Data
FORM populate_period_data .
*- Work Variables
DATA: wa_inv TYPE glt0,
wa_cog TYPE ecmct,
w_amt(12),
w_debit TYPE tslxx,
w_credit TYPE tslxx,
w_invtot TYPE tslxx,
w_cogstot TYPE tslxx,
w_bal1 TYPE tslxx,
w_bal2 TYPE tslxx,
w_total TYPE tslxx,
w_inc(2) TYPE n,
w_perd TYPE fc_perid,
w_bal(12),
lv_period TYPE fc_perid,
lv_year TYPE gjahr,
w_change.
*- Field Symbols
FIELD-SYMBOLS: <fs> TYPE ANY,
<fs_bal> TYPE ANY.
*-Population of Balance for all Periods.
SORT it_inv BY ryear.
LOOP AT r_year.
CLEAR: w_debit,w_credit,
w_bal1,w_bal2,w_total.
wa_balance-gjahr = r_year-low.
LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
drcrk = 'S' .
w_bal1 = w_bal1 + wa_inv-tslvt.
CLEAR wa_inv-tslvt.
ENDLOOP. " LOOP AT it_inv
LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
drcrk = 'H' .
wa_inv-tslvt = wa_inv-tslvt * -1.
w_bal2 = w_bal2 + wa_inv-tslvt.
CLEAR wa_inv-tslvt.
ENDLOOP. " LOOP AT it_inv INTO wa_inv
w_total = w_bal1 - w_bal2.
w_inc = 1.
DO 12 TIMES.
LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
drcrk = 'S' .
CLEAR: w_bal.
CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
ASSIGN (w_bal) TO <fs_bal>.
w_debit = w_debit + <fs_bal>.
UNASSIGN <fs_bal>.
ENDLOOP. " LOOP AT it_inv INTO wa_inv
LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
drcrk = 'H' .
CLEAR: w_bal.
CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
ASSIGN (w_bal) TO <fs_bal>.
<fs_bal> = <fs_bal> * -1.
w_credit = w_credit + <fs_bal>.
UNASSIGN <fs_bal>.
ENDLOOP. " LOOP AT it_inv INTO wa_inv
wa_balance-tslvt = w_debit - w_credit + w_total.
wa_balance-period = w_inc.
APPEND wa_balance TO it_balance.
w_inc = w_inc + 1.
ENDDO. " DO 12 TIMES
ENDLOOP. " LOOP AT r_year
CLEAR: w_credit,w_debit.
r_per-sign = 'I'.
r_per-option = 'EQ'.
CLEAR it_peryear[].
*-Populate the periods
r_per-low = s_per-low.
lv_year = s_year-low.
DO .
it_peryear-period = r_per-low.
it_peryear-gjahr = lv_year.
APPEND it_peryear.
IF r_per-low GE s_per2-low AND
lv_year EQ s_year2-low.
EXIT.
ENDIF. " IF r_per-low GE s_per2
IF r_per-low = 12.
r_per-low = 1.
lv_year = lv_year + 1.
ELSE.
r_per-low = r_per-low + 1.
ENDIF. " IF r_per-low = 12
ENDDO. " DO
CLEAR: r_per,r_year,w_change.
*-Population of the Turns information based on Period and year
LOOP AT it_peryear.
w_perd = it_peryear-period.
LOOP AT r_yr WHERE low = it_peryear-gjahr.
w_per-period = it_peryear-period.
IF w_change = ''.
w_per-year = r_yr-low.
ENDIF. " IF w_change = ''
IF w_per-period = 12.
IF s_per-low <> w_per-period.
r_yr-low = r_yr-low - 1.
w_change = 'X'.
ENDIF. " IF s_per-low <> w_per-period
w_per-year = r_yr-low.
ENDIF. " IF w_per-period = 1
CLEAR: w_invtot,
w_cogstot.
*-For each period populate the Credit and Debit info
DO 12 TIMES.
w_period-period = it_peryear-period.
w_period-year = r_yr-low.
CLEAR: w_amt,w_debit,w_bal1.
CONCATENATE 'WA_INV-TSL' w_period-period+1(2) INTO w_amt.
LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
drcrk = 'S' .
ASSIGN (w_amt) TO <fs>.
w_debit = w_debit + <fs>.
UNASSIGN <fs>.
CLEAR wa_inv-tslvt.
ENDLOOP. " LOOP AT it_inv INTO wa_inv
CLEAR: w_credit,w_bal2.
LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
drcrk = 'H' .
ASSIGN (w_amt) TO <fs>.
<fs> = <fs> * -1.
w_credit = w_credit + <fs>.
UNASSIGN <fs>.
CLEAR wa_inv-tslvt.
ENDLOOP. " LOOP AT it_inv INTO wa_inv
w_period-tsl01 = w_debit - w_credit.
CLEAR w_amt.
CONCATENATE 'WA_COG-TSL' w_period-period+1(2) INTO w_amt.
LOOP AT it_cogs INTO wa_cog WHERE ryear = w_period-year.
ASSIGN (w_amt) TO <fs>.
w_period-tsl02 = w_period-tsl02 + <fs>.
UNASSIGN <fs>.
ENDLOOP. " LOOP AT it_cogs INTO wa_cog
*-Calculate the total amounts
w_invtot = w_invtot + w_period-tsl01.
w_cogstot = w_cogstot + w_period-tsl02.
APPEND w_period TO it_year_per.
CLEAR: w_period-tsl02,w_period-tsl01.
IF it_peryear-period EQ 1.
it_peryear-period = 12.
r_yr-low = r_yr-low - 1.
ELSE.
it_peryear-period = it_peryear-period - 1.
ENDIF. " IF it_peryear-period
ENDDO. " DO 12 TIMES.
lv_period = w_per-period.
lv_year = w_per-year.
DO 12 TIMES.
READ TABLE it_balance INTO wa_balance
WITH KEY period = lv_period
gjahr = lv_year.
w_per-invtot = w_invtot .+ wa_balance-tslvt.
w_per-invtot = w_per-invtot + wa_balance-tslvt.
IF lv_period = 1.
lv_period = 12.
lv_year = lv_year - 1.
ELSE.
lv_period = lv_period - 1.
ENDIF. " IF lv_period = 1
CLEAR wa_balance-tslvt.
ENDDO. " DO 12 TIMES
w_per-cogs = w_cogstot.
w_per-invavg = w_per-invtot / 12.
IF w_per-invavg NE 0.
w_per-invturn = w_per-cogs / w_per-invavg.
ENDIF. " IF w_per-invavg NE 0
w_per-year = it_peryear-gjahr.
w_per-info = it_year_per.
APPEND w_per TO it_per.
CLEAR: w_per-period,
w_per-invtot,
w_per-invavg,
w_per-cogs,
w_per-invturn,
w_per-info,it_year_per.
ENDLOOP. " LOOP AT r_yr WHERE
ENDLOOP. " LOOP AT it_peryear
ENDFORM. " POPULATE_PERIOD_DATA
*& Form create_chart
Display the Chart
FORM create_chart USING p_html TYPE w3htmltabtype p_real.
DATA:
igs_chart TYPE REF TO cl_igs_chart,
line TYPE igs_data,
data TYPE igs_data_tab,
ext_line TYPE igs_ext,
extension TYPE igs_ext_tab,
mime TYPE w3mimetabtype,
html TYPE w3htmltabtype,
html_line TYPE w3html,
url TYPE w3url,
content_length TYPE i,
content_type TYPE w3param-cont_type,
content_subtype TYPE w3param-cont_type.
DATA: val TYPE char30.
empty result table
REFRESH p_html.
create chart object
CREATE OBJECT igs_chart.
set chart type
igs_chart->type = cl_igs_chart=>co_type_lines.
set picture size
igs_chart->width = 640.
igs_chart->height = 480.
igs_chart->width = 1024.
igs_chart->height = 680.
data to be displayed in the form of Graph
SORT it_per BY period.
LOOP AT it_per INTO w_per.
line-groupid = w_per-year.
line-x = w_per-period.
IF w_per-invturn < 0.
w_per-invturn = w_per-invturn * -1.
CLEAR val.
val = w_per-invturn .
CONCATENATE '-' val INTO line-y.
ELSE.
line-y = w_per-invturn.
ENDIF. " IF w_per-invturn < 0
BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
To dislay the values in Graph
line-DATALABEL = line-y.
condense line-datalabel.
END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
APPEND line TO data.
CLEAR line.
ENDLOOP. " LOOP AT it_per INTO w_per
*-Populate the IGS data
igs_chart->data = data.
set titles
igs_chart->title = 'Inventory Turns'.
igs_chart->title_values = 'No of Turns'.
igs_chart->title_categories = 'Period'.
create picture
CALL METHOD igs_chart->send
IMPORTING
content_type = content_type
content_length = content_length
content = mime
imagemap = html
EXCEPTIONS
rfc_communication_error = 1
rfc_system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc IS INITIAL AND p_real NE space.
SPLIT content_type AT '/' INTO content_type content_subtype.
CALL METHOD html_control->load_data
EXPORTING
type = content_type
subtype = content_subtype
size = content_length
IMPORTING
assigned_url = url
CHANGING
data_table = mime.
CONCATENATE
'<HTML><HEAD><TITLE>SAP IGS Chart</TITLE></HEAD>'
'<BODY BGCOLOR=#DEDEC8>'
'<MAP NAME=chart>'
INTO html_line-line.
APPEND html_line TO p_html.
APPEND LINES OF html TO p_html.
CONCATENATE
'</MAP>'
'<IMG SRC="' url '" USEMAP=#chart BORDER=0>'
'</BODY></HTML>'
INTO html_line-line.
APPEND html_line TO p_html.
ENDIF. " IF sy-subrc IS INITIAL AND..
ENDFORM. " create_chart
*& Module STATUS_0100 OUTPUT
Status and Controls Initialzation
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZTURN'.
SET TITLEBAR 'ZTURN'.
DATA: layout TYPE lvc_s_layo.
*-Create the Container
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc NE 0
*-If Report option
IF p_rep EQ 'X'.
*-Creation of Grid Object
CREATE OBJECT grid
EXPORTING
i_parent = cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc NE 0
layout-zebra = 'X'.
layout-no_headers = 'X'.
layout-cwidth_opt = 'X'.
layout-grid_title = 'Inventory Turns Report'.
*-Display the ALV
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = it_final
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc NE 0
*-If Graph Option selected
ELSEIF p_grp EQ 'X'.
set rfc destination
cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
create hmtl control
CREATE OBJECT html_control
EXPORTING parent = cont.
PERFORM create_chart USING g_html 'X'.
get url of output data
CALL METHOD html_control->load_data
EXPORTING
type = 'text'
subtype = 'html'
IMPORTING
assigned_url = g_url
CHANGING
data_table = g_html.
Load the picture by using the url generated by the data .
CALL METHOD html_control->show_url
EXPORTING
url = g_url.
*-If Both Report and Graph Selected
ELSE.
set rfc destination
cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
Create Splitter for custom_container
CREATE OBJECT split
EXPORTING
parent = cont
rows = 2
columns = 1.
CALL METHOD split->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = htmlcon.
CALL METHOD split->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = gridcon.
create hmtl control
CREATE OBJECT html_control
EXPORTING parent = htmlcon.
PERFORM create_chart USING g_html 'X'.
get url of output data
CALL METHOD html_control->load_data
EXPORTING
type = 'text'
subtype = 'html'
IMPORTING
assigned_url = g_url
CHANGING
data_table = g_html.
Load the picture by using the url generated by the data .
CALL METHOD html_control->show_url
EXPORTING
url = g_url.
CREATE OBJECT grid
EXPORTING
i_parent = gridcon
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc NE 0
layout-zebra = 'X'.
layout-no_headers = 'X'.
layout-cwidth_opt = 'X'.
layout-grid_title = 'Inventory Turns Report'.
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = it_final
it_fieldcatalog = it_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. " IF sy-subrc NE 0
ENDIF. " IF p_rep EQ 'X'
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
User Action Handling
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
*-Handling the User actions
WHEN 'BACK' OR 'CANC' OR 'EXIT'.
LEAVE TO SCREEN 0. -
Hi Friendz
Need your help very urgently. Please give me your expert ideas.
usually we get output of ALV grid display in column wise.
But in my requirement I need to populate two fields horizontally using alv_grid_display.
Report heading according to project standard, including title u201CDemand plan compare reportu201D, Pergo, date and time printed, and plant
the fields after UOM are pdatu from pbed and underneath is the field plnmg from pbed.
Material Ver UOM 2008-05 2008-06 2008-07 u2026u2026.. 2009-04 Total
034014 00 M2 2500 2400 3000 2800 31450
01 1000 800 1200 1400 11800
40% 33% 40% 50% 36%
034015 u2026u2026.
Plz give me any solution for this. I need to use alv grid displayI did a sample using ALV (OO).
To test it create a screen 100, and place custom control on it , Name it as CONT. Create the Pf-status in the PBO module.
REPORT ztest_dynamic_code.
DATA: BEGIN OF it_tab OCCURS 0,
abc(3),
xyz(3),
pqr(3),
item,
END OF it_tab.
DATA: it_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: i_dyntab TYPE REF TO data. " To create dyn.Itab
DATA:
w_dref TYPE REF TO data,
ind(2) TYPE n,
w_data TYPE REF TO data,
w_text(5),
w_grid TYPE REF TO cl_gui_alv_grid.
DATA: grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY,<fs> TYPE ANY.
DATA: in TYPE i.
*Data population
it_tab-abc = 'ABC'.
it_tab-xyz = 'XYZ'.
it_tab-pqr = 'PQR'.
DO 9 TIMES.
in = in + 1.
it_tab-item = in.
APPEND it_tab.
ENDDO.
*Field cat population.
wa_fieldcat-fieldname = 'ABC'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'abc'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'XYZ'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'XYZ'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'PQR'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'pqr'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'COLOR'.
wa_fieldcat-outputlen = 4.
wa_fieldcat-coltext = 'col'.
APPEND wa_fieldcat TO it_fieldcatalog.
ind = 1.
DO 9 TIMES.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-fieldname.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-coltext.
wa_fieldcat-outputlen = 1.
APPEND wa_fieldcat TO it_fieldcatalog.
CLEAR wa_fieldcat .
ind = ind + 1.
ENDDO.
*-Dynamic Table creation
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = i_dyntab.
ASSIGN i_dyntab->* TO <t_itab>.
CREATE DATA w_data LIKE LINE OF <t_itab>.
ASSIGN w_data->* TO <fs_wa>.
SORT it_tab BY abc xyz pqr.
CLEAR ind.
ind = 4.
*-Final Internal table as per Requirement
do 10 times.
LOOP AT it_tab.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-abc.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-xyz.
UNASSIGN <fs>.
ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-pqr.
UNASSIGN <fs>.
ASSIGN COMPONENT 4 OF STRUCTURE <fs_wa> TO <fs>.
*-You can assign the color conditionally also..
if sy-index = 4.
<fs> = 'C400'.
else.
<fs> = 'C600'.
endif.
UNASSIGN <fs>.
ASSIGN COMPONENT ind OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-item.
UNASSIGN <fs>.
ind = ind + 1.
AT END OF pqr.
APPEND <fs_wa> TO <t_itab>.
* <fs_wa>-color = 'C600'.
ind = 4.
CLEAR <fs_wa>.
ENDAT.
ENDLOOP.
enddo.
*-Display
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
DATA: layout TYPE lvc_s_layo.
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT grid
EXPORTING
i_parent = cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
layout-INFO_FNAME = 'COLOR'.
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = <t_itab>
it_fieldcatalog = it_fieldcatalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT -
Hi folks,
Im using the variant function of the ALV Grid. The screen you get by creating or saving a variant contains the following tabstrips: Sort Order, Filter, View and Display. My aim is to hide all tabstrips except the Sort Order one. Is there any way to do this?
thanks in advanceCheck this code that I got from Rich Heilman when I had the same problem. If you find out which you have by using
RS_CUA_GET_STATUS_FUNCTIONS and then exclude the ones you don't want.
Sure...check out the following code.
Its the IT_TOOLBAR_EXCLUDING parameter of the interface of method SET_TABLE_FOR_FIRST_DISPLAY.
look a the form EXCLUDE_TB_FUNCTIONS.
REPORT ZRICH_0001.
TABLES: MARA.
DATA: BEGIN OF I_ALV OCCURS 0,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF I_ALV.
DATA: ALV_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: LAYOUT TYPE LVC_S_LAYO.
DATA: FIELDCAT TYPE LVC_T_FCAT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM GET_DATA.
CALL SCREEN 100.
Module status_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
DATA: VARIANT TYPE DISVARIANT.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
Create Controls
CREATE OBJECT ALV_CONTAINER
EXPORTING
CONTAINER_NAME = 'ALV_CONTAINER'.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = ALV_CONTAINER.
ALV Specific. Data selection.
Populate Field Catalog
PERFORM GET_FIELDCATALOG.
Exclude functions
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
IS_VARIANT = VARIANT
I_SAVE = 'U'
I_STRUCTURE_NAME = 'I_ALV'
it_toolbar_excluding = lt_exclude
CHANGING
IT_OUTTAB = I_ALV[]
IT_FIELDCATALOG = FIELDCAT[].
ENDMODULE.
Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR 'CANC'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
IF SY-SUBRC = 0.
SET SCREEN 0.
LEAVE SCREEN.
ELSE.
LEAVE PROGRAM.
ENDIF.
WHEN 'EXIT'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
FORM GET_DATA
FORM GET_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
FROM MARA
INNER JOIN MAKT
ON MARAMATNR = MAKTMATNR
WHERE MARA~MATNR IN S_MATNR
AND MAKT~SPRAS = SY-LANGU.
SORT I_ALV ASCENDING BY MATNR.
ENDFORM.
Form Get_Fieldcatalog - Set Up Columns/Headers
FORM GET_FIELDCATALOG.
DATA: LS_FCAT TYPE LVC_S_FCAT.
REFRESH: FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Number'.
LS_FCAT-COLTEXT = 'Material Number'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-COL_POS = 1.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Description'.
LS_FCAT-COLTEXT = 'Material Description'.
LS_FCAT-FIELDNAME = 'MAKTX'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '40'.
LS_FCAT-COL_POS = 2.
APPEND LS_FCAT TO FIELDCAT.
ENDFORM.
Form EXCLUDE_TB_FUNCTIONS
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
DATA LS_EXCLUDE TYPE UI_FUNC.
Row manipulation
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
Sort buttons
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_ASC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_DSC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
This excludes all buttons
LS_EXCLUDE = '&EXCLALLFC'.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM.
Best Regards Benita -
How can I select 2 options in Interactive reports
Hi Friends
I have a doubt about Interactive reports/ ALV interactive reports. Is there any option to select multiple selections in interactive reports. If I am displaying in a screen CustNo, Name, Country.
I want to see order details of that customer in another screen using AT Line-Selection. Can I select multiple customer nos at a time and also can I see those order details whom I selected over in first list.
Please send me reply ASAP if there is any option with suitable example.
Thanks
Praveen.Check out this sample. It uses two ALV grids. On the first one you can do multiple selection, hit the continue buttons and it will throw another ALV with those material/plant records. Implement the following program. Create screen 100 and 200. One each screen create a custom container called ALV_CONTAINER(screen 100) and ALV_CONTAINER2(screen 200). Create the gui status for both. Don't forget to create a "CONTINUE" button on the gui-status 100.
report zrich_0006.
tables: mara.
type-pools: slis, icon.
* Internal Tables
data: begin of ialv occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of ialv .
data: begin of ialv2 occurs 0,
matnr type mara-matnr,
werks type marc-werks,
end of ialv2.
* Miscellanous Variables
data: index_rows type lvc_t_row,
index like line of index_rows.
data: alv_container type ref to cl_gui_custom_container,
alv_container2 type ref to cl_gui_custom_container,
alv_grid type ref to cl_gui_alv_grid,
alv_grid2 type ref to cl_gui_alv_grid,
row_table type lvc_t_row with header line,
ok_code like sy-ucomm,
layout type lvc_s_layo,
fieldcat type lvc_t_fcat,
fieldcat2 type lvc_t_fcat.
select-options: s_matnr for mara-matnr.
start-of-selection.
select mara~matnr makt~maktx
into corresponding fields of table ialv
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
sort ialv ascending by matnr.
call screen 100.
* Module status_0100 OUTPUT
module status_0100 output.
set pf-status '0100'.
set titlebar '0100'.
data: lt_exclude type ui_functions.
* Create Controls
create object alv_container
exporting container_name = 'ALV_CONTAINER'.
create object alv_grid
exporting i_parent = alv_container.
* Populate Field Catalog
perform get_fieldcatalog.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
perform exclude_tb_functions changing lt_exclude.
* Set selection mode to "D" -- Multiple Lines
layout-sel_mode = 'D'.
call method alv_grid->set_table_for_first_display
exporting
is_layout = layout
it_toolbar_excluding = lt_exclude
i_structure_name = 'IALV'
changing
it_outtab = ialv[]
it_fieldcatalog = fieldcat[].
endmodule.
* Module USER_COMMAND_0100 INPUT
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
perform free_containers.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
when 'EXIT'.
perform free_containers.
leave program.
when 'CONTINUE'.
* Retrieve selected rows from ALV grid
clear index_rows. refresh index_rows.
call method alv_grid->get_selected_rows
importing
et_index_rows = index_rows.
* Do something with those selected rows here
loop at index_rows into index.
read table ialv index index-index.
if sy-subrc = 0.
select * appending corresponding fields of table ialv2
from marc
where matnr = ialv-matnr.
endif.
endloop.
perform free_containers.
leave to screen 200.
endcase.
endmodule.
* Form FREE_CONTAINERS
form free_containers.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
if not alv_container2 is initial.
call method alv_container2->free.
clear: alv_container2.
free : alv_container2.
endif.
endform.
* Form Get_Fieldcatalog - Set Up Columns/Headers
form get_fieldcatalog.
data: ls_fcat type lvc_s_fcat.
data: columnno(3) type n value '0'.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'IALV'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-coltext = 'Material Description'.
ls_fcat-fieldname = 'MATKX'.
ls_fcat-ref_table = 'IALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat.
endform.
* Form Get_Fieldcatalog2 - Set Up Columns/Headers
form get_fieldcatalog2.
data: ls_fcat type lvc_s_fcat.
data: columnno(3) type n value '0'.
refresh: fieldcat2.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'IALV2'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat2.
clear: ls_fcat.
ls_fcat-reptext = 'Plant'.
ls_fcat-coltext = 'Plant'.
ls_fcat-fieldname = 'WERKS'.
ls_fcat-ref_table = 'IALV2'.
ls_fcat-outputlen = '4'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat2.
endform.
* Form EXCLUDE_TB_FUNCTIONS
form exclude_tb_functions changing pt_exclude type ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).
data ls_exclude type ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
append ls_exclude to pt_exclude.
endform.
* Module status_0200 OUTPUT
module status_0200 output.
set pf-status '0200'.
set titlebar '0200'.
* Create Controls
create object alv_container2
exporting container_name = 'ALV_CONTAINER2'.
create object alv_grid2
exporting i_parent = alv_container2.
* Populate Field Catalog
perform get_fieldcatalog2.
call method alv_grid2->set_table_for_first_display
changing
it_outtab = ialv2[]
it_fieldcatalog = fieldcat2[].
endmodule.
* Module USER_COMMAND_0200 INPUT
module user_command_0200 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
perform free_containers.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
when 'EXIT'.
perform free_containers.
leave program.
endcase.
endmodule.
Regards,
Rich Heilman -
All -
I'm realtively new to ALV grid reporting.
What should be done in order to not get the default setting like sorting,set filter screen Icons and the other icons in the report .
Thanks in advance.You mean that you want to exclude those icons from the toolbar? You can do it by using the exclude parameter.
Here's how. See the parts in bold, you can look at the other functions that can be execluded via SE24 in the attributes tab. Check the attributes that start with MC_FC_
REPORT ZRICH_0001.
TABLES: MARA.
DATA: BEGIN OF I_ALV OCCURS 0,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF I_ALV.
* CLASS cl_event_receiver DEFINITION Handles Double Click
CLASS CL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS HANDLE_DOUBLE_CLICK
FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING E_ROW E_COLUMN.
PRIVATE SECTION.
ENDCLASS.
* CLASS CL_EVENT_RECEIVER IMPLEMENTATION Handles Double Click
CLASS CL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_DOUBLE_CLICK.
PERFORM DRILL_DOWN USING E_ROW-INDEX.
ENDMETHOD.
ENDCLASS.
DATA: ALV_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA: EVENT_RECEIVER TYPE REF TO CL_EVENT_RECEIVER.
DATA: ALV_GRID TYPE REF TO CL_GUI_ALV_GRID.
DATA: LAYOUT TYPE LVC_S_LAYO.
DATA: FIELDCAT TYPE LVC_T_FCAT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001 .
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM GET_DATA.
CALL SCREEN 100.
* Module status_0100 OUTPUT
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
DATA: VARIANT TYPE DISVARIANT.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
* Create Controls
CREATE OBJECT ALV_CONTAINER
EXPORTING
CONTAINER_NAME = 'ALV_CONTAINER'.
CREATE OBJECT ALV_GRID
EXPORTING
I_PARENT = ALV_CONTAINER.
* Create Event Receiver
CREATE OBJECT EVENT_RECEIVER.
* ALV Specific. Data selection.
* Populate Field Catalog
PERFORM GET_FIELDCATALOG.
<b>* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.</b>
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
IS_VARIANT = VARIANT
I_SAVE = 'U'
I_STRUCTURE_NAME = 'I_ALV'
<b> it_toolbar_excluding = lt_exclude</b>
CHANGING
IT_OUTTAB = I_ALV[]
IT_FIELDCATALOG = FIELDCAT[].
* handler for ALV grid
SET HANDLER EVENT_RECEIVER->HANDLE_DOUBLE_CLICK FOR ALV_GRID.
ENDMODULE.
* Module USER_COMMAND_0100 INPUT
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR 'CANC'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
IF SY-SUBRC = 0.
SET SCREEN 0.
LEAVE SCREEN.
ELSE.
LEAVE PROGRAM.
ENDIF.
WHEN 'EXIT'.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
* FORM GET_DATA
FORM GET_DATA.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ALV
FROM MARA
INNER JOIN MAKT
ON MARA~MATNR = MAKT~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MAKT~SPRAS = SY-LANGU.
SORT I_ALV ASCENDING BY MATNR.
ENDFORM.
* Form Get_Fieldcatalog - Set Up Columns/Headers
FORM GET_FIELDCATALOG.
DATA: LS_FCAT TYPE LVC_S_FCAT.
REFRESH: FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Number'.
LS_FCAT-COLTEXT = 'Material Number'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-COL_POS = 1.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Description'.
LS_FCAT-COLTEXT = 'Material Description'.
LS_FCAT-FIELDNAME = 'MAKTX'.
LS_FCAT-REF_TABLE = 'I_ALV'.
LS_FCAT-OUTPUTLEN = '40'.
LS_FCAT-COL_POS = 2.
APPEND LS_FCAT TO FIELDCAT.
ENDFORM.
* DRILL_DOWN
FORM DRILL_DOWN USING INDEX.
READ TABLE I_ALV INDEX INDEX.
IF SY-SUBRC = 0.
SET PARAMETER ID 'MAT' FIELD I_ALV-MATNR.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
ENDIF.
ENDFORM.
<b>***********************************************************************
* Form EXCLUDE_TB_FUNCTIONS
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_ASC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_SORT_DSC.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
** This excludes all buttons
* LS_EXCLUDE = '&EXCLALLFC'.
* APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM.</b>
Regards,
RIch Heilman -
Table with bith dynamic and non dynamic data
Hi all,
We have a report already developed. Now we need add some fields from some table which is dynamic in feature to the final report which is already there.
I need to know how come we can include the dynamic fields into the final internal table.
I tried declaring fieldsymbols inside the data stmt of the final internal table but it shows some syntax error.
Please help me.
ThanksCheck this sample code..
REPORT ztest_dynamic_code.
DATA: BEGIN OF it_tab OCCURS 0,
abc(3),
xyz(3),
pqr(3),
item,
END OF it_tab.
DATA: it_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: i_dyntab TYPE REF TO data. " To create dyn.Itab
DATA:
w_dref TYPE REF TO data,
ind(2) TYPE n,
w_data TYPE REF TO data,
w_text(5),
w_grid TYPE REF TO cl_gui_alv_grid.
DATA: grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY,<fs> TYPE ANY.
DATA: in TYPE i.
*Data population
it_tab-abc = 'ABC'.
it_tab-xyz = 'XYZ'.
it_tab-pqr = 'PQR'.
DO 9 TIMES.
in = in + 1.
it_tab-item = in.
APPEND it_tab.
ENDDO.
*Field cat population.
wa_fieldcat-fieldname = 'ABC'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'abc'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'XYZ'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'XYZ'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'PQR'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'pqr'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'COLOR'.
wa_fieldcat-outputlen = 4.
wa_fieldcat-coltext = 'col'.
APPEND wa_fieldcat TO it_fieldcatalog.
ind = 1.
DO 9 TIMES.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-fieldname.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-coltext.
wa_fieldcat-outputlen = 1.
APPEND wa_fieldcat TO it_fieldcatalog.
CLEAR wa_fieldcat .
ind = ind + 1.
ENDDO.
*-Dynamic Table creation
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = i_dyntab.
ASSIGN i_dyntab->* TO <t_itab>.
CREATE DATA w_data LIKE LINE OF <t_itab>.
ASSIGN w_data->* TO <fs_wa>.
SORT it_tab BY abc xyz pqr.
CLEAR ind.
ind = 4.
*-Final Internal table as per Requirement
do 10 times.
LOOP AT it_tab.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-abc.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-xyz.
UNASSIGN <fs>.
ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-pqr.
UNASSIGN <fs>.
ASSIGN COMPONENT 4 OF STRUCTURE <fs_wa> TO <fs>.
*-You can assign the color conditionally also..
if sy-index = 4.
<fs> = 'C400'.
else.
<fs> = 'C600'.
endif.
UNASSIGN <fs>.
ASSIGN COMPONENT ind OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-item.
UNASSIGN <fs>.
ind = ind + 1.
AT END OF pqr.
APPEND <fs_wa> TO <t_itab>.
* <fs_wa>-color = 'C600'.
ind = 4.
CLEAR <fs_wa>.
ENDAT.
ENDLOOP.
enddo.
*-Display
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
DATA: layout TYPE lvc_s_layo.
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT grid
EXPORTING
i_parent = cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
layout-INFO_FNAME = 'COLOR'.
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = <t_itab>
it_fieldcatalog = it_fieldcatalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT -
How to put icon in selection screen
Hello All,
Can any one tell how to put icons ICON_EXPAND and ICON_COLLAPSE in selection screen and to use.
Good Answers will be appreciated.
Thanks in advance.
Best Regards,
Sasidhar Reddy Matli.hi check his..
REPORT zalv_sel_screen .TABLES: mara.DATA: BEGIN OF i_alv OCCURS 0,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
matkl TYPE mara-matkl,
groes TYPE mara-groes,
maktx TYPE makt-maktx,
END OF i_alv.DATA: alv_container TYPE REF TO cl_gui_docking_container.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: layout TYPE lvc_s_layo.
DATA: fieldcat TYPE lvc_t_fcat.PARAMETERS: p_check.INITIALIZATION. PERFORM get_data.AT SELECTION-SCREEN OUTPUT. DATA: variant TYPE disvariant.
DATA: repid TYPE sy-repid. repid = sy-repid. variant-report = sy-repid.
variant-username = sy-uname. layout-zebra = 'X'.
layout-edit_mode = 'X'. CHECK alv_container IS INITIAL. CREATE OBJECT alv_container
EXPORTING repid = repid
dynnr = sy-dynnr
side = alv_container->dock_at_left
extension = 1500. CREATE OBJECT alv_grid
EXPORTING
i_parent = alv_container.* ALV Specific. Data selection.
Populate Field Catalog
PERFORM get_fieldcatalog. CALL METHOD alv_grid->set_table_for_first_display
EXPORTING
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
CHANGING
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
START-OF-SELECTION.
FORM GET_DATA
FORM get_data. SELECT * INTO CORRESPONDING FIELDS OF TABLE i_alv
FROM mara
INNER JOIN makt
ON maramatnr = maktmatnr
UP TO 100 ROWS
WHERE makt~spras = sy-langu. SORT i_alv ASCENDING BY matnr.ENDFORM. "get_data***************************************************************
Form Get_Fieldcatalog - Set Up Columns/Headers
FORM get_fieldcatalog. DATA: ls_fcat TYPE lvc_s_fcat.
REFRESH: fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '1'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Type'.
ls_fcat-fieldname = 'MTART'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '10'.
ls_fcat-fix_column = 'X'.
ls_fcat-key = 'X'.
ls_fcat-col_pos = '2'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Group'.
ls_fcat-fieldname = 'MATKL'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '12'.
ls_fcat-col_pos = '3'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Size'.
ls_fcat-fieldname = 'GROES'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '30'. ls_fcat-col_pos = '4'.
APPEND ls_fcat TO fieldcat. CLEAR: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'. ls_fcat-col_pos = '5'.
APPEND ls_fcat TO fieldcat.ENDFORM. "get_fieldcatalog -
Hi,
I am working on an a alv report.In the selection screen,if the fiscal period is input based on that the dates have to be calculated and have to be displayed as column headers in the o/p.This colum is dynamic and will change based on the values given in the selection screen.Now I need to populate the values for these dates under the corresponding columns respectively.
Can anyone tell me how can I achieve this?
Regards,
Hemacheck this.. sample code..
REPORT ztest_dynamic_code.
TYPES: BEGIN OF ty_data,
abc(3),
xyz(3),
pqr(3),
item1,
item2,
item3,
item4,
item5,
item6,
item7,
item8,
item9,
END OF ty_data.
DATA: BEGIN OF it_tab OCCURS 0,
abc(3),
xyz(3),
pqr(3),
item,
END OF it_tab.
DATA: it_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: i_dyntab TYPE REF TO data. " To create dyn.Itab
DATA:
w_dref TYPE REF TO data,
ind(2) TYPE n,
w_data TYPE REF TO data,
w_text(5),
w_grid TYPE REF TO cl_gui_alv_grid.
DATA: grid TYPE REF TO cl_gui_alv_grid,
cont TYPE REF TO cl_gui_custom_container.
FIELD-SYMBOLS: <t_itab> TYPE STANDARD TABLE,
<fs_wa> TYPE ANY,<fs> TYPE ANY.
DATA: in TYPE i.
*Data population
it_tab-abc = 'ABC'.
it_tab-xyz = 'XYZ'.
it_tab-pqr = 'PQR'.
DO 9 TIMES.
in = in + 1.
it_tab-item = in.
APPEND it_tab.
ENDDO.
*Field cat population.
wa_fieldcat-fieldname = 'ABC'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'abc'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'XYZ'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'XYZ'.
APPEND wa_fieldcat TO it_fieldcatalog.
wa_fieldcat-fieldname = 'PQR'.
wa_fieldcat-outputlen = 3.
wa_fieldcat-coltext = 'pqr'.
APPEND wa_fieldcat TO it_fieldcatalog.
ind = 1.
DO 9 TIMES.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-fieldname.
CONCATENATE 'ITEM' ind INTO wa_fieldcat-coltext.
wa_fieldcat-outputlen = 1.
APPEND wa_fieldcat TO it_fieldcatalog.
CLEAR wa_fieldcat .
ind = ind + 1.
ENDDO.
*-Dynamic Table creation
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcatalog
IMPORTING
ep_table = i_dyntab.
ASSIGN i_dyntab->* TO <t_itab>.
CREATE DATA w_data LIKE LINE OF <t_itab>.
ASSIGN w_data->* TO <fs_wa>.
SORT it_tab BY abc xyz pqr.
CLEAR ind.
ind = 4.
*-Final Internal table as per Requirement
LOOP AT it_tab.
ASSIGN COMPONENT 1 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-abc.
ASSIGN COMPONENT 2 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-xyz.
UNASSIGN <fs>.
ASSIGN COMPONENT 3 OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-pqr.
UNASSIGN <fs>.
ASSIGN COMPONENT ind OF STRUCTURE <fs_wa> TO <fs>.
<fs> = it_tab-item.
UNASSIGN <fs>.
ind = ind + 1.
AT END OF pqr.
APPEND <fs_wa> TO <t_itab>.
ind = 4.
CLEAR <fs_wa>.
ENDAT.
ENDLOOP.
*-Display
CALL SCREEN 100.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
DATA: layout TYPE lvc_s_layo.
CREATE OBJECT cont
EXPORTING
container_name = 'CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CREATE OBJECT grid
EXPORTING
i_parent = cont
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
grid->set_table_for_first_display(
EXPORTING
is_layout = layout
CHANGING
it_outtab = <t_itab>
it_fieldcatalog = it_fieldcatalog
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT -
hi ,
i have displayed data using method set_table_for_first_display of class CL_GUI_ALV_GRID.
not i have a requirement to provide the functionality to save the variant in alvtoolbar to save the variant so that user can display the required fields only.
we have the variant functionality were user can select the required fields but how can we save that variant?
regards
vijayif you provide the following option then you will be able to save the variant.
call method grid->set_table_for_first_display
exporting
is_layout = layout "This is required
is_variant = variant "This is required
i_save = 'U' " X or A also possible "This is required
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[]. -
Hi All,
I had created a ALV grid control. I want to handle the left most button of the alv grid, which when clicked , entire row gets selected.
I have to do some functionality when this button is clicked. So, can anybody help me in handling this button event.How about just making the row a hotspot. When user double clicks the row, trigger some functionality.
Here is a sample program
report zrich_0001.
data: begin of i_alv occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of i_alv.
* CLASS lcl_event_receiver DEFINITION Handles Double Click
class lcl_event_receiver definition.
public section.
methods handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
private section.
endclass.
* CLASS lCL_EVENT_RECEIVER IMPLEMENTATION Handles Double Click
class lcl_event_receiver implementation.
method handle_double_click.
perform drill_down using e_row-index.
endmethod.
endclass.
data: alv_container type ref to cl_gui_custom_container.
data: event_receiver type ref to lcl_event_receiver.
data: alv_grid type ref to cl_gui_alv_grid.
data: layout type lvc_s_layo.
data: fieldcat type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for i_alv-matnr.
selection-screen end of block b1.
start-of-selection.
select * into corresponding fields of table i_alv
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
sort i_alv ascending by matnr.
call screen 100.
* Module status_0100 OUTPUT
module status_0100 output.
set pf-status '0100'.
set titlebar '0100'.
data: variant type disvariant.
variant-report = sy-repid.
variant-username = sy-uname.
* Create Controls
create object alv_container
exporting
container_name = 'ALV_CONTAINER'.
create object alv_grid
exporting
i_parent = alv_container.
* Create Event Receiver
create object event_receiver.
* ALV Specific. Data selection.
* Populate Field Catalog
data: ls_fcat type lvc_s_fcat.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Number'.
ls_fcat-coltext = 'Material Number'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '18'.
ls_fcat-col_pos = 1.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext = 'Material Description'.
ls_fcat-coltext = 'Material Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-ref_table = 'I_ALV'.
ls_fcat-outputlen = '40'.
ls_fcat-col_pos = 2.
append ls_fcat to fieldcat.
* Set table for display
call method alv_grid->set_table_for_first_display
exporting
is_layout = layout
is_variant = variant
i_save = 'U'
i_structure_name = 'I_ALV'
changing
it_outtab = i_alv[]
it_fieldcatalog = fieldcat[].
* handler for ALV grid
set handler event_receiver->handle_double_click for alv_grid.
endmodule.
* Module USER_COMMAND_0100 INPUT
module user_command_0100 input.
case sy-ucomm.
when 'BACK' or 'CANC'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
if sy-subrc = 0.
set screen 0.
leave screen.
else.
leave program.
endif.
when 'EXIT'.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
leave program.
endcase.
endmodule.
* DRILL_DOWN
form drill_down using index.
read table i_alv index index.
if sy-subrc = 0.
set parameter id 'MAT' field i_alv-matnr.
call transaction 'MM03' and skip first screen.
if not alv_container is initial.
call method alv_container->free.
clear: alv_container.
free : alv_container.
endif.
endif.
endform.
Regards,
Rich Heilman
Maybe you are looking for
-
How to make use of 'Icon Name' in Logical link?
I see the option 'Icon name' in 'define logical links' in SPRO. It does not however has an F4. I tried giving the name of image in the relevant skin. But no image appears besides the logical link. Is there something else that needs to be done to get
-
sorry for my last thread but anyways i was just curious if anyone here tried to flash a 6800nu with a diffrent company bios like say evga or leadtek. do u guys still experience problems after the bios flash?
-
Watch streaming video in konqueror
Is it possible to play streaming video (for example the trailers from apple.com) within konqueror? I tried installing mplayer-plugin and kaffeine, but neither of them were able to do the trick? Has anyone been able to get this working? Thanks in adva
-
Confirm the char value for in UTF8
Hi Team, we are facing an issue with one of the special characters in Oracle Database: 1. We have description with ® in description 2. We have the database charset as UTF8 3. The setting for the application is Unicode 4. When we query the item on the
-
How do I save file thats playing on the screen from the internet that uses flsh player
How do I save a video streaming from the internet being played by flash player?