on 04-05-2006 3:12 PM
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = L_LAYOUT
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = IT_FIELDCAT
it_events = it_events
I_SCREEN_START_COLUMN = 10
I_SCREEN_START_LINE = 1
I_SCREEN_END_COLUMN = 80
I_SCREEN_END_LINE = 40
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.
i use this fm
how i can see the rows that i select
where are they?
Normally u can do it by setting parameter i_callback_user_command. after seeing your code i came to know that u have written user_command function. so can you please provide me the code for user_command.
so that i can tell wher u r going wrong.
Regards,
Lisa
Message was edited by: Lisa Roy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To do the further processing with these selected records, you need to code in User Command event.
The interface of the specified form routine must be defined as follows:
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
In this routine you need to code, if user does specfic action like selecting records and click on a button on toolbar then what needs to be executed.
Hi rani,
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.
(Important code has been marked)
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 : BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE t001.
DATA : END OF itab.
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.
WRITE itab-bukrs.
ENDFORM. "ITAB_user_command
regards,
amit m.
Sure I can give you an example..... create screen 100 and add a custom contol to it named ALV_CONTAINER.
REPORT ZRICH_0006.
TABLES: MARA.
TYPE-POOLS: SLIS, ICON.
* Internal Tables
DATA: BEGIN OF IALV OCCURS 0,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF IALV .
* Miscellanous Variables
DATA: INDEX_ROWS TYPE LVC_T_ROW,
INDEX LIKE LINE OF INDEX_ROWS.
DATA: ALV_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
ALV_GRID TYPE REF TO CL_GUI_ALV_GRID,
ROW_TABLE TYPE LVC_T_ROW WITH HEADER LINE,
OK_CODE LIKE SY-UCOMM,
LAYOUT TYPE LVC_S_LAYO,
FIELDCAT TYPE LVC_T_FCAT.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
START-OF-SELECTION.
PERFORM GET_DATA.
IF IALV[] IS INITIAL.
MESSAGE S429(MO).
EXIT.
ENDIF.
CALL SCREEN 100.
************************************************************************
* Module status_0100 OUTPUT
************************************************************************
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '0100'.
SET TITLEBAR '0100'.
DATA: VARIANT TYPE DISVARIANT.
DATA: LT_EXCLUDE TYPE UI_FUNCTIONS.
VARIANT-REPORT = SY-REPID.
VARIANT-USERNAME = SY-UNAME.
* Create Controls
CREATE OBJECT ALV_CONTAINER
EXPORTING CONTAINER_NAME = 'ALV_CONTAINER'.
CREATE OBJECT ALV_GRID
EXPORTING I_PARENT = ALV_CONTAINER.
* Populate Field Catalog
PERFORM GET_FIELDCATALOG.
* Optionally restrict generic functions to 'change only'.
* (The user shall not be able to add new lines).
PERFORM EXCLUDE_TB_FUNCTIONS CHANGING LT_EXCLUDE.
* Set selection mode to "D" -- Multiple Lines
LAYOUT-SEL_MODE = 'D'.
CALL METHOD ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
IS_VARIANT = VARIANT
I_SAVE = 'A'
I_STRUCTURE_NAME = 'IALV'
CHANGING
IT_OUTTAB = IALV[]
IT_FIELDCATALOG = FIELDCAT[].
ENDMODULE.
************************************************************************
* Module USER_COMMAND_0100 INPUT
************************************************************************
MODULE USER_COMMAND_0100 INPUT.
CASE SY-UCOMM.
WHEN 'BACK' OR 'CANC'.
PERFORM FREE_CONTAINERS.
IF SY-SUBRC = 0.
SET SCREEN 0.
LEAVE SCREEN.
ELSE.
LEAVE PROGRAM.
ENDIF.
WHEN 'EXIT'.
PERFORM FREE_CONTAINERS.
LEAVE PROGRAM.
WHEN 'CONTINUE'.
* Retrieve selected rows from ALV grid
PERFORM GET_SELECTED_ROWS.
* Do something with those selected rows here
LOOP AT INDEX_ROWS INTO INDEX.
READ TABLE IALV INDEX INDEX-INDEX.
IF SY-SUBRC = 0.
* Insert code here
ENDIF.
ENDLOOP.
PERFORM FREE_CONTAINERS.
LEAVE TO SCREEN 100.
ENDCASE.
ENDMODULE.
*********************************************************************
* FORM GET_DATA.
*********************************************************************
FORM GET_DATA.
SELECT MARA~MATNR MAKT~MAKTX
INTO CORRESPONDING FIELDS OF TABLE IALV
FROM MARA
INNER JOIN MAKT
ON MARA~MATNR = MAKT~MATNR
WHERE MARA~MATNR IN S_MATNR
AND MAKT~SPRAS = SY-LANGU.
SORT IALV ASCENDING BY MATNR.
ENDFORM.
************************************************************************
* Form GET_SELECTED_ROWS
************************************************************************
FORM GET_SELECTED_ROWS.
* Get Selected rows from alv grid
CLEAR INDEX_ROWS. REFRESH INDEX_ROWS.
CALL METHOD ALV_GRID->GET_SELECTED_ROWS
IMPORTING
ET_INDEX_ROWS = INDEX_ROWS.
ENDFORM.
************************************************************************
* Form FREE_CONTAINERS
************************************************************************
FORM FREE_CONTAINERS.
IF NOT ALV_CONTAINER IS INITIAL.
CALL METHOD ALV_CONTAINER->FREE.
CLEAR: ALV_CONTAINER.
FREE : ALV_CONTAINER.
ENDIF.
ENDFORM.
************************************************************************
* Form Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
FORM GET_FIELDCATALOG.
DATA: LS_FCAT TYPE LVC_S_FCAT.
DATA: COLUMNNO(3) TYPE N VALUE '0'.
REFRESH: FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Number'.
LS_FCAT-COLTEXT = 'Material Number'.
LS_FCAT-FIELDNAME = 'MATNR'.
LS_FCAT-REF_TABLE = 'IALV'.
LS_FCAT-OUTPUTLEN = '18'.
LS_FCAT-COL_POS = 1.
APPEND LS_FCAT TO FIELDCAT.
CLEAR: LS_FCAT.
LS_FCAT-REPTEXT = 'Material Description'.
LS_FCAT-COLTEXT = 'Material Description'.
LS_FCAT-FIELDNAME = 'MAKTX'.
LS_FCAT-REF_TABLE = 'IALV'.
LS_FCAT-OUTPUTLEN = '40'.
LS_FCAT-COL_POS = 2.
APPEND LS_FCAT TO FIELDCAT.
ENDFORM.
***********************************************************************
* Form EXCLUDE_TB_FUNCTIONS
***********************************************************************
FORM EXCLUDE_TB_FUNCTIONS CHANGING PT_EXCLUDE TYPE UI_FUNCTIONS.
* Only allow to change data not to create new entries (exclude
* generic functions).
DATA LS_EXCLUDE TYPE UI_FUNC.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_COPY_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_DELETE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_APPEND_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_INSERT_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
LS_EXCLUDE = CL_GUI_ALV_GRID=>MC_FC_LOC_MOVE_ROW.
APPEND LS_EXCLUDE TO PT_EXCLUDE.
ENDFORM.
Regards,
Rich Heilman
Hi Rani,
if you want to select two rows and then you want to process the same then you can do it with the help of BOX field name or check box.
If you use BOX then you can do it with help of CTRL key of key baorad , then selected records will be marked in internal table ,
loop at itab where SEL = 'X'.
"here you can process the selected ones.
endloop.
the above code should be in user command , and you should create some button and when you click on it, you should handle it .
Regards
vijay
hi rani,
u can find the explanation of the FM
IS_LAYOUT Output list description structure.
IT_FIELDCAT Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
the rows selected by u are in IT_FIELDCAT, this can be populated manually or automatically by using FM
You can generate the field catalog automatically or semi-automatically by calling function module REUSE_ALV_FIELDCATALOG_MERGE OR the field catalog can be built by the user manually.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi rani,
1. SCREENSTART_COLUMN = 10
I_SCREEN_START_LINE = 1
I_SCREEN_END_COLUMN = 80
I_SCREEN_END_LINE = 40
these parameters are
for showing the alv
in popup window.
these parameters specify the
size and position of the popup window.
(they are not for selection of the rows)
regards,
amit m.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what is your exact requirement?
By seeing the code you have placed here, i see that this ALV fm will display contents of internal table ITAB in a screen which will be displayed as a pop up as you have mentioned start column, start line, end column and end line.
Also i guess this is used for interactive reporting as User command routine is present and also events are populated.
Pls let us know ur requirement in detail.
ashish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.