Report with 5 ALV grids on 1 screen
I am trying to build a screen/report with 5 ALV grids which are interactive. One grid will display all sales order. When I click on a Sales order Hotspot, the items of the sales order would appear in the ALV grid box below.
When i click on an sales order item hotspot, i want the delivery information in another alv grid in the same screen.
There should be 2 more grids - one displaying the customer information -name,address, in one grid and one grid for open items if any. Any advice is welcome . Should I be creating a split container/docking container or multiple containers ? Sample code is welcome.
Edited by: Shareen Hegde on Apr 2, 2008 9:25 PM
Hello Shareen
Below I have added my sample report ZUS_SDN_THREE_ALV_GRIDS showing three interactive ALV grids. Perhaps it might be useful to you. I would prefer one or multiple splitter containers over multiple "stand-alone" containers.
*& Report ZUS_SDN_THREE_ALV_GRIDS
*& Display Customer data in three ALV lists:
*& 1st ALV: Customers
*& 2nd ALV: Sales order of selected customer (double-click)
*& 3rd ALV: Positions of selected sales order (double-click)
*& Double-click on material -> display material (MM02)
*& NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
*& Flow logic of dynpro '0100':
*&PROCESS BEFORE OUTPUT.
*& MODULE STATUS_0100.
*&PROCESS AFTER INPUT.
*& MODULE USER_COMMAND_0100.
REPORT zus_sdn_three_alv_grids.
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_splitter_2 TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_cell_left TYPE REF TO cl_gui_container,
go_cell_right TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
go_grid3 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_vbak TYPE STANDARD TABLE OF vbak,
gt_vbap TYPE STANDARD TABLE OF vbap.
PARAMETERS:
p_bukrs TYPE bukrs DEFAULT '1000'.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender. " sending control, i.e. ALV grid that raised event
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1,
ls_vbak TYPE vbak,
ls_vbap TYPE vbap.
* Distinguish according to sending grid instance
CASE sender.
WHEN go_grid1.
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDERS' ).
WHEN go_grid2.
READ TABLE gt_vbak INTO ls_vbak INDEX e_row-index.
CHECK ( ls_vbak-vbeln IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'ORDER_DETAILS' ).
WHEN go_grid3.
READ TABLE gt_vbap INTO ls_vbap INDEX e_row-index.
CHECK ( ls_vbap-matnr IS NOT INITIAL ).
SET PARAMETER ID 'MAT' FIELD ls_vbap-matnr.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = p_bukrs.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 1
columns = 2
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_left.
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = go_cell_right.
* Create 2nd splitter container
CREATE OBJECT go_splitter_2
EXPORTING
parent = go_cell_left
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid3
EXPORTING
i_parent = go_cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid2.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid3.
* Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_vbak.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAK'
CHANGING
it_outtab = gt_vbak " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_vbap.
CALL METHOD go_grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAP'
CHANGING
it_outtab = gt_vbap " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements (ok_code -> GD_OKCODE)
CALL SCREEN '0100'.
* Flow logic of dynpro:
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "ORDERS"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Refresh display of detail ALV list
CALL METHOD go_grid3->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Orders"
WHEN 'ORDERS'.
PERFORM customer_show_orders.
WHEN 'ORDER_DETAILS'.
PERFORM order_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form CUSTOMER_SHOW_ORDERS
* text
* --> p1 text
* <-- p2 text
FORM customer_show_orders .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM vbak INTO TABLE gt_vbak
WHERE kunnr = ls_knb1-kunnr.
REFRESH: gt_vbap.
ENDFORM. " CUSTOMER_SHOW_ORDERS
*& Form ORDER_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM order_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_vbak TYPE vbak.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_vbak INTO ls_vbak INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM vbap INTO TABLE gt_vbap
WHERE vbeln = ls_vbak-vbeln.
ENDFORM. " ORDER_SHOW_DETAILS
Regards
Uwe
Similar Messages
-
Report with two ALV grids and a header
Hi experts,
I have a report with two ALV grids in the same screen, each one in a separated container. The information displays it correctly. The report has been implemented by using OO Programming.
My real trouble is in the header. It must have a logo, a title with a specific font and other information.
I'll attach a capture of my need:
[Report with two ALV grids and a header|http://picasaweb.google.com/lh/photo/AcQD49QPmm-0L_jL2iMedA?feat=directlink]
Then, I want to set up the header you can see, with logo, a font with specific features. Obviously, the header you see has taken from another report. But is the same idea.
I've tried with a third container, using the CL_GUI_CONTAINER and CL_GUI_CONTAINER classes, but it doesn't work.
Any idea? Would welcome any help you can provide.
Thanks in advance,
Jorge RojasHi, Jorge.
Should the header be a"attached" to any of the ALV? Or it should be carried alone?
If first applies, you've given the solution yourself: put the info & logo in first ALV's header and invoke it from the proper method.
You could use CL_GUI_DOCKING_CONTAINER CLASS to divide screen in several containers and then, in the upper one, I would create another one docking container to divide the screen into two: the written info could be performed with an HTML viewer class and the logo with a CL_GUI_PICTURE element.
Cheers. -
2 alv grids in 1 screen with 2 different header
Hi All,
I have a requirement where in I need to display 2 alv grids in 1 screen and each has its own set of header information. If anybody has come across such a requirement then pls send the code. I can do this using BLOCKED list alv but I want to do in grids.
Thanks in advance.
Sutapa Senguptathr u go with code..
Code listing for: Z_011_ALV_GRID_EVENT
Description: EXAMPLE OF ALV GRID CONTROL
SCREEN 101 : FLOW LOGIC
PROCESS BEFORE OUTPUT.
MODULE STATUS_0101.
MODULE GET_DATA.
MODULE CREATE_OBJECTS.
MODULE SHOW_ALV.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0101.
MODULE POOL Z_011_ALV_GRID_EVENT
PROGRAM Z_011_ALV_GRID_EVENT.
CLASS CL_EVENT_HANDLER DEFINITION
CLASS CL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS: ON_DOUBLE_CLICK FOR EVENT
DOUBLE_CLICK OF CL_GUI_ALV_GRID
IMPORTING ES_ROW_NO E_COLUMN,
ON_RIGHT_CLICK FOR EVENT
RIGHT_CLICK OF CL_GUI_ALV_GRID.
ENDCLASS. "CL_EVENT_HANDLER DEFINITION
CLASS CL_EVENT_HANDLER IMPLEMENTATION
CLASS CL_EVENT_HANDLER IMPLEMENTATION.
METHOD ON_DOUBLE_CLICK.
DATA: TEXT TYPE STRING,
ES_ROW_STRING TYPE STRING.
ES_ROW_STRING = ES_ROW_NO-ROW_ID.
CONCATENATE 'ROW : ' ES_ROW_STRING 'COLUMN : '
E_COLUMN-FIELDNAME INTO TEXT SEPARATED BY SPACE.
MESSAGE TEXT TYPE 'I'.
ENDMETHOD. "ON_DOUBLE_CLICK
METHOD ON_RIGHT_CLICK.
MESSAGE 'RIGHT MOUSE BUTTON HAS CLICKED !!!' TYPE 'I'.
ENDMETHOD. "ON_RIGHT_CLICK
ENDCLASS. "CL_EVENT_HANDLER IMPLEMENTATION
INCLUDE PROGRAMS
INCLUDE Z_011_ALV_GRID_EVENT_TOP. " Global Data
INCLUDE Z_011_ALV_GRID_EVENT_O01. " PBO-Modules
INCLUDE Z_011_ALV_GRID_EVENT_I01. " PAI-Modules
INCLUDE Z_011_ALV_GRID_EVENT_F01. " FORM-Routines
TOP INCLUDE Z_011_ALV_GRID_EVENT_TOP
TYPES AND DATA DECLARATION
TABLES: SFLIGHT.
DATA: OK_CODE TYPE SY-UCOMM,
IT_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT,
R_HANDLER TYPE REF TO CL_EVENT_HANDLER,
R_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
R_GRID TYPE REF TO CL_GUI_ALV_GRID.
PBO INCLUDE Z_011_ALV_GRID_EVENT_O01
Module SHOW_ALV OUTPUT
MODULE SHOW_ALV OUTPUT.
CHECK OK_CODE IS INITIAL.
CALL METHOD R_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
CHANGING
IT_OUTTAB = IT_SFLIGHT.
ENDMODULE. " SHOW_ALV OUTPUT
Module GET_DATA OUTPUT
MODULE GET_DATA OUTPUT.
CHECK OK_CODE IS INITIAL.
PERFORM GET_DATA
USING
SFLIGHT-CARRID.
ENDMODULE. " GET_DATA OUTPUT
Module CREATE_OBJECTS OUTPUT
MODULE CREATE_OBJECTS OUTPUT.
IF R_HANDLER IS NOT BOUND. "CHECKS WHETHER A REFERENCE
"VARIABLE CONTAINS VALID REFERENCE
CREATE OBJECT R_HANDLER.
ENDIF.
IF R_CONTAINER IS NOT BOUND. "CHECKS WHETHER A REFERENCE
"VARIABLE CONTAINS VALID REFERENCE
CREATE OBJECT R_CONTAINER
EXPORTING
CONTAINER_NAME = 'CC_ALV'.
ENDIF.
IF R_GRID IS NOT BOUND.
CREATE OBJECT R_GRID
EXPORTING
I_PARENT = R_CONTAINER.
SET HANDLER R_HANDLER->ON_DOUBLE_CLICK
R_HANDLER->ON_RIGHT_CLICK FOR ALL INSTANCES
ENDIF.
ENDMODULE. " CREATE_OBJECTS OUTPUT
Module STATUS_0101 OUTPUT
MODULE STATUS_0101 OUTPUT.
SET PF-STATUS 'Z_010_STATUS'.
"SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0101 OUTPUT
PAI INCLUDE Z_011_ALV_GRID_EVENT_I01
Module USER_COMMAND_0101 INPUT
MODULE USER_COMMAND_0101 INPUT.
CASE OK_CODE .
WHEN 'SEARCH'.
PERFORM GET_DATA
USING
SFLIGHT-CARRID.
CALL METHOD R_GRID->REFRESH_TABLE_DISPLAY.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0101 INPUT
FORM INCLUDE Z_011_ALV_GRID_EVENT_F01
FORM : GET_DATA
Created : 26.03.2008 12:34:09
FORM GET_DATA USING VALUE(P_CARRID) TYPE SFLIGHT-CARRID.
IF P_CARRID IS INITIAL.
SELECT * FROM SFLIGHT INTO CORRESPONDING
FIELDS OF TABLE IT_SFLIGHT.
ELSE.
SELECT * FROM SFLIGHT INTO CORRESPONDING
FIELDS OF TABLE IT_SFLIGHT WHERE CARRID = P_CARRID.
ENDIF.
ENDFORM. "GET_DATA -
Background Execution Problem-Docking Container with 2 ALV Grids in one scre
Hi Friends,
I have created 2 ALV Grids in one screen - one below another using DOCKING CONTAINER.
The objects are 'g_dock_cont' and 'g_dock_cont1'.
I am getting the foreground output as expected with 2 ALV Grids.
While executing in background (F9), I am getting only output of first ALV grid. Second ALV is not getting displayed in BACKGROUND(F9) mode.
How to solve this.
FORM create_objects.
* Materials with data
IF g_dock_cont IS INITIAL.
IF sy-batch NE 'X'.
*CREATE THE OBJECT FOR DOCKING CONTAINER
CREATE OBJECT g_dock_cont
EXPORTING
side = cl_gui_docking_container=>dock_at_top
extension = 300.
ENDIF.
*CREATE THE OBJECT FOR ALV GRID
CREATE OBJECT g_alvgrid
EXPORTING i_parent = g_dock_cont.
wa_layout-grid_title =
'Materials with Data'.
ENDIF.
IF NOT I_DETAIL[] IS INITIAL.
CALL METHOD g_alvgrid->set_table_for_first_display
EXPORTING
IS_VARIANT = WA_VARIANT_STX
IS_LAYOUT = wa_layout
CHANGING
it_outtab = I_DETAIL
IT_FIELDCATALOG = LIT_FIELDCATALOG[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
IF sy-subrc <> 0.
ENDIF.
ENDIF.
*MATERIALS WITHOUT DATA
IF g_dock_cont1 IS INITIAL.
IF sy-batch NE 'X'.
*CREATE THE OBJECT FOR DOCKING CONTAINER
CREATE OBJECT g_dock_cont1
EXPORTING
side = cl_gui_docking_container=>dock_at_bottom
extension = 300.
ENDIF.
*CREATE THE OBJECT FOR ALV GRID
CREATE OBJECT g_alvgrid1
EXPORTING i_parent = g_dock_cont1.
wa_layout1-grid_title =
'Materials without Data'.
ENDIF.
IF NOT I_MARA[] IS INITIAL.
CALL METHOD g_alvgrid1->set_table_for_first_display
EXPORTING
IS_LAYOUT = wa_layout1
CHANGING
it_outtab = I_MARA
IT_FIELDCATALOG = i_fieldcat[]
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
others = 4
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDFORM. " create_objects
Regards,
Viji.Hi,
What i was saying is that you need to code again for background mode of execution.
AT END OF SELECTION.
IF SY-BATCH EQ 'X'.
PERFORM DISPLAY1.
PERFORM DISPLAY2.
In DISPLAY1 use REUSE_ALV_LIST_DISPLAY to display data from outtab1.
In DISPLAY2 use REUSE_ALV_LIST_DISPLAY to display data from outtab2.
For example : execute this report in background mode.this will not execute in online mode.
After execution you will get two spools one for KNA1 and one for LFA1 data. Spool can be controlled via IS_PRINT structure.
report zrbackground.
data gt_lfa1 type standard table of lfa1.
data gt_kna1 type standard table of kna1.
start-of-selection.
select * from lfa1 into table gt_lfa1 up to 10 rows.
select * from kna1 into table gt_kna1 up to 20 rows.
end-of-selection.
if sy-batch eq 'X'.
perform display_lfa1.
perform display_kna1.
endif.
*& Form DISPLAY_LFA1
text
--> p1 text
<-- p2 text
form display_lfa1 .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
i_structure_name = 'LFA1'
tables
t_outtab = gt_lfa1
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " DISPLAY_LFA1
*& Form DISPLAY_KNA1
text
--> p1 text
<-- p2 text
form display_kna1 .
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program = sy-repid
i_structure_name = 'KNA1'
tables
t_outtab = gt_kna1
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " DISPLAY_KNA1
Please let me know if its not clear or you need more info.
Thanks,
Abhishek
Edited by: abhishek sinha on May 8, 2009 7:42 PM
Edited by: abhishek sinha on May 8, 2009 8:45 PM -
Printing a Report from a ALV Grid
We just did a kenrel upgrade from 6.20 to 6.40
Now, when we go to run a report using an ALV grid it will not print the subtotals. I can see the information fine on the screen but will only print lines with no data!
Any help will be great! thanks...
-DJHi,
Try with this FM
REUSE_ALV_GRID_DISPLAY_LVC" not "REUSE_ALV_GRID_DISPLAY".
Thanks,
Neelima. -
Return from ALV Grid to Selection screen
hi,
I want to go back from ALV grid to selection screen.
I am using the following code:
WHEN 'BACK'.
CALL METHOD grid1->refresh_table_display.
CALL METHOD grid1->free.
CALL METHOD custom_container1->free.
CALL SELECTION-SCREEN 1000.
it is working,but when i press BACK button from selection screen to program it is showing ERROR IN FLUSH 4 Error.
Also I tried with method FLUSH
WHEN 'BACK'.
CALL METHOD grid1->refresh_table_display.
CALL METHOD grid1->free.
CALL METHOD custom_container1->free.
CALL METHOD cl_gui_cfw=>flush.
it's still showing same Error.
Please help on this.
Regards,
SankarHi,
My grid name is grid1.
I tried with :
DATA grid1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = grid1.
CALL METHOD grid1->check_changed_data.
CALL METHOD grid1->refresh_table_display.
LEAVE TO SCREEN 0.
Even, I tried with declaring another grid : grid2
DATA grid1 TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = grid1.
CALL METHOD grid1->check_changed_data.
CALL METHOD grid1->refresh_table_display.
LEAVE TO SCREEN 0.
In both cases, I am getting the following Error : OBJECTS_OBJREF_NOT_ASSIGNED -
Displayig ALV GRID, then a screen with write satetment
Hi,
I developed a program to post GL accounts. First I am displaying a report through ALV GRID(OOPS). I am providing a button on the same screen. If the user clicks it, it will post the GL documents, then I want to display the results from this GL posting. Please help me to display the results in other screen. I am not able to do this.
Thanks,
RaviHi Ravi,
Try this way.
<li>When you click on POST button on ALV, It posts the documents using some BAPI, Here get the all messages into one internal table. I do not know whether you loop and call BAPI or at a time post all GL a/cs. But You need to gather all the messages into one internal table. After postings, Write LEAVE TO LIST PROCESSING AND RETURN TO SCREEN 0. Then loop your message internal table and display using WRITE statement. LEAVE TO LIST PROCESSING will take you to LIST processing displays in classical way.
CASE sy-ucomm.
WHEN 'POST'.
"Post the documents
"Gather all the msges into one internal table.
"Finally call the below statement
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
LOOP AT it_msgs INTO wa_msgs.
WRITE:/ wa_msgs-message.
ENDLOOP.
ENDCASE.
Thanks
Venkat.O -
To Display Report in a ALV GRID Format
Hi All,
I want to display dome information in ALV Grid format.
Can anybody give example for displaying data in ALV Grid Format.
Thanks in advance.
Thanks & Regards,
Rayeez.Hi ,
1.FOR ALV Lists..
REPORT Y_DEMO_ALV NO STANDARD PAGE HEADING.
Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.
2.Using Grids..
REPORT Y_DEMO_ALV_1.
Data to be displayed
DATA: I_SFLIGHT TYPE TABLE OF SFLIGHT.
Selection
SELECT * FROM SFLIGHT INTO TABLE I_SFLIGHT.
Call ABAP List Viewer (ALV)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_STRUCTURE_NAME = 'SFLIGHT'
TABLES
T_OUTTAB = I_SFLIGHT.
3.Demo Using most of the ALv Functionalities..
REPORT ZSATTRIAL4.
TYPE-POOLS: slis.
DB-Table
TABLES sflight.
Includes
INCLUDE <icon>.
INCLUDE <symbol>.
CONSTANTS:
c_formname_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE'.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
i_sp_group TYPE slis_t_sp_group_alv,
i_events TYPE slis_t_event,
i_print TYPE slis_print_alv,
i_sort TYPE slis_t_sortinfo_alv.
*internal table for data to be displayed
DATA: BEGIN OF i_sflight OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: box,
lights.
DATA: END OF i_sflight.
DATA: w_repid LIKE sy-repid.
DATA: i_list_top_of_page TYPE slis_t_listheader.
Report Selections
SELECT-OPTIONS s_carrid FOR sflight-carrid.
SELECT-OPTIONS s_connid FOR sflight-connid.
SELECT-OPTIONS s_fldate FOR sflight-fldate.
*SELECTION-SCREEN SKIP 1.
Parameters
PARAMETERS: p_maxrow TYPE i DEFAULT 30."to limit the selection
SELECTION-SCREEN SKIP 1.
Variant for ALV display
SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.
PARAMETERS: p_varnt LIKE disvariant-variant.
SELECTION-SCREEN END OF BLOCK 0.
Layout of the report display
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-001.
PARAMETERS: p_zebra AS CHECKBOX DEFAULT ' ', "Striped pattern
p_nocolh AS CHECKBOX DEFAULT ' ', "No column heading
p_novlin AS CHECKBOX DEFAULT ' ', "No vertical lines
p_colopt AS CHECKBOX DEFAULT ' ', "Optimizes col. wd
p_keyhot AS CHECKBOX DEFAULT ' ', "Key fields hot
p_noinpt AS CHECKBOX DEFAULT ' '. "No field for input
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-002.
PARAMETERS: p_lights AS CHECKBOX DEFAULT 'X',
p_lightc AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
PARAMETERS: p_totonl AS CHECKBOX DEFAULT ' ',
p_totext(60),
p_sttext(60).
SELECTION-SCREEN END OF BLOCK c.
SELECTION-SCREEN BEGIN OF BLOCK d WITH FRAME TITLE text-004.
PARAMETERS: p_chkbox AS CHECKBOX DEFAULT 'X',
p_detpop AS CHECKBOX DEFAULT 'X',
p_groupb AS CHECKBOX DEFAULT ' ',
p_groups AS CHECKBOX DEFAULT ' '.
SELECTION-SCREEN END OF BLOCK d.
SELECTION-SCREEN BEGIN OF BLOCK e WITH FRAME TITLE text-005.
PARAMETERS: p_print AS CHECKBOX DEFAULT ' ',
p_nosinf AS CHECKBOX DEFAULT ' ',
p_nocove AS CHECKBOX DEFAULT ' ',
p_nonewp AS CHECKBOX DEFAULT ' ',
p_nolinf AS CHECKBOX DEFAULT ' ',
p_reserv TYPE i.
SELECTION-SCREEN END OF BLOCK e.
DATA: w_boxnam TYPE slis_fieldname VALUE 'BOX',
w_f2code LIKE sy-ucomm VALUE '&ETA',
w_lignam TYPE slis_fieldname VALUE 'LIGHTS',
w_save(1) TYPE c,
w_default(1) TYPE c,
w_exit(1) TYPE c,
i_variant LIKE disvariant,
i_variant1 LIKE disvariant.
INITIALIZATION.
w_repid = sy-repid.
PERFORM fieldcat_init USING i_fieldcat.
PERFORM eventtab_build USING i_events.
PERFORM comment_build USING i_list_top_of_page.
PERFORM sp_group_build USING i_sp_group.
PERFORM t_sort_build USING i_sort.
Set Options: save variant userspecific or general
'A or 'U' are for user-specific variants list
'X' or 'space' for general
w_save = 'A'.
PERFORM variant_init.
Get default variant
i_variant1 = i_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 0.
p_varnt = i_variant1-variant.
ENDIF.
Process on value request (list of possible variants)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.
PERFORM f4_for_variant.
PAI
AT SELECTION-SCREEN.
PERFORM pai_of_selection_screen.
START-OF-SELECTION.
PERFORM selection.
END-OF-SELECTION.
PERFORM layout_build USING i_layout. "wg. Parameters
PERFORM print_build USING i_print. "wg. Parameters
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'I_SFLIGHT'
i_structure_name = 'SFLIGHT'
i_client_never_display = 'X'
i_inclname = w_repid
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Call ABAP/4 List Viewer
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_callback_program = w_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
i_structure_name = 'SFLIGHT'
i_background_id = 'ALV_BACKGROUND'
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_print
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = i_sflight
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_structure_name = 'SFLIGHT'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
it_special_groups = i_sp_group[]
it_sort = i_sort[]
IT_FILTER =
IS_SEL_HIDE =
i_default = W_DEFAULT
i_save = w_save
is_variant = i_variant
it_events = i_events[]
IT_EVENT_EXIT =
is_print = i_print
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
TABLES
t_outtab = i_sflight.
FORM FIELDCAT_INIT *
--> L_FIELDCAT *
FORM fieldcat_init USING l_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSOCC'.
*The field is not displayed in the initial output, can be interactively
chosen for display
ls_fieldcat-no_out = 'X'.
*This field is assigned to a special group with tech. key 'A' and can be
*displayed using the special group buttons
ls_fieldcat-sp_group = 'A'.
*The field cannot be summed irrespective of its data type
ls_fieldcat-no_sum = 'X'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'SEATSMAX'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'A'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'PRICE'.
ls_fieldcat-no_out = 'X'.
ls_fieldcat-sp_group = 'B'.
APPEND ls_fieldcat TO l_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'CARRID'.
ls_fieldcat-outputlen = 7.
APPEND ls_fieldcat TO l_fieldcat.
ENDFORM.
FORM DATA_ADD *
--> L_SFLIGHT
FORM data_add TABLES l_sflight STRUCTURE i_sflight.
LOOP AT l_sflight.
IF sy-tabix > 10.
l_sflight-box = 'X'.
l_sflight-lights = '3'.
ELSE.
IF sy-tabix = 1.
l_sflight-lights = '2'.
ELSE.
l_sflight-lights = '1'.
ENDIF.
ENDIF.
MODIFY l_sflight.
ENDLOOP.
ENDFORM.
FORM EVENTTAB_BUILD *
--> l_EVENTS *
FORM eventtab_build USING l_events TYPE slis_t_event.
DATA: ls_event TYPE slis_alv_event.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = l_events.
READ TABLE l_events WITH KEY name = slis_ev_top_of_page INTO ls_event.
IF sy-subrc = 0.
MOVE c_formname_top_of_page TO ls_event-form.
APPEND ls_event TO l_events.
ENDIF.
ENDFORM.
FORM COMMENT_BUILD *
--> L_TOP_OF_PAGE *
FORM comment_build USING l_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
***Header
CLEAR ls_line.
ls_line-typ = 'H'.
LS_LINE-KEY: not used for this type
ls_line-info = 'Heading list'.
APPEND ls_line TO l_top_of_page.
***Selection
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Information'.
APPEND ls_line TO l_top_of_page.
ls_line-key = 'Key 2'.
APPEND ls_line TO l_top_of_page.
***Action
CLEAR ls_line.
ls_line-typ = 'A'.
LS_LINE-KEY: not used for this type
Ls_line-info = 'Status list'.
APPEND ls_line TO l_top_of_page.
ENDFORM.
FORM LAYOUT_BUILD *
<-> LS_LAYOUT *
FORM layout_build USING ls_layout TYPE slis_layout_alv.
ls_layout-f2code = w_f2code.
ls_layout-zebra = p_zebra.
ls_layout-colwidth_optimize = p_colopt.
IF p_chkbox = 'X'.
*Fieldname for check box on the report output
ls_layout-box_fieldname = w_boxnam.
ELSE.
ls_layout-box_fieldname = space.
ENDIF.
ls_layout-no_input = p_noinpt.
ls_layout-no_vline = p_novlin.
ls_layout-no_colhead = p_nocolh.
IF p_lights = 'X' OR p_lightc = 'X'.
**Fieldname for lights on the report output
ls_layout-lights_fieldname = w_lignam.
ELSE.
CLEAR ls_layout-lights_fieldname.
ENDIF.
ls_layout-lights_condense = p_lightc.
ls_layout-totals_text = p_totext.
ls_layout-subtotals_text = p_sttext.
ls_layout-totals_only = p_totonl.
ls_layout-key_hotspot = p_keyhot.
ls_layout-detail_popup = p_detpop.
ls_layout-group_change_edit = p_groups.
E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.
ls_layout-group_buttons = 'X'.
ENDFORM.
FORM SP_GROUP_BUILD *
--> L_SP_GROUP *
FORM sp_group_build USING l_sp_group TYPE slis_t_sp_group_alv.
DATA: ls_sp_group TYPE slis_sp_group_alv.
*Fields are assigned to the special group
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'A'.
ls_sp_group-text = 'Reservation status'.
APPEND ls_sp_group TO l_sp_group.
CLEAR ls_sp_group.
ls_sp_group-sp_group = 'B'.
ls_sp_group-text = 'Flight charges'.
APPEND ls_sp_group TO l_sp_group.
ENDFORM.
FORM SELECTION *
FORM selection.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE i_sflight
UP TO p_maxrow ROWS WHERE carrid IN s_carrid
AND connid IN s_connid AND fldate IN s_fldate.
PERFORM data_add TABLES i_sflight.
ENDFORM.
FORM TOP_OF_PAGE *
FORM top_of_page.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
i_logo = 'ENJOYSAP_LOGO'
it_list_commentary = i_list_top_of_page.
ENDFORM.
FORM F4_FOR_VARIANT *
FORM f4_for_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = i_variant
i_save = w_save
it_default_fieldcat =
IMPORTING
e_exit = w_exit
es_variant = i_variant1
EXCEPTIONS
not_found = 2.
IF sy-subrc = 2.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF w_exit = space.
p_varnt = i_variant1-variant.
ENDIF.
ENDIF.
ENDFORM.
*& Form PAI_OF_SELECTION_SCREEN
to check whether right variant is entered on the selection scr
FORM pai_of_selection_screen.
IF NOT p_varnt IS INITIAL.
MOVE i_variant TO i_variant1.
MOVE p_varnt TO i_variant1-variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
EXPORTING
i_save = w_save
CHANGING
cs_variant = i_variant1.
i_variant = i_variant1.
ELSE.
PERFORM variant_init.
ENDIF.
ENDFORM. " PAI_OF_SELECTION_SCREEN
*& Form VARIANT_INIT
FORM variant_init.
CLEAR i_variant.
i_variant-report = w_repid.
ENDFORM. " VARIANT_INIT
FORM PRINT_BUILD *
FORM print_build USING l_print TYPE slis_print_alv.
l_print-print = p_print.
l_print-no_print_selinfos = p_nosinf.
l_print-no_coverpage = p_nocove.
l_print-no_new_page = p_nonewp.
l_print-no_print_listinfos = p_nolinf.
l_print-reserve_lines = p_reserv.
l_print-print = p_print.
ENDFORM.
FORM T_SORT_BUILD *
FORM t_sort_build USING l_sort TYPE slis_t_sortinfo_alv.
DATA: ls_sort TYPE slis_sortinfo_alv.
ls_sort-fieldname = 'CARRID'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
APPEND ls_sort TO l_sort.
ps : reward points for helpful answers and mark the post as closed.. -
For all users having probs with OO ALV Grid
I wanted to put this in the WIKI but it keeps bombing out when I try and save so I've put this here -- Maybe a MOD can move it for me.
This generic class should give you far more insite into using an EDITABLE ALV table than the standard documentation.
If you follow the steps you should be able to code very quickly a decent useable ALV OO program which can retrieve and manipulate data very easily. The events are (hopefully) well documented as are all the steps.
Once you understand the basics you can add more functionality like colouring Cells, adding hyperlinks etc etc.
I've always found that stupid SEAT / AIRLINE application SAP uses for its examples far too overblown and in reality who would ever use a SAP system for Airline reservations anyway.
The class here describes a much simpler application which CLEARLY (I hope) explains how the whole thing works.
Jimbo's generic class for using the OO ALV GRID Class CL_GUI_ALV_GRID
from an application program to display and manipulate ANY table
with minimal coding needed in the Calling application program.
Handles the following EVENTS
1) TOOLBAR BUTTONS
(you can add more to the toolbar method
if you need even more functionality).
2) DOUBLE CLICK
3) ENTER KEY PRESSED
4) DATA CHANGED
5) DATA CHANGED FINISHED
Methods available
PUBLIC METHODS ( Can be called directly from the application program).
1) display_grid displays grid with toolbar
Table and FCAT are built dynamically - user only needs to
define the table structure (can be DDIC or User fields)
2) change_title - changes title at the top of the Grid
3) refresh_grid - refreshes grid after table updated etc.
4) build_dynamic_structures - this method creates a dynamic table and a dynamic FCAT
using the structure defined in the calling application program
PRIVATE METHODS (Internal Methods used within the class)
1) verwerk - returns to FORM VERWERK in calling application program
(Via Toolbar). The application program can then do any special processing
at this point e.g update SAP tables etc.
2) download_to_excel (via Toolbar). This creates an EXCEL spreadsheet
directly which can be downloaded / saved to a file if required,
3) return_structure - internal method returns the structure
of the table defined in the calling application program. This is needed in order
to build the dynamic table and Field Catalog.
4) create_dynamic_table - creates a dynamic table from the structure defined in
the calling application program
5) create_dynamic_fcat - creates the dynamic field catalog from the structure
defined in the application program.
6) dubbleklik entered when user double clicks a cell
activated by EVENT DOUBLE_CLICK.
returns to FORM DUBBELKLIK in the
calling application program
COOKBOOK STEP BY STEP instructions on how to use this class
in your application program.
In the application program :
1) define a blank screen 100 - SE51 with a custom container
on it called CCONTAINER1.
you need the following logic in the screen
The PAI is only used if you have defined a STATUS with SE41 and you exit the
application program via the standard SAP buttons on the
top of the Screen (NOT the GRID toolbar).
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
2) (optional) define a STATUS with a titlebar - SE41
you only need this if you want the standard EXIT and menu buttons on the
top line of the screen
3) If you want to have your OWN colum names on the grid
add the following macro to the start of your program
DEFINE col_name.
read table it_fldcat into wa_it_fldcat index &1.
wa_it_fldcat-coltext = &2.
modify it_fldcat from wa_it_fldcat index &1.
END-OF-DEFINITION.
4) Define the following Field symbols
<fs1> TYPE ANY,
<fs2> TYPE STANDARD TABLE,
<fs3> TYPE ANY,
<field_catalog> TYPE STANDARD TABLE,
<dyn_table> TYPE STANDARD TABLE,
<orig_table> TYPE STANDARD TABLE,
<dyn_field>,
<dyn_wa>.
5) After the field-symbols add the code in this class
as an INCLUDE
e.g INCLUDE ZZJIMBOXX_INCL.
6) define your Internal table as follows
TYPES: BEGIN OF s_elements,
Your structure
your structure etc.
END OF s_elements.
For example
INCLUDE <icon>.
TABLES: VAPMA.
*TYPES: BEGIN OF s_elements,
vbeln TYPE vapma-vbeln,
posnr TYPE vapma-posnr,
matnr TYPE vapma-matnr,
kunnr TYPE vapma-kunnr,
werks TYPE vapma-werks,
vkorg TYPE vapma-vkorg,
vkbur TYPE vapma-vkbur,
status TYPE c,
*END OF s_elements.
7) Define the following data IN YOUR APPLICATION PROGRAM
(note here only data is described
that relates to using THIS CLASS. Data purely used internally
in the application program is NOT shown here).
DATA: z_object TYPE REF TO zcl_dog, "Instantiate our class
grid_container1 TYPE REF TO cl_gui_custom_container,
t_elements TYPE TABLE OF s_elements, "refers to our ITAB
wa_elements TYPE s_elements,
wa_dyn_table_line TYPE REF TO DATA,
it_fldcat TYPE lvc_t_fcat,
i_gridtitle TYPE lvc_title,
wa_it_fldcat TYPE lvc_s_fcat,
new_table TYPE REF TO DATA,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
row_id TYPE sy-index.
8) insert the following code at the start of the application program.
*START-OF-SELECTION.
*CALL SCREEN 100.
*END-OF-SELECTION.
*MODULE status_0100 OUTPUT.
*ASSIGN wa_elements TO <fs1>.
*CREATE OBJECT z_object EXPORTING z_object = z_object. "Instantiate the class
*CALL METHOD z_object->build_dynamic_structures
CHANGING it_fldcat = it_fldcat.
9) if you inserted the macro in step 3) then
define your own column names as follws
col_name 1 'Name1'.
col_name 2 'Name2'.
etc. The number is the colum number you want and the name is
the name you want to assign to the column.
for example using the table shown above
col_name 1 'Order Nr'.
col_name 2 'Item'.
col_name 3 'Material'.
col_name 4 'Customer'.
col_name 5 'Plant'.
col_name 6 'Sales Org'.
col_name 7 'Sales Office'.
col_name 8 'Status'.
10) perform a routine that fills your dynamic table and
display the GRID. If you created a status with SE41 you can set
a title etc. Further processing is dependent on the users action
after the GRID is displayed for example if a Cell is double clicked,
dat is entered, a toolbar button is pressed or a SAP ICON on top of the screen is pressed.
PERFORM populate_dynamic_itab.
CALL METHOD z_object->display_grid
CHANGING it_fldcat = it_fldcat.
SET PF-STATUS '0001'.
SET TITLEBAR '000'.
ENDMODULE.
11) If you added a STATUS via SE41 you can exit the program via the
standard SAP buttons at the top of the screen
otherwise exit via the exit button on the toolbar.
You only need this piece of code if you defined a STATUS in the application program
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'RETURN'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
12) to populate the dynamic table you only need to code something like this
remember the class has already created and structured the field-symbol <dyn_table>
so you don't have to do anything other than just select the fields you want
filled and from what data source(es).
*FORM populate_dynamic_itab.
*SELECT vbeln posnr matnr kunnr werks vkorg vkbur
UP TO 200 rows
FROM vapma
INTO CORRESPONDING FIELDS OF TABLE <dyn_table>.
if you want to keep the original table before making any changes etc code
the following
create 2nd Dyn table to hold original data. We can use
the same field catalog as for the original table
as we are just creating an identical copy here.
*CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <orig_table>.
CREATE DATA dy_line LIKE LINE OF <orig_table>.
ASSIGN dy_line->* TO <dyn_wa>.
<orig_table> = <dyn_table>.
ENDFORM.
13) you need these 2 processing routines in your application program.
FORM VERWERK. "Entered from VERW on toolbar
*break-point 1.
Orig table is in dynamic table <orig_table>
ALV GRID changed table is in <dyn_table>.
*Loop at <orig_table> into <dyn_wa>.
Do what you want here
end
endloop.
ENDFORM.
*form dubbleklik using "Entered when a cell is double clicked
e_row type LVC_S_ROW
e_column type LVC_S_col
es_row_no type lvc_s_roid.
break-point 1.
Get Row id into a variable for this program.
row_id = e_row.
SET TITLEBAR '001'. "If you defined a status in SE41
i_gridtitle = 'Grid Title Changed'.
CALL METHOD z_object->change_title
EXPORTING i_gridtitle = i_gridtitle.
PERFORM refresh.
endform.
The REFRESH routine is optional but after a double click I assume
you want to do some processing
and re-display the data
so as a sample code something like
*FORM refresh.
data: ord_nr TYPE vapma-vbeln. "Your data
*READ TABLE <dyn_table> index row_id into wa_elements.
ord_nr = wa_elements-vbeln.
You've now got the Row double clicked so pick out the data element(s)
you wnat to process and do your processing
*set parameter id 'AUN' field ord_nr.
*CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
You can update the dynamic table for example
*wa_elements-status = 'C'.
*modify <dyn_table> from wa_elements index row_id.
now redisplay the updated grid.
*CALL METHOD z_object->refresh_grid.
*ENDFORM.
*************Class ZCL_DOG*************
CLASS zcl_dog DEFINITION.
PUBLIC SECTION.
METHODS:
constructor
IMPORTING
z_object TYPE REF TO zcl_dog,
display_grid
CHANGING
it_fldcat TYPE lvc_t_fcat,
build_dynamic_structures
CHANGING it_fldcat TYPE lvc_t_fcat,
change_title
IMPORTING
i_gridtitle TYPE lvc_title,
refresh_grid.
PRIVATE SECTION.
METHODS:
on_user_command FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm
sender,
on_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
on_dubbelklik FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row
e_column
es_row_no,
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed,
handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING e_modified
et_good_cells,
verwerk
IMPORTING program TYPE sy-repid,
download_to_excel,
dubbleklik
IMPORTING
e_row type LVC_S_ROW
e_column TYPE LVC_S_COL
es_row_no type lvc_s_ROID
program type sy-repid,
return_structure,
create_dynamic_fcat
EXPORTING it_fldcat TYPE lvc_t_fcat,
create_dynamic_table
IMPORTING it_fldcat TYPE lvc_t_fcat
EXPORTING dy_table TYPE REF TO DATA.
DATA:
lr_rtti_struc TYPE REF TO cl_abap_structdescr, "RTTI
zog LIKE LINE OF lr_rtti_struc->components, "RTTI
wa_it_fldcat TYPE lvc_s_fcat,
it_fldcat TYPE lvc_t_fcat,
dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
struct_grid_lset TYPE lvc_s_layo,
e_row TYPE LVC_S_ROW,
e_column TYPE lvc_s_col,
es_rowid TYPE lvc_s_roid,
grid_container1 TYPE REF TO cl_gui_custom_container,
grid1 TYPE REF TO cl_gui_alv_grid,
ls_layout TYPE kkblo_layout,
lt_fieldcat_wa TYPE kkblo_fieldcat,
l_mode TYPE raw4,
celltab TYPE LVC_T_STYL,
wa_celltab TYPE lvc_s_styl,
lt_fieldcat TYPE kkblo_t_fieldcat,
l_tabname TYPE slis_tabname.
TYPES:
struc LIKE zog.
DATA:
zogt TYPE TABLE OF struc.
ENDCLASS.
CLASS zcl_dog IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT grid_container1
EXPORTING
container_name = 'CCONTAINER1'.
CREATE OBJECT grid1
EXPORTING
i_parent = grid_container1.
SET HANDLER z_object->on_user_command for grid1.
SET HANDLER z_object->on_toolbar for grid1.
SET HANDLER Z_OBJECT->handle_data_changed_finished FOR grid1.
SET HANDLER Z_OBJECT->on_dubbelklik FOR grid1.
CALL METHOD grid1->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDMETHOD.
METHOD refresh_grid.
CALL METHOD cl_gui_cfw=>flush.
CALL METHOD grid1->refresh_table_display.
ENDMETHOD.
METHOD on_dubbelklik.
CALL METHOD me->dubbleklik
EXPORTING
e_row = e_row
e_column = e_column
es_row_no = es_row_no
program = sy-repid.
break-point 1.
ENDMETHOD.
METHOD handle_data_changed.
Insert user code here if required
this method is entered if user ENTERS DATA.
ENDMETHOD.
METHOD handle_data_changed_finished.
Insert user code here if required
Method entered here after data entry has finished.
ENDMETHOD.
METHOD return_structure.
lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA( <fs1> ).
zogt[] = lr_rtti_struc->components.
ASSIGN zogt[] TO <fs2>.
ENDMETHOD.
METHOD create_dynamic_fcat.
LOOP AT <fs2> INTO zog.
CLEAR wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
APPEND wa_it_fldcat TO it_fldcat .
ASSIGN it_fldcat[] TO <field_catalog>.
ENDLOOP.
ASSIGN it_fldcat[] TO <field_catalog>.
ENDMETHOD.
METHOD download_to_excel.
break-point 5.
CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
EXPORTING
it_fieldcat_lvc = <field_catalog>
is_layout_lvc = m_cl_variant->ms_layout
is_tech_complete = ' '
IMPORTING
es_layout_kkblo = ls_layout
et_fieldcat_kkblo = lt_fieldcat.
LOOP AT lt_fieldcat INTO lt_fieldcat_wa.
CLEAR lt_fieldcat_wa-tech_complete.
IF lt_fieldcat_wa-tabname IS initial.
lt_fieldcat_wa-tabname = '1'.
MODIFY lt_fieldcat FROM lt_fieldcat_wa.
ENDIF.
l_tabname = lt_fieldcat_wa-tabname.
ENDLOOP.
CALL FUNCTION 'ALV_XXL_CALL'
EXPORTING
i_tabname = l_tabname
is_layout = ls_layout
it_fieldcat = lt_fieldcat
i_title = sy-title
TABLES
it_outtab = <dyn_table>
EXCEPTIONS
fatal_error = 1
no_display_possible = 2
others = 3.
IF sy-subrc <> 0.
message id sy-msgid type 'S' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDMETHOD.
METHOD create_dynamic_table.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fldcat
IMPORTING
ep_table = dy_table.
ENDMETHOD.
METHOD build_dynamic_structures.
CALL METHOD me->return_structure.
CALL METHOD me->create_dynamic_fcat
IMPORTING
it_fldcat = it_fldcat.
CALL METHOD me->create_dynamic_table
EXPORTING
it_fldcat = it_fldcat
IMPORTING
dy_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDMETHOD.
METHOD display_grid.
struct_grid_lset-edit = 'X'. "To enable editing in ALV
struct_grid_lset-grid_title = 'Bulkwijzigingen inkoopprijzen'.
struct_grid_lset-ctab_fname = 'T_CELLCOLORS'.
struct_grid_lset-stylefname = 'CELLTAB'.
CALL METHOD grid1->set_ready_for_input
EXPORTING
i_ready_for_input = '1'.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
is_layout = struct_grid_lset
CHANGING
it_outtab = <dyn_table>
it_fieldcatalog = it_fldcat.
ENDMETHOD.
METHOD change_title.
CALL METHOD grid1->set_gridtitle
EXPORTING
i_gridtitle = i_gridtitle.
ENDMETHOD.
METHOD on_user_command.
CASE e_ucomm.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'EXCEL'.
CALL METHOD me->download_to_excel.
WHEN 'SAVE'.
WHEN 'VERW'.
CALL METHOD me->verwerk
EXPORTING
PROGRAM = SY-REPID.
ENDCASE.
ENDMETHOD. "on_user_command
METHOD on_toolbar.
User can add extra functionality by adding extra
buttons if required. Functionality can also be simplified by removing buttons.
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_end TO ls_toolbar-icon.
MOVE 'Click2Exit' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'SAVE' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Save data' TO ls_toolbar-quickinfo.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EDIT' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_toggle_display_change TO ls_toolbar-icon.
MOVE 'Edit data' TO ls_toolbar-quickinfo.
MOVE 'EDIT' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'VERW' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_businav_process to ls_toolbar-icon.
MOVE 'Verw.' TO ls_toolbar-quickinfo.
MOVE 'VERW' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'EXCEL' TO ls_toolbar-function.
MOVE SPACE TO ls_toolbar-disabled.
MOVE icon_xxl TO ls_toolbar-icon.
MOVE 'Excel' TO ls_toolbar-quickinfo.
MOVE 'EXCEL' TO ls_toolbar-text.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
METHOD verwerk.
PERFORM verwerk IN PROGRAM (program).
LEAVE PROGRAM.
ENDMETHOD.
METHOD dubbleklik.
PERFORM dubbleklik IN PROGRAM (program)
USING
e_row
e_column
es_row_no.
ENDMETHOD.
ENDCLASS.
Cheers
JimboHi Dinu,
Before analysing ALV, please cross check the behaviour of the calling program.
Is the control really going to the application server when you do all the above process?
If so, when user makes some changes are they saved in the data base / affected the internal table which you are using for ALV?
Regards
Surya. -
ALV grid in Spool screen limit
Hi,
I am displaying a report for bulk of order.
So we will schedule it in background .
Through the program, i am creating the output as file in appln server also i m dispklaying the report in ALV grid.
now the report is working fine and its creating a file in appln server.
Now my problem is if I see the spool in SM37,its showing the ALV grid. but some columns are missing in the right side.
I hope this is because of the screen limitation.How should I solve this.
I have to allow the user to see all the columns.Hi
I too have the same issue....Where u able to find the solution...
I have checked through this Thread, when I create a new Format 65_1000, I still get some pages missing
Re: Spool ALV LIST
Your responses will be helpful.
Thanks,
Chaithanya k -
Print Issue with Sorted ALV Grid
Hi Team,
I am using ALV display for my Program. Iam using REUSE_ALV_GRID_DISPLAY. Also i have a Sorting condition for my ALV grid. So iam filling the Sort table & passing it to the Function module. The data is displayed correctly with Sorting as required in the Output.
Now the issue is with: Print from this ALV. When we try to print the data, The requirement is that the Print should be same as how it is displayed in the ALV. "Grouped Columns"..... But now, the Print is that all the data is filled in all the columns. But user wants the Print also to appear same as it is shown in a Sorted ALV display.(With some similar column data missing in succeding sort columns until new entry starts)
Please suggest a solution to acheive the same.
Thanks & regards,
ChaitanyaLook at Q#19 in the note 1009650. Merging functionality is available only for ALV grid display.
Related Note: 447055
Work around would be to display the excel in the SAP window (Excel in Place) and print it from Excel. Read the following thread to make the necessary settings to make it work. Download Report exactly same as seems with Layout set !!
Edited by: Jeevan Sagar on Jan 19, 2012 12:38 AM -
Display alv grids in selection screen based on the user event
Hi All,
I am workign on displaying ALV in same selection screen.I am able to display the ALV in selection screen.
But i have 2 buttons in my selection screen 'Create' and 'change'.
When i click on create i need with some type of data and when i click on 'change' my alv grid another type of data.Ex: if i click on crate mara data should be dispalyed when i click on change makt table data should be dispalyed and also i have user defined buttons are in my grids.
So i have used 2 containers to dispaly to different data.I am able to display the perfectly but the problem is first time when i click on create the grid is displaying when i click on change button the create alv grid is displaying down and change data is dispalying up.
I need only one alv grid at a time.Can anybody please let me know how can i do this.
Thanks,
TaraginiHello,
Also I would suggest if it is relevant data maintain in one interntal table and show/hide based on condition
through fieldcatalog (NO_OUT) parameter.
Thanks -
Urgent : Problem with Editable ALV Grid for Quantity and Currency Fields
Hi All,
I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
When user changes these values these values are not changing properly .
For the quantity field the domain is MENG13 with 3 deciamal places and here if we enter 500 it takes it as 0.500 .
The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
Here also it takes last 2 digits after decimal places by default.
Please advice how to get proper values in this case from ALV editable fields.
Thanks and Regards
Harshad
Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AMfor all the currency field , it will display like that only.
u have to manipulate uin program before displaying.
if they are giving 500, in program multiply with 100 and move it to table.
when u are getting from table, divinde and display.
this is what I am doing.
Reward if helpfull. -
Resizing ALV Grid When Changing Screen Resolution
I have an ALV Grid imbedded in a custom container. I would like for the Grid to resize if the user switches from 1024x768 to 800x600 resolution. I obviously could size it for the lower res screen (and it would be ok on the higher res screen), but I ultimately would like it to resize. Does anyone know how to make this happen?
Is your Grid running within a custom container that was placed in the screen painter? If so this is very easy. Just make you screen very large (much larger then even 1024x768). When you lay down the custom container, make it large enough to fill the entire empty area. Your custom container should have a Resizing section in the attributes window. Just check on Vertical and Horizontal resizing and choose you minimum size.
-
Report program for alv grid in hierarchial manner
I have a requirement where I need to display values in hierarchial fashion. can anyone send me some sample program for the same.
thanks,
hema sundar.hi, chk this.
Check this code. this might help in solving your problem.
>********************************************************************
This report displays data from SAP tables (like SE16) *
FM : REUSE_ALV_GRID_DISPLAY
DATA:
g_mandt TYPE mandt.
SELECTION-SCREEN :
BEGIN OF LINE, COMMENT 6(33) v_1 FOR FIELD p_table. "#EC NEEDED
PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY MEMORY ID dtb.
SELECTION-SCREEN : END OF LINE, SKIP.
SELECTION-SCREEN :
BEGIN OF LINE, COMMENT 6(30) v_2 FOR FIELD s_mandt. "#EC NEEDED
SELECT-OPTIONS s_mandt FOR g_mandt DEFAULT sy-mandt
MATCHCODE OBJECT ddsef4clnt.
SELECTION-SCREEN : END OF LINE, SKIP.
SELECTION-SCREEN :
SKIP , BEGIN OF LINE, COMMENT 6(33) v_3 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
AT SELECTION-SCREEN.
PERFORM f_check_table.
INITIALIZATION.
v_1 = 'Table'.
v_2 = 'Client'.
v_3 = 'Maximum of records'.
START-OF-SELECTION.
PERFORM f_display_data.
Form F_DISPLAY_DATA
FORM f_display_data.
TYPE-POOLS: slis. " ALV Global Types
DATA:
lp_table TYPE REF TO data, " Pointer to dynamic table
ls_layout TYPE slis_layout_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
FIELD-SYMBOLS :
<lt_data> TYPE STANDARD TABLE. " Data to display
Create internal table
CREATE DATA lp_table TYPE STANDARD TABLE OF (p_table)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN lp_table->* TO <lt_data>.
Field MANDT exists ?
SELECT SINGLE tabname
INTO p_table
FROM dd03l
WHERE tabname = p_table
AND fieldname = 'MANDT'
AND as4local = 'A'
AND as4vers = '0000'
AND position = '0001'
AND rollname = 'MANDT'.
IF sy-subrc EQ 0.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
WHERE mandt IN s_mandt
ORDER BY PRIMARY KEY.
ELSE.
Field CLIENT exists ?
SELECT SINGLE tabname
INTO p_table
FROM dd03l
WHERE tabname = p_table
AND fieldname = 'CLIENT'
AND as4local = 'A'
AND as4vers = '0000'
AND position = '0001'
AND rollname = 'MANDT'.
IF sy-subrc EQ 0.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
WHERE client IN s_mandt
ORDER BY PRIMARY KEY.
ELSE.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
ORDER BY PRIMARY KEY.
ENDIF.
ENDIF.
IF <lt_data>[] IS INITIAL.
No table entries found for specified key
MESSAGE i429(mo).
EXIT.
ENDIF.
Build Field catalog
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
i_client_never_display = ''
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
Display ALV List
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = <lt_data>.
ENDFORM. " F_DISPLAY_DATA
Form F_CHECK_TABLE
FORM f_check_table.
DATA :
l_tabclass TYPE tabclass, " Table category
l_viewclass TYPE viewclass. " View Type
Read table category
SELECT SINGLE tabclass viewclass
INTO (l_tabclass, l_viewclass)
FROM dd02l
WHERE tabname = p_table
AND as4local = 'A'
AND as4vers = '0000'.
IF sy-subrc NE 0.
Table & is not active in the Dictionary
MESSAGE e402(mo) WITH p_table.
ELSEIF l_tabclass = 'INTTAB'.
& is a structure, not a table
MESSAGE e403(mo) WITH p_table.
ELSEIF l_tabclass = 'VIEW' AND l_viewclass NE 'D'.
Only use views of type "Maintenance view"
MESSAGE e309(sv).
ENDIF.
ENDFORM. " F_CHECK_TABLE
with regards,
madhavi.
Maybe you are looking for
-
my icloud stopped working photo streem wont streem and when I go to icloud web page it says error in cloudos when I try to sumitt this to apple it says icloud stopped working I don't know what to do
-
RoboHelp HTML 9.0.2.271 crashes when opening .htm files
Hello. I'm using RoboHelp HTML 9.0.2.271. When opening a certain RH project (I have three that I access regularly), the project opens fine, but when I try to open any of the topic files, RH hangs/crashes. I can perform any other tasks in the project
-
Cannot print -- when I do I get the message 'Printer is busy'. Unable to turn printer on/off with the on/off button. I have had it for only 25 days :-( Unable to change cartridge as the cartridge container does not move to the center but stays in the
-
Hi all, I've just found out these wonderful Inkjet papers, I've copied the ICC profils given on their web site for Epson2200, Mac OS X in HD/library/colorsync/profils and my problem is that none of the profils copied show when I try to use them in Ph
-
How to save a word document to word on ipad
I opened a document from my emails on Microsoft word. I edited the document and now want to save it as the new edited version but how do i do that? If i press the back button i lose everything and i cannot see anything that can help me? Thank you ple