12-22-2011 4:48 AM
Hi Abapers,
I have two internal tables itab1 and itab2. where itab1 contains old data and itab2 contains new changed data in alv editable grid.
now i have to insert itab2 data in ztable and display itab1 and itab2 data in alv grid output when data is changed and clicked SAVE.
I am not able to display and insert.
Thanks & regards.
12-22-2011 4:56 AM
HI
Report zalv_two_tabs .
data: imara type table of mara.
data: xmara like line of imara.
data: imarc type table of marc.
data: dockingbottom type ref to cl_gui_docking_container,
dockingtop type ref to cl_gui_docking_container,
alv_bottom type ref to cl_gui_alv_grid,
alv_top type ref to cl_gui_alv_grid,
repid type syrepid.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_event_handler definition.
public section.
class-methods handle_double_click
for event double_click of cl_gui_alv_grid
importing e_row e_column.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_event_handler IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_event_handler implementation.
method handle_double_click.
read table imara into xmara index e_row-index.
select * into table imarc from marc
where matnr = xmara-matnr.
call method alv_bottom->refresh_table_display( ).
endmethod.
endclass.
parameters: p_check type c.
start-of-selection.
at selection-screen output.
repid = sy-repid.
select * into corresponding fields of table imara
from mara up to 100 rows.
check dockingbottom is initial.
create object dockingtop
exporting repid = repid
dynnr = sy-dynnr
side = dockingtop->dock_at_top
extension = 200.
create object alv_top
exporting i_parent = dockingtop.
call method alv_top->set_table_for_first_display
exporting
i_structure_name = 'MARA'
changing
it_outtab = imara[].
* handler for ALV grid
set handler lcl_event_handler=>handle_double_click for alv_top.
create object dockingbottom
exporting repid = repid
dynnr = sy-dynnr
side = dockingbottom->dock_at_bottom
extension = 200.
create object alv_bottom
exporting i_parent = dockingbottom.
call method alv_bottom->set_table_for_first_display
exporting
i_structure_name = 'MARC'
changing
it_outtab = imarc[].
Cheers NZAB
12-22-2011 5:12 AM
Hi,
Thanku for ur reply,
am using reuse_alv_grid_display.
Thanks & regards.
12-22-2011 5:42 AM
Hi here i am posting sample code it may be helpful to you..
FM is REUSE_ALV_HIERSEQ_LIST_DISPLAY: HIERARCHICAL ALV REPORT : IS USED TO DISPLAY ONLY TWO
INTERNAL TABLES DATA ONTO ALV GRID.i.e HEADER(EKKO) AND ITEM DATA(EKPO).
* HIERARCHICAL ALV REPORT : IS USED TO DISPLAY ONLY TWO INTERNAL TABLES DATA ONTO ALV GRID
*.i.e HEADER(EKKO) AND ITEM DATA(EKPO).
REPORT YALV_HIERARCHICAL_REPORT.
TABLES EKKO,EKPO.
TYPE-POOLS SLIS.
DATA IT_EKKO TYPE TABLE OF EKKO.
DATA IT_EKPO TYPE TABLE OF EKPO.
DATA V_PROGRAM LIKE SY-REPID VALUE SY-REPID.
*TO CREATE WORK AREA WA_KEY TO STORE KEY FIELDS
DATA WA_KEY TYPE SLIS_KEYINFO_ALV.
SELECT-OPTIONS S_EBELN FOR EKKO-EBELN.
START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM GET_DATA1.
PERFORM DIPLAY_HIERARCHICAL_ALV_REPORT.
FORM GET_DATA .
SELECT * FROM EKKO INTO TABLE IT_EKKO WHERE EBELN IN S_EBELN.
ENDFORM. " GET_DATA
FORM GET_DATA1 .
*TO GET DATA FROM DBTABLE EKPO INTO INTERNAL TABLE IT_EKPO
IF IT_EKKO IS NOT INITIAL.
SELECT EBELN EBELP MATNR BUKRS WERKS MATKL
FROM EKPO INTO TABLE IT_EKPO FOR ALL ENTRIES IN IT_EKKO WHERE EBELN = IT_EKKO-EBELN.
ENDIF.
ENDFORM. " GET_DATA1
FORM DIPLAY_HIERARCHICAL_ALV_REPORT .
*TO FILL KEY FIELDS.
WA_KEY-HEADER01 = 'EBELN'.
WA_KEY-ITEM01 = 'EBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_PROGRAM
I_TABNAME_HEADER = 'IT_EKKO'
I_TABNAME_ITEM = 'IT_EKPO'
I_STRUCTURE_NAME_HEADER = 'EKKO'
I_STRUCTURE_NAME_ITEM = 'ZSTRUCT_EKPO'
IS_KEYINFO = WA_KEY
TABLES
T_OUTTAB_HEADER = IT_EKKO
T_OUTTAB_ITEM = IT_EKPO
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. " DIPLAY_HIERARCHICAL_ALV_REPORT
If you want to display mulltiple tables data in ALV Grid then you can go with BLOCKED ALV Report Concept..
Thanks&Regards
Sreenivas Pachva
Edited by: sreenivas.p on Dec 22, 2011 6:44 AM
12-22-2011 7:21 AM