‎2006 Jul 14 9:52 AM
hai any one please tell the logic for the alv interactive report.
i have created two internal tables and one for first list and another for secondary list so when i click on to the first list(alv) then go to secondary list(alv) give logic here ..
i checked some logics from internet they give some sy-ucomm in perform statment...and they can assign some trasaction why they r giving to the ABAP programing i don't know please give only that code which is entering in to scondary list... and detailes description also....
‎2006 Jul 14 9:55 AM
Hello,
Use this code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = G_T_OUTTAB
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.
----
FORM user_command *
----
........ *
----
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
DATA: REPORT LIKE SY-REPID,
CODE LIKE SY-UCOMM.
REPORT = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
<b> T_OUTTAB = G_T_OUTTAB2</b>
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.
If usefule reward points.
‎2006 Jul 14 9:55 AM
Hello,
Use this code.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = G_T_OUTTAB
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.
----
FORM user_command *
----
........ *
----
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
DATA: REPORT LIKE SY-REPID,
CODE LIKE SY-UCOMM.
REPORT = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
I_SAVE = 'A'
IS_VARIANT = IT_VARIANT
IT_SORT = IT_SORT
IT_EVENTS = IT_EVENTS
TABLES
<b> T_OUTTAB = G_T_OUTTAB2</b>
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.
If usefule reward points.
‎2006 Jul 14 9:57 AM
in case of ALV u have to use User_commands and Events.
check r_ucomm = '&IC1'. "User Double Clicked on Some field
check not rs_selfield-value is initial.
sort itab by werks.
case rs_selfield-fieldname.
when 'AURNR'.
read table final index rs_selfield-tabindex.
perform display_alv1 using ptab.
endcase.
Regards
Prabhu
‎2006 Jul 14 9:59 AM
Hi suganya,
1. There are some parameters
in the FM which are passed,
and a new FORM has to be written.
2. Just copy paste this code in new program.
3. It will display list of company.
On double-clicking on the alv,
it will again display the clicked company code.
Important code has been marked.
4.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : ITAB LIKE T001 OCCURS 0 WITH HEADER LINE.
DATA : PTAB LIKE T001 OCCURS 0 WITH HEADER LINE.
DATA : alvfc TYPE slis_t_fieldcat_alv.
*----
Select Data
SELECT * FROM t001 INTO TABLE itab.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'ITAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
i_callback_user_command = 'ITAB_USER_COMMAND' "<------ Important
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
*----
CALL BACK FORM
*----
FORM itab_user_command USING whatcomm TYPE sy-ucomm whatrow TYPE
slis_selfield.
READ TABLE itab INDEX whatrow-tabindex.
SELECT * FROM t001 INTO TABLE Ptab
WHERE BUKRS = ITAB-BUKRS.
CLEAR ALVFC.
REFRESH ALVFC.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'PTAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
it_fieldcat = alvfc
TABLES
t_outtab = Ptab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "ITAB_user_command
regards,
amit m.
‎2006 Jul 14 11:28 AM
There are two ways to handle this in ALV's using objects
<b>1 Handle double click</b>
a) Set the grid to handle double click event.
b) This will give the selected record no. Read the table with first internal table with this index.
c) Based on this perpare 2 internal table and finally display
<b>2 Handle user_command</b>
a) Set the grid to handle user command event.
b) Use method get_selected_rows, to get the selected records and then read the 1st internal table
c) Based on this perpare 2 internal table and finally display
‎2006 Jul 14 2:49 PM