2006 Dec 05 9:07 AM
hi guru,
What is functionmodules used in alvs?by clicking vendorno directly we get XK01 screen how is it possible by using alv?
hi guru,
What is functionmodules used in alvs?by clicking vendorno directly we get XK01 screen how is it possible by using alv?
2006 Dec 05 9:09 AM
REUSE_ALV_BLOCK_LIST_APPEND
REUSE_ALV_BLOCK_LIST_DATA_GET
REUSE_ALV_BLOCK_LIST_DATA_SET
REUSE_ALV_BLOCK_LIST_DISPLAY
REUSE_ALV_BLOCK_LIST_HS_APPEND
REUSE_ALV_BLOCK_LIST_INIT
REUSE_ALV_BLOCK_LIST_REFRESH
REUSE_ALV_BLOCK_STATUS_GET
REUSE_ALV_CHECKBOX_SET
REUSE_ALV_COMMENTARY_WRITE
REUSE_ALV_FIELDCATALOG_MERGE
REUSE_ALV_HIERSEQ_LIST_DISPLAY
REUSE_ALV_LIST_DISPLAY
REUSE_ALV_POPUP_TO_SELECT
write a doble click event. if the user double click the vendor number call transaction XK01.
write USER_COMMAND in REUSE_ALV_LIST_DISPLAY
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
READ TABLE IVBAP INDEX SELFIELD-TABINDEX.
CHECK SY-SUBRC = 0.
CASE UCOMM.
WHEN '&IC1'.
CASE SELFIELD-SEL_TAB_FIELD.
WHEN 'IVBAP-ENO'.
SET PARAMETER ID 'AUN' FIELD IVBAP-ENO.
CALL TRANSACTION 'SE03' AND SKIP FIRST SCREEN.
WHEN 'IVBAP-NAME'.
SET PARAMETER ID 'MAT' FIELD IVBAP-NAME.
CALL TRANSACTION 'SE07' AND SKIP FIRST SCREEN.
ENDCASE.
ENDCASE.
ENDFORM.
null
2006 Dec 05 9:10 AM
USE LIKE THAT....
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
case R_UCOMM
when '&IC1'.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen.
endcase.
ENDFORM. "USER_COMMANDkishan negi
2006 Dec 05 9:14 AM
The commonly used ALV functions used are:
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
Out of these most commonly used are REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY.
REUSE_ALV_LIST_DISPLAY: This is the function module which prints the data.
The important parameters are:
1. Export:
a. I_callback_program : report id
b. I_callback_pf_status_set : routine where a user can set his own pf status
or change the functionality of the existing pf status.
c. I_callback_user_command : routine where the function codes are
handled.
d. I_structure name : name of the dictionary table
e. Is_Layout : structure to set the layout of the report
f. It_fieldcat : internal table with the list of all fields and their
attributes which are to be printed (this table can
be populated automatically by the function
module REUSE_ALV_FIELDCATALOG_MERGE)
g. It_events : internal table with a list of all possible events of ALV and their corresponding routine names.
2. Tables:
a. t_outtab : internal table with the data to be output
REUSE_ALV_GRID_DISPLAY: A new function in 4.6 version, to display the results in grid rather than as a list.
Parameters : same as reuse_alv_list_display
REUSE_ALV_FIELDCATALOG_MERGE:
This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure_name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.
REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
Have a look at ABAP List Viewer in below link:
<a href="http://www.sap-basis-abap.com/sapabap01.htm">ALV</a>
I hope it helps.
Best Regards,
Vibha
*Please mark all the helpful answers
2006 Dec 05 11:34 AM
Raju,
you need to take the help of USER_COMMAND event.
with that it is simple to show the interactive report.
**-ALV list Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
<b> I_CALLBACK_PF_STATUS_SET = 'PF_STATUS_SET'</b>
<b> I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENTS
TABLES
T_OUTTAB = IT_FINAL
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.you need to pass these two forms
FORM PF_STATUS_SET USING P_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING P_EXTAB.
ENDFORM. "PF_STATUS_SET
FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM SELFIELD TYPE
SLIS_SELFIELD.
case UCOMM.
when '&IC1'. "this is for double click.
"do some thing..
ENDCASE.
ENDFORM. "USER_COMMANDCheck the sample code also..
REPORT ZTEST_ALV_CHECK message-id zz .
TYPE-POOLS: SLIS.
DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
L_LAYOUT type slis_layout_alv.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
SELECT VBELN
POSNR
FROM VBAP
UP TO 20 ROWS
INTO TABLE ITAB.
X_FIELDCAT-FIELDNAME = 'VBELN'.
X_FIELDCAT-SELTEXT_L = 'VBELN'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 2.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-FIELDNAME = 'POSNR'.
X_FIELDCAT-SELTEXT_L = 'POSNR'.
X_FIELDCAT-TABNAME = 'ITAB'.
X_FIELDCAT-COL_POS = 3.
APPEND X_FIELDCAT TO IT_FIELDCAT.
CLEAR X_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
<b> I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'</b>
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = ITAB
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 STATUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXTAB text
*----------------------------------------------------------------------*
FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.
*- Pf status
<b> SET PF-STATUS 'STATUS'.</b>
ENDFORM. " STATUS
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
<b>FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
case r_ucomm.
when 'BACK' or 'CANC' or 'EXIT'.
leave to screen 0.
when '&IC1'.
if rs_selfield-fieldname = 'VBELN'.
* message i000 with 'clicked on row' rs_Selfield-tabindex.
set parameter id 'AUN' field rs_selfield-value.
call transaction 'VA03' and skip first screen.
endif.
endcase.
ENDFORM. "USER_COMMAND</b>you need set the PF-status and the User-command. and enable F2 key that is for double clicking, set the Function code '&IC1' for f2 key.
then it will work.
Regards
Vijay
2006 Dec 05 11:35 AM
Hi surendra,
1. In alv we cannot use AT LINE Selection
2. For alv, there is a special syntax, so that when we double-click on alv,
our FORM / routine is called and there we display another alv,
OR use CALL TRANSACTION to show another tcode.
3. just copy paste to get a taste of interactive alv.
4.
REPORT abc.
TYPE-POOLS : slis.
*----
Data
DATA : ITAB LIKE T001 OCCURS 0 WITH HEADER LINE.
DATA : alvfc TYPE slis_t_fieldcat_alv.
DATA : STAB LIKE T001 OCCURS 0 WITH HEADER LINE.
*----
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_GRID_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.
*----
IMPORTANT.
READ TABLE ITAB INDEX WHATROW-TABINDEX.
*
CLEAR STAB.
SELECT * FROM T001
INTO TABLE STAB
WHERE BUKRS = ITAB-BUKRS.
CLEAR ALVFC.
*------- Field Catalogue
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'STAB'
i_inclname = sy-repid
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*----
Display
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = alvfc
i_callback_program = sy-repid "<-------Important
TABLES
t_outtab = Stab
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "ITAB_user_command
regards,
amit m.
2006 Dec 05 11:37 AM
hi,
simply chk this link.
code is there.
http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_ucomm.htm
rgds
anver
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |