04-18-2008 12:18 AM
I have few questions in ALV 5Grids ,could you please correct me in the following program logic...
Using this program logic i am able to generate the five Grids and able to populate Header details from VBAK into Grid1,If you click in the Grid 1 and it is populating item details in Grid2 from VBAP,parallally populating the customer data in Grid5 from KNA1.
Now the pending issue is ,
if you click in the Grid2 then we should populate the shipping details in Grid3 and
if you click in the Grid3 then we should populate the billing details in Grid4.
Program Logic;
REPORT ZAREPAS20.
Tables : vbak,vbap,likp,lips,vbrk,vbrp,kna1.
DATA : OK_CODE LIKE SY-UCOMM,
G_CONTAINER TYPE SCRFNAME VALUE 'BCALV7_GRID_DEMO_0100_VASU',
DOCKING TYPE REF TO CL_GUI_DOCKING_CONTAINER,
SPLITTER_1 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
SPLITTER_2 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
splitter_3 TYPE REF TO CL_GUI_SPLITTER_CONTAINER,
CELL_TOP1 TYPE REF TO CL_GUI_CONTAINER,
CELL_BOTTOM1 TYPE REF TO CL_GUI_CONTAINER,
CELL_TOP2 TYPE REF TO CL_GUI_CONTAINER,
CELL_BOTTOM2 TYPE REF TO CL_GUI_CONTAINER,
CELL_LEFT TYPE REF TO CL_GUI_CONTAINER,
CELL_middle TYPE REF TO CL_GUI_CONTAINER,
CELL_RIGHT 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,
GRID4 TYPE REF TO CL_GUI_ALV_GRID,
GRID5 TYPE REF TO CL_GUI_ALV_GRID.
DATA : GT_VBAK TYPE STANDARD TABLE OF VBAK,
GT_VBAP TYPE STANDARD TABLE OF VBAP,
GT_LIKP TYPE STANDARD TABLE OF likp,
GT_LIPS TYPE STANDARD TABLE OF lips,
GT_VBRK TYPE STANDARD TABLE OF vbrk,
GT_VBRP TYPE STANDARD TABLE OF vbrp,
GT_KNA1 TYPE STANDARD TABLE OF kna1.
DATA:begin of itab1 occurs 0,
vbeln type likp-VBELN,
erzet type likp-ERZET,
lfart type likp-LFART,
posnr type lips-POSNR,
END OF ITAB1.
DATA:begin of itab2 occurs 0,
vbeln like vbrk-vbeln,
posnr like vbrk-fktyp,
fkart like vbrk-fkart,
fklmg like vbrp-fklmg,
end of itab2.
*selection screen for selecting range of values
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
select-options: S_vbeln for VBAK-vbeln.
selection-screen end of block b1.
----
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 : itab_vbak type VBAK,
itab_vbap type VBAP,
itab_likp type likp,
itab_lips type lips,
itab_vbrk type vbrk,
itab_vbrp type vbrp,
itab_kna1 type kna1.
*DISTINGUISH ACCORDING TO SENDING GRID INSTANCE
CASE SENDER.
WHEN GRID1.
READ TABLE gt_VBAK INTO itab_vbak INDEX e_row-index.
CHECK ( itab_vbak-vbeln IS NOT INITIAL ).
CALL METHOD 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 GRID2.
READ TABLE gt_VBAP INTO itab_vbap INDEX e_row-index.
CHECK ( itab_vbap-vbeln IS NOT INITIAL ).
CALL METHOD GRID2->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 GRID3.
READ TABLE gt_LIPS INTO itab_LIPS INDEX e_row-index.
CHECK ( itab_lips-vgbel IS NOT INITIAL ).
CALL METHOD GRID3->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( 'DELIVERY_DETAILS' ).
WHEN GRID4.
READ TABLE gt_VBRP INTO itab_VBRP INDEX e_row-index.
CHECK ( itab_vbrp-vgbel IS NOT INITIAL ).
CALL METHOD GRID4->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( 'BILLING_DETAILS' ).
WHEN GRID5.
READ TABLE gt_KNA1 INTO itab_KNA1 INDEX e_row-index.
CHECK ( itab_kna1-kunnr IS NOT INITIAL ).
SET PARAMETER ID 'KUN' FIELD itab_KNA1-KUNNR.
CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
WHEN OTHERS.
RETURN.
ENDCASE.
endmethod.
endclass. "lcl_eventhandler IMPLEMENTATION
start-of-selection.
*write 😕 'FEDEX INT''''L' .
SELECT * FROM vbak INTO TABLE gt_VBAK
where vbeln IN S_VBELN.
creating docking container
create object docking
exporting
parent = cl_gui_container=>screen0
ratio = 90
exceptions
others = 6.
if sy-subrc eq 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 splitter_1
EXPORTING
parent = docking
rows = 1
columns = 3
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 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 splitter_1->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_left.
CALL METHOD splitter_1->get_container
EXPORTING
row = 1
column = 2
RECEIVING
container = cell_middle.
CALL METHOD splitter_1->get_container
EXPORTING
row = 1
column = 3
RECEIVING
container = cell_right.
Create 2nd splitter container
CREATE OBJECT splitter_2
EXPORTING
parent = cell_left
rows = 2
columns = 1
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 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 splitter_2->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_top1.
CALL METHOD splitter_2->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = cell_bottom1.
Create 3rd splitter container
CREATE OBJECT splitter_3
EXPORTING
parent = cell_middle
rows = 2
columns = 1
NO_AUTODEF_PROGID_DYNNR =
NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc eq 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 splitter_3->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = cell_top2.
CALL METHOD splitter_3->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = cell_bottom2.
Create ALV grids
CREATE OBJECT grid1
EXPORTING
i_parent = cell_top1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid2
EXPORTING
i_parent = cell_bottom1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid3
EXPORTING
i_parent = cell_top2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid4
EXPORTING
i_parent = cell_bottom2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT grid5
EXPORTING
i_parent = cell_right
EXCEPTIONS
OTHERS = 5.
IF sy-subrc eq 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 grid1.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid2.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid3.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid4.
SET HANDLER: lcl_eventhandler=>handle_double_click FOR grid5.
----
----
Display data
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAK'
CHANGING
it_outtab = gt_VBAK
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 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 grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'VBAP'
CHANGING
it_outtab = gt_VBAP " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_LIPS.
CALL METHOD grid3->set_table_for_first_display
EXPORTING
i_structure_name = 'LIPS'
CHANGING
it_outtab = gt_LIPS " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_VBRP.
CALL METHOD grid4->set_table_for_first_display
EXPORTING
i_structure_name = 'VBRP'
CHANGING
it_outtab = gt_VBRP " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_KNA1.
CALL METHOD grid5->set_table_for_first_display
EXPORTING
i_structure_name = 'KNA1'
CHANGING
it_outtab = gt_KNA1 " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 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 docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc eq 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'.
SET TITLEBAR 'xxx'.
Refresh display of detail ALV list
CALL METHOD grid2->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 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 grid3->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 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 grid4->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 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 grid5->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc eq 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 SY-UCOMM.
WHEN 'BACK' OR
'EXIT' OR
'CANCEL'.
SET SCREEN 0.LEAVE SCREEN.
USER HAS PUSHED BUTTON "DISPLAY OREDERS"
*
WHEN 'ORDER_DETAILS'.
PERFORM ORDER_SHOW_DETAILS.
when 'DELIVERY_DETAILS'.
PERFORM DELIVERY_SHOW_DETAILS.
WHEN 'BILLING_DETAILS'.
PERFORM BILLING_SHOW_DETAILS.
WHEN OTHERS.
ENDCASE.
CLEAR : OK_CODE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form ORDER_SHOW_DETAILS
&----
text
----
--> p1 text
<-- p2 text
----
FORM order_show_details .
define local data
DATA:
ld_row TYPE i,
itab_VBAK TYPE VBAK.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_VBAK INTO itab_VBAK INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM KNA1 INTO TABLE gt_KNA1
WHERE KUNNR = itab_VBAK-KUNNR.
SELECT * FROM VBAP INTO TABLE gt_VBAP
WHERE VBELN = ITAB_VBAK-VBELN.
*REFRESH: gt_LIPS.
ENDFORM. " ORDER_SHOW_DETAILS
&----
*& Form DELIVERY_SHOW_DETAILS
&----
text
----
--> p1 text
<-- p2 text
----
FORM DELIVERY_SHOW_DETAILS .
define local data
DATA:
ld_row TYPE i,
itab_VBAP TYPE VBAP.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_VBAP INTO itab_VBAP INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT LIKPVBELN LIKPERZET LIKPLFART LIPSVBELN
INTO CORRESPONDING FIELDS OF TABLE ITAB1
FROM ( LIKP INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN )
WHERE LIKP~VBELN IN S_VBELN.
*REFRESH: gt_LIPS.
ENDFORM. " DELIVERY_SHOW_DETAILS
&----
*& Form BILLING_SHOW_DETAILS
&----
text
----
--> p1 text
<-- p2 text
----
FORM BILLING_SHOW_DETAILS .
define local data
DATA:
ld_row TYPE i,
itab_LIPS TYPE LIPS.
CALL METHOD grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_LIPS INTO itab_LIPS INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT VBRKVBELN VBRKFKTYP VBRKFKART VBRPFKLMG
INTO CORRESPONDING FIELDS OF TABLE ITAB2
FROM ( VBRK INNER JOIN VBRP ON VBRKVBELN = VBRPVBELN )
WHERE VBRK~VBELN IN S_VBELN.
ENDFORM. " BILLING_SHOW_DETAILS
04-18-2008 8:03 PM
Hi,
anyone can help me out in this issue...
that would be greatly apriciated ...
thanks in advance
srinivas.........
04-18-2008 4:21 AM
Hello Srinivas
In thread you find sample report ZUS_SDN_THREE_ALV_GRIDS which demonstrates your requirement for three "connected" ALV lists. Given this example it should be easy to extend it to 5 ALV lists. The linked tables are: KNA1, VBAK, VBAP.
Regards
Uwe
04-18-2008 7:04 AM
hi thanks for responding....
i had gone thru the same logic and i done 3 GRID ALV but i struk up with 5 alv Grid...
i am able to populateting the values for GRID1,GRID2,GRID3.
unable to populate values in GRID4 (shipping details )and GRID5 (billing details)
could you please help me out in th elogic for 5 ALV GRID...
thanks®ards
srinivas ...
04-18-2008 8:41 AM
i had gone thru which you provided the same 3Grid ALV logic..but i am struck up in 5Grid ALV report using objects and methods.
i am able to populate the values in GRID1(sales order details),if you click in grid1 and related item values are populated in GRID2 from VBAP and customer details in GRID5 from KNA1.I AM unable to populate the values in GRID3(shipping details)WHEN click the GRID2(ITEM DETAILS) AND WHEN CLICKING THE Grid3 unable to populate the billing details in GRID4(billing details)..could anyone please help out one program logic...
thanks in advance
srinivas......
04-18-2008 8:03 PM
Hi,
anyone can help me out in this issue...
that would be greatly apriciated ...
thanks in advance
srinivas.........
04-19-2008 2:10 AM
You should add in each perform you call based on the okcodes, a refresh of the AVL grids, which the data has changed and then a flush to inform the frontend.
The refresh in the gui status is wrong, because everytime it goes through PBO/PAI you call a refresh.
I think this should fix your problem.
04-19-2008 2:28 AM
04-19-2008 11:12 AM
Hi,
ALV means ABAP List Viewer. Most convenient way to use it is through reuse library (cf.
transaction se83) available from release 4.6 of SAP R/3.
ALV is available in two modes: list and grid. List mode is good old list processing with
standard functionnalities, and grid mode is using a new OCX object displaying grids.
Classical reports needs more coding to set the horizontal and vertical lines.we need to adjust
the lines manually.Even interactive also takes lot of code.
ALV reports reduces the code when compared to classical reports.we use function modules to
generate the output.
that r REUSE_ALV_LIST_DISPLAY,REUSE_ALV_GRID_DISPLAY,REUSE_ALV_HIERSEQ_LIST_DISPLAY etc..
the following threads will give some examples of the functions which you are expecting
Reprots
http://www.sapgenie.com/abap/reports.htm
http://www.allsaplinks.com/material.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you
use - ABAP Objects calls or simple function modules.
04-19-2008 6:35 PM
Thanks Sridevi for sharing ALV related stuff with me...:)
Thanks&Regards
srinivas