Push Button on Alv Grid display
Hi experts,
I strcuk in the middle of one program, i need to have push buttons on the output ALV Grid display, i have copied the standard status and used the same in the Function module for pf-status, iam able to get the output
but my requirement is how to add the push buttons to the out put screen, as when iam clicking on status which i have copied iam unable to find where to add these push button in the application tool bar, iam unable to edit the push button can any body help me out, thanks in advance.
Hello Madan
I cannot help you with the FM-based ALV lists. However, for OO-based ALV grids (CL_GUI_ALV_GRID) I have a sample program that simulates radio buttons by using icons with hotspots.
PROGRAM ZUS_SDN_BCALV_GRID_DEMO_2.
* Based on: BCALV_GRID_DEMO.
TYPE-POOLS: icon.
TYPES: BEGIN OF ty_s_sflight.
INCLUDE TYPE sflight.
TYPES: button1 TYPE lvc_emphsz.
TYPES: button2 TYPE lvc_emphsz.
TYPES: button3 TYPE lvc_emphsz.
TYPES: button4 TYPE lvc_emphsz.
TYPES: END OF ty_s_sflight.
DATA:
gt_sflight TYPE STANDARD TABLE OF ty_s_sflight,
gt_fcat TYPE lvc_t_fcat.
DATA: ok_code LIKE sy-ucomm,
* gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_cnt TYPE i.
CLASS-METHODS:
handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING
e_row_id
e_column_id
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_hotspot_click.
* define local data
FIELD-SYMBOLS:
<ls_entry> TYPE ty_s_sflight,
<ld_fld> TYPE ANY.
READ TABLE gt_sflight ASSIGNING <ls_entry> INDEX es_row_no-row_id.
CHECK ( <ls_entry> IS ASSIGNED ).
* Set all radio buttons "unselected"
<ls_entry>-button1 = icon_wd_radio_button_empty.
<ls_entry>-button2 = icon_wd_radio_button_empty.
<ls_entry>-button3 = icon_wd_radio_button_empty.
<ls_entry>-button4 = icon_wd_radio_button_empty.
ASSIGN COMPONENT e_column_id-fieldname OF STRUCTURE <ls_entry>
TO <ld_fld>.
IF ( <ld_fld> IS ASSIGNED ).
* Set selected radio button "selected".
<ld_fld> = icon_wd_radio_button.
ENDIF.
* Force PAI followed by refresh of table display in PBO
CALL METHOD cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code = 'DUMMY'
* IMPORTING
* RC =
ENDMETHOD. "handle_hotspot_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
* MAIN *
PERFORM select_data.
CALL SCREEN 100.
* MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
PERFORM build_fieldcatalog.
CALL METHOD grid1->set_table_for_first_display
* EXPORTING
* i_structure_name = 'SFLIGHT'
CHANGING
it_fieldcatalog = gt_fcat
it_outtab = gt_sflight.
* Set event handler for event TOOLBAR
SET HANDLER:
lcl_eventhandler=>handle_hotspot_click FOR grid1.
else.
CALL METHOD grid1->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
FINISHED = 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.
ENDIF.
ENDMODULE. "PBO OUTPUT
* MODULE PAI INPUT *
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN OTHERS.
* do nothing
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
* FORM EXIT_PROGRAM *
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*& Form BUILD_FIELDCATALOG
* text
* --> p1 text
* <-- p2 text
FORM build_fieldcatalog .
* define local data
DATA:
ls_fcat TYPE lvc_s_fcat,
ls_hype TYPE lvc_s_hype.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'LVC_S_FCAT'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DELETE gt_fcat WHERE ( fieldname <> 'EMPHASIZE' ).
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* I_BUFFER_ACTIVE =
i_structure_name = 'SFLIGHT'
* I_CLIENT_NEVER_DISPLAY = 'X'
* I_BYPASSING_BUFFER =
* I_INTERNAL_TABNAME =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
READ TABLE gt_fcat INTO ls_fcat
WITH KEY fieldname = 'EMPHASIZE'.
IF ( syst-subrc = 0 ).
DELETE gt_fcat INDEX syst-tabix.
ENDIF.
ls_fcat-fieldname = 'BUTTON4'.
ls_fcat-icon = 'X'.
ls_fcat-hotspot = 'X'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON3'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON2'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
ls_fcat-fieldname = 'BUTTON1'.
INSERT ls_fcat INTO gt_fcat INDEX 4.
LOOP AT gt_fcat INTO ls_fcat.
ls_fcat-col_pos = syst-tabix.
MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
ENDLOOP.
ENDFORM. " BUILD_FIELDCATALOG
*& Form SELECT_DATA
* text
* --> p1 text
* <-- p2 text
FORM select_data .
* define local data
DATA:
ls_sflight TYPE ty_s_sflight.
SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE gt_sflight.
ls_sflight-button1 = icon_wd_radio_button.
ls_sflight-button2 = icon_wd_radio_button_empty.
ls_sflight-button3 = icon_wd_radio_button_empty.
ls_sflight-button4 = icon_wd_radio_button_empty.
MODIFY gt_sflight FROM ls_sflight
TRANSPORTING button1 button2 button3 button4
WHERE ( carrid IS NOT INITIAL ).
ENDFORM. " SELECT_DATA
Regards
Uwe
Similar Messages
-
Push button in ALV Grid Display
Hi all,
I have a requirement wherin i need to place a button in the ALV Grid Display which should update all the records whatever are displayed in the specified infotype. This is to be done in a report.
Can anybody give me any pointers or sample code for the above query.
Regards,
AmritaSimply add a button on your GUI status. Then when pushed, code your logic for update IT0008.
AT USER-COMMAND event block will be triggered when you press your button.
AT USER-COMMAND.
if sy-ucomm = 'PUSHBUTTON'. "here comes function code of your pushbutton
"update your diplayed records
endif. -
How to show traffic lights on push button in ALV Grid?
Hi Experts,
I have an requirement where I have to show traffic lights on push button in ALV grid of a container. I am showing access sequence for each condition type in my grid. Now, if the access sequence contains 'PLANT', it should show 'green' on push button or else it should show 'red'. How I can I achieve this?
Thanks in advance.Try This One.
DATA: gs_fieldcat TYPE slis_fieldcat_alv,
gt_fieldcat TYPE slis_t_fieldcat_alv,
gs_layout TYPE slis_layout_alv.
TYPES :BEGIN OF gty_temp,
col(10) TYPE c,
END OF gty_temp.
DATA : gt_temp TYPE STANDARD TABLE OF gty_temp,
gs_temp TYPE gty_temp.
gs_temp-col ='@0A@'. "ERROR RED LIGHT
APPEND gs_temp TO gt_temp.
CLEAR GS_TEMP.
gs_temp-col = '@08@'." SUCCESS GREEN LIGHT
APPEND gs_temp TO gt_temp.
CLAER GS_TEMP.
gs_temp-col = '@09@'. WARNING YELLOW LIGHT
APPEND gs_temp TO gt_temp.
CLAER GS_TEMP.
gs_fieldcat-fieldname = ' COL'.
gs_fieldcat-tabname = 'GT_TEMP'.
gs_fieldcat-seltext_m = 'ERROR'."
APPEND gs_fieldcat TO gt_fieldcat.
CLEAR gs_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZPROG1' " PROGRAM NAME
i_grid_title = 'Details'
* is_layout = gs_layout
it_fieldcat = gt_fieldcat
TABLES
t_outtab = gt_temp.
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF. -
How can we create a push-button in ALV-GRID.
How will u handle a push-button in ALV.Hello,
To add a push button and handle it,you have to define a local class and use the methods <b>handle_toolbar</b> and <b>handle_user_command</b>.Here is a sample code:
CLASS lcl_eh DEFINITION
CLASS lcl_eh DEFINITION.
PUBLIC SECTION.
DATA:
<b>ls_toolbar TYPE stb_button</b>.
METHODS:
<b>handle_toolbar</b>
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
<b>handle_user_command</b>
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_eh DEFINITION
*Type referencing an object of the class
<b>DATA: lo_obj TYPE REF TO lcl_eh.</b>
CLASS lcl_eh IMPLEMENTATION
CLASS lcl_eh IMPLEMENTATION.
*METHOD: HANDLE_TOOLBAR
*DESCRIPTION: This method provides the necessary detail required to
create an extra button in the toolbar.
METHOD <b>handle_toolbar.</b>
CLEAR ls_toolbar.
MOVE 'CREATE' TO ls_toolbar-function.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'CREATE' TO ls_toolbar-text.
MOVE 'ICON_DETAIL' TO ls_toolbar-icon.
MOVE 'CREATE' TO ls_toolbar-quickinfo.
<b>APPEND ls_toolbar TO e_object->mt_toolbar.</b>
ENDMETHOD. "handle_toolbar
*METHOD: HANDLE_USER_COMMAND
*DESCRIPTION: This method is used to handle the push button
<b>METHOD handle_user_command.</b>
<b> CASE e_ucomm.</b>
<b> WHEN 'CREATE'.</b>
**logic
ENDCASE.
ENDMETHOD.
ENDCLASS.
Regards,
Beejal
**reward if this helps -
How to add a push button in ALV Grid Top-of-page
Is it possible to add a push button to the top-of-page in Alv grid display?if yes, then how? I am not using OO ABAP and am using reuse_alv_grid_display with top-of-page event.
Hi,
I am not sure whether we can add push button in top-of -page or not. But instead of that if you want to add button on toolbar as per your requirement then follow below link. it will useful.
http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
Ram. -
TO enable the menu button in ALV Grid Display
Hi Mates,
I have a peculiar problem while doing ALV Grid display for screens.
In the main Screen i have Three coloumns.The 1st coloum will interacted
next screen 101 and 2nd coloum will interacted to screen 102.
Now the problem is in the menu of ALV Grid display,the Total button was enabled for screen
101 and same button is disabled in screen 102.
But the code semms to be fine .
Below i have pasted the code and please have a look and help to come out of this cris.
My Code :
FORM CREATE_ALV_GRID USING R_SCREEN.
DATA: LS_LAYOUT TYPE LVC_S_LAYO,
ITAB_FUNCTIONS TYPE UI_FUNCTIONS. "MHTK903257(+)(add)
CASE R_SCREEN.
*--> SCREEN 9000
WHEN C_SCREEN_9000.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' 'WADAT' 'Due date'(004) 'X' 'D' ' ' ' ' ' ' 'C100',
*'ITAB_OVERVIEW' 'HU_UNLOAD' 'Unloaded HU'(005) 'X' 'I' '15' ' ' ' ' 'C500', "MHTK903257(-)
'ITAB_OVERVIEW' 'TOT_TO' 'Total TO'(006) 'X' 'I' ' ' ' ' ' ' 'C30',
GMTK901103: REMOVE HOTSPOT ON ESTIMATED TO:
'ITAB_OVERVIEW' 'EST_TO' 'Estim TO'(030) ' ' 'I' ' ' ' ' ' ' 'C500'.
LOOP AT ITAB_INB_LOC WHERE OUTPUT = 'X'.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' ITAB_INB_LOC-FIELDNAME
ITAB_INB_LOC-Z_INBND_LOC 'X' '' ' ' ' ' 'R' 'C500'. "MHTK903418
ENDLOOP.
LOOP AT ITAB_STORAGE_TYPE WHERE OUTPUT = 'X'.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_9000
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_OVERVIEW' ITAB_STORAGE_TYPE-FIELDNAME
ITAB_STORAGE_TYPE-LGTYP 'X' 'I' ' ' ' ' 'R' 'C500'.
ENDLOOP.
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1000
EXPORTING
I_PARENT = PT_DOCK_1000.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS "MHTK903257(+)(add)
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1000
CHANGING LS_LAYOUT-GRID_TITLE.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1000->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_OVERVIEW
IT_FIELDCATALOG = ITAB_FIELDCAT_9000.
*--> SCREEN 9100
WHEN C_SCREEN_1100.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETIAL' 'WAUHR' 'Due time'(007) ' ' 'T' ' ' 'X' ' ' 'C100',
'ITAB_DETAIL' 'TOT_TO' 'Total TO'(006) 'X' 'I' ' ' ' ' ' ' 'C30',
'ITAB_DETAIL' 'EST_TO' 'Estim TO'(030) ' ' 'I' ' ' ' ' ' ' 'C500'.
CLEAR ITAB_INB_LOC.
LOOP AT ITAB_INB_LOC WHERE SELECTED = 'X'.
CHECK SY-SUBRC EQ 0.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETAIL' ITAB_INB_LOC-FIELDNAME
ITAB_INB_LOC-Z_INBND_LOC '' '' ' ' ' ' 'R' 'C500'.
ENDLOOP.
CLEAR: ITAB_STORAGE_TYPE.
LOOP AT ITAB_STORAGE_TYPE WHERE SELECTED = 'X'.
CHECK SY-SUBRC EQ 0.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1100
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_DETAIL' ITAB_STORAGE_TYPE-FIELDNAME
ITAB_STORAGE_TYPE-LGTYP 'X' 'I' ' ' ' ' 'R' 'C500'.
ENDLOOP.
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1100
EXPORTING
I_PARENT = PT_DOCK_1100.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS "MHTK903257(+)(add)
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1100
CHANGING LS_LAYOUT-GRID_TITLE.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1100->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_DETAIL
IT_FIELDCATALOG = ITAB_FIELDCAT_1100.
screen 1300 TO detail.
*--> SCREEN 9300
WHEN C_SCREEN_1300.
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1300
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_TO2' 'TANUM' 'TO'(020) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_TO2' 'NLPLA' 'Location'(021) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'LETY1' 'SUT'(013) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'MATNR' 'Material'(016) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'NSOLM' 'Quantity'(017) ' ' 'I' ' ' ' ' ' ' 'C500',
'ITAB_TO2' 'NLTYP' 'Storage type'(014) ' ' '' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*'ITAB_TO2' 'POSNR' 'Line'(015) ' ' 'C' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1300
EXPORTING
I_PARENT = PT_DOCK_1300.
*-- Exclude the non-applicable functions from the ALV grid.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1300
CHANGING LS_LAYOUT-GRID_TITLE.
SORT ITAB_TO2 BY TANUM VBELN POSNR.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1300->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_TO2
IT_FIELDCATALOG = ITAB_FIELDCAT_1300.
screen 9400 Pre Processing detail.
*--> SCREEN 9400
WHEN C_SCREEN_9400. "MHTK903418(BEgin Of change)
*-- Build the field catalog for the ALV grid.
PERFORM BUILD_FIELD_CATALOG TABLES ITAB_FIELDCAT_1400
USING:
*ref_table|fieldname|coltext|hotspot|inttype|outputlen|lzero|just|color
'ITAB_PRE_PROC2' 'Z_PRE_PROC' 'Pre Processing Number'(030) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_PRE_PROC2' 'Z_PRE_PROC_LN' 'Pre Processing Number'(035) ' ' 'C' ' ' ' ' ' ' 'C100',
'ITAB_PRE_PROC2' 'MATNR' 'Material'(035) ' ' 'C' ' ' ' ' ' ' 'C500',
'ITAB_PRE_PROC2' 'Z_PSH_QTY' 'Quantity'(035) ' ' 'C' ' ' ' ' ' ' 'C500'.
*'ITAB_TO2' 'MATNR' 'Material'(016) ' ' 'C' ' ' ' ' ' ' 'C500',
*'ITAB_TO2' 'NSOLM' 'Quantity'(017) ' ' 'I' ' ' ' ' ' ' 'C500',
*'ITAB_TO2' 'NLTYP' 'Storage type'(014) ' ' '' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
**'ITAB_TO2' 'POSNR' 'Line'(015) ' ' 'C' ' ' ' ' ' ' 'C500'. "MHTK903257(-)
*-- Create the ALV grid object.
CREATE OBJECT PT_ALV_1400
EXPORTING
I_PARENT = PT_DOCK_1400.
*-- Exclude the non-applicable functions from the ALV grid.
PERFORM EXCLUDE_FUNCTIONS TABLES ITAB_FUNCTIONS
USING R_SCREEN.
*-- Get the title of the ALV grid.
PERFORM GET_ALV_GRID_TITLE USING C_SCREEN_1400
CHANGING LS_LAYOUT-GRID_TITLE.
SORT ITAB_PRE_PROC2 BY Z_PRE_PROC.
*-- Display the ALV grid.
CALL METHOD PT_ALV_1400->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LS_LAYOUT
IT_TOOLBAR_EXCLUDING = ITAB_FUNCTIONS
CHANGING
IT_OUTTAB = ITAB_PRE_PROC2
IT_FIELDCATALOG = ITAB_FIELDCAT_1400. "MHTK903418(End of change)
ENDCASE.Hi
U copy from standard program and paste ur report ...It will work..'
Regards:
Prabu -
Remove buttons in ALV grid display in ABAP Web Dynpro
Hi,
Sub: ALV grid-->Web Dynpro ABAP.
Request guidance to prevent display of the buttons "Microsoft Excel" and "Print Version" (which provide options to export the ALV grid output into an Excel format document).
Is there a way we could hide this from being displayed on the ALV grid in a Web dynpro ABAP component output?
Thanks very much.
Best Regards,
AdiHi Adithya,
really simple solution is to call cl_salv_wd_model_table_util=>if_salv_wd_table_util_stdfuncs=>set_all( abap_false ). This deactivates all ALV functionality.
For individual setting cl_salv_wd_config_table if_salv_wd_standard_functions~set_<x>_allowed.
- Michelle -
Not diaplsy buttons on alv grid display
Hi,
In the below code,i dont understand where i made a mistake,i used a user command on alv it's working but not display the buttons on a output.Please check the below code and solve it.
REPORT Y_ALV_VERSION.
TYPE-POOLS : SLIS.
DATA : BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARC-MATNR, "Plant Data for Material-Material Number
WERKS LIKE MARC-WERKS, "Plant Data for Material-Plant
EKGRP LIKE MARC-EKGRP, "Plant Data for Material-Purchasing Group
END OF ITAB.
DATA : BEGIN OF ITAB1 OCCURS 0,
MATNR LIKE MARD-MATNR, "Storage Location Data for Material-Material Number
WERKS LIKE MARD-WERKS, "Storage Location Data for Material-Plant
LGORT LIKE MARD-LGORT, "Storage Location Data for Material-Storage Location
END OF ITAB1.
DATA : REPID LIKE SY-REPID.
DATA : V_LINE TYPE SY-TABIX.
DATA : X_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA : I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA : I_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV.
DATA : X_ALV_EVENTS TYPE SLIS_ALV_EVENT.
DATA : T_ALV_EVENTS TYPE SLIS_T_EVENT.
DATA : X_ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
*********************START-OF-SELECTION***************
START-OF-SELECTION.
PERFORM SUB_SELECT_RECORD.
PERFORM SUB_PREPARE_FIELDCATALOG.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = T_ALV_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 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.
READ TABLE T_ALV_EVENTS INTO X_ALV_EVENTS WITH KEY NAME = 'USERCOMMAND'.
IF SY-SUBRC = 0.
X_ALV_EVENTS-FORM = 'USER_ACTION'.
MODIFY T_ALV_EVENTS FROM X_ALV_EVENTS INDEX SY-TABIX.
ENDIF.
READ TABLE T_ALV_EVENTS INTO X_ALV_EVENTS WITH KEY NAME = 'PF_STATUS_SET'.
IF SY-SUBRC = 0.
X_ALV_EVENTS-FORM = 'PF_STATUS'.
MODIFY T_ALV_EVENTS FROM X_ALV_EVENTS INDEX SY-TABIX.
ENDIF.
PERFORM SUB_DETERMINE_ALV_LAYOUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = X_ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS = T_ALV_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
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 PF_STATUS
text
-->RT_EXTAB text
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'ALV_PF_STATUS'. " excluding rt_extab.
ENDFORM. "PF_STATUS
*& Form user_action
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM USER_ACTION USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
DATA : OKCODE TYPE SY-UCOMM.
OKCODE = R_UCOMM.
CLEAR R_UCOMM.
V_LINE = RS_SELFIELD-TABINDEX.
CASE OKCODE.
WHEN 'PICK'.
READ TABLE ITAB INDEX V_LINE.
PERFORM SUB_SELECT_RECORD1.
PERFORM SUB_PREPARE_FIELDCATALOG1.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = 'REPID'
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS-SET'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB1
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.
WHEN 'EXIT'.
RS_SELFIELD-EXIT = 'X'.
ENDCASE.
ENDFORM. "user_action
*& Form SUB_PREPARE_FIELDCATALOG
text
--> p1 text
<-- p2 text
FORM SUB_PREPARE_FIELDCATALOG .
X_FIELDCAT-SELTEXT_L = 'MATERIAL'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 18.
X_FIELDCAT-FIELDNAME = 'MATNR'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO I_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-SELTEXT_L = 'PLANT'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 4.
X_FIELDCAT-FIELDNAME = 'WERKS'.
APPEND X_FIELDCAT TO I_FIELDCAT.
CLEAR X_FIELDCAT.
X_FIELDCAT-SELTEXT_L = 'PUR.GROUP'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 4.
X_FIELDCAT-FIELDNAME = 'EKGRP'.
X_FIELDCAT-EDIT = 'X'.
APPEND X_FIELDCAT TO I_FIELDCAT.
CLEAR X_FIELDCAT.
ENDFORM. " SUB_PREPARE_FIELDCATALOG
*& Form SUB_SELECT_RECORD
text
--> p1 text
<-- p2 text
FORM SUB_SELECT_RECORD.
SELECT MATNR WERKS EKGRP FROM MARC INTO TABLE ITAB UP TO 10 ROWS WHERE WERKS = '1000'.
ENDFORM. " SUB_SELECT_RECORD
*& Form SUB_DETERMINE_ALV_LAYOUT
text
--> p1 text
<-- p2 text
FORM SUB_DETERMINE_ALV_LAYOUT .
X_ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
X_ALV_LAYOUT-F2CODE = 'PICK'.
X_ALV_LAYOUT-WINDOW_TITLEBAR = 'PLANT DATA'.
X_ALV_LAYOUT-KEY_HOTSPOT = 'X'.
ENDFORM. " SUB_DETERMINE_ALV_LAYOUT
*& Form SUB_PREPARE_FIELDCATALOG1
text
--> p1 text
<-- p2 text
FORM SUB_PREPARE_FIELDCATALOG1 .
X_FIELDCAT-SELTEXT_L = 'MATERIAL'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 18.
X_FIELDCAT-FIELDNAME = 'MATNR'.
X_FIELDCAT-HOTSPOT = 'X'.
APPEND X_FIELDCAT TO I_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-SELTEXT_L = 'PLANT'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 4.
X_FIELDCAT-FIELDNAME = 'WERKS'.
APPEND X_FIELDCAT TO I_FIELDCAT1.
CLEAR X_FIELDCAT.
X_FIELDCAT-SELTEXT_L = 'Storage Location'.
X_FIELDCAT-DATATYPE = 'CHAR'.
X_FIELDCAT-OUTPUTLEN = 4.
X_FIELDCAT-FIELDNAME = 'LGORT'.
X_FIELDCAT-EDIT = 'X'.
APPEND X_FIELDCAT TO I_FIELDCAT1.
CLEAR X_FIELDCAT.
ENDFORM. " SUB_PREPARE_FIELDCATALOG1
*& Form SUB_SELECT_RECORD1
text
--> p1 text
<-- p2 text
FORM SUB_SELECT_RECORD1 .
SELECT MATNR WERKS LGORT FROM MARD INTO TABLE ITAB1 WHERE MATNR = ITAB-MATNR AND WERKS = ITAB-WERKS.
REFRESH I_FIELDCAT1.
ENDFORM. " SUB_SELECT_RECORD1
thanks and regardsConsider this logic.
DATA:
g_exclude TYPE slis_t_extab.
* FORM display_alv_report *
FORM display_alv_report.
PERFORM fieldcat_init USING g_fieldcat[].
PERFORM build_sort_fields USING g_sort[].
PERFORM eventtab_build USING g_events[]
g_events_ex[].
PERFORM layout_build USING g_layout.
PERFORM exclude_icons.
PERFORM list_view.
ENDFORM. " display_alv_report.
* Form exclude_icons
FORM exclude_icons.
APPEND '&ETA' TO g_exclude. "Details
* APPEND '&OUP' TO g_exclude. "Sort Up
* APPEND '&ODN' TO g_exclude. "Sort Down
APPEND '&ILT' TO g_exclude. "Set Filter
APPEND '&UMC' TO g_exclude. "Sum
APPEND '&RNT_PREV' TO g_exclude. "Print preview
* APPEND '&VEXCEL' TO g_exclude. "Excel
APPEND '&AQW' TO g_exclude. "Word processing
APPEND '%PC' TO g_exclude. "Local File
APPEND '%SL' TO g_exclude. "Mail recepient
APPEND '&ABC' TO g_exclude. "ABC Analysis
APPEND '&GRAPH' TO g_exclude. "Graphic
* APPEND '&OL0' TO g_exclude. "Change layout
* APPEND '&OAD' TO g_exclude. "Select layout
APPEND '&AVE' TO g_exclude. "Save Layout
APPEND '&INFO' TO g_exclude. "Information
ENDFORM. " exclude_icons
FORM list_view.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = g_layout
it_sort = g_sort[]
it_events = g_events[]
it_fieldcat = g_fieldcat[]
i_save = g_save
it_excluding = g_exclude "<== Exclude
TABLES
t_outtab = it_work
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'Error: ALV Grid'.
ENDIF.
ENDFORM. " layout_build -
Custom buttons in ALV grid display
I want to add custom buttons on application toolbar while displaying an ALV report using grid display.
how can it be done?Hi
In order to add user command functioality to the ALV grid you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM
2. Create 'USER_COMMAND' FORM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
FORM USER_COMMAND *
--> R_UCOMM *
--> RS_SELFIELD *
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
In order modify PF_STATUS of ALV grid report you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:
i_callback_pf_status_set = 'SET_PF_STATUS' statement.
2. Create 'SET_PF_STATUS' FORM
3. Create pf_status (i.e. 'ZNEWSTATUS').
- It is recommend that you copy standard status'STANDARD' from function group SALV
and modify it accordingly. ALV standard function codes always start with '&'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
FORM SET_PF_STATUS *
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZNEWSTATUS'.
"Copy of 'STANDARD' pf_status from fgroup SALV
ENDFORM. -
Hi frenz,
I have a requirement in PS module.The problem is, i am fetching 'lessons learned from the project' from CJ20N tcode which i have to display in ALV.If it is one line or two line i can display in the ALV but if it is of 1 or 2 pages ? here i have to place an icon or button for that and upon clicking that it shud go to that long text(cj20n tcode).pls help me .
reward is guaranteed.
BR,
ANIl.Hello Anil
Here is an example of how to display the long text of a PSP project.
*& Report ZUS_SDN_PS_LONGTEXT_DISPLAY
REPORT zus_sdn_ps_longtext_display.
DATA:
go_docking TYPE REF TO cl_gui_docking_container,
go_textedit TYPE REF TO cl_gui_textedit,
gd_name TYPE thead-tdname,
gs_header TYPE thead,
gd_langu TYPE thead-tdspras,
gt_lines TYPE STANDARD TABLE OF tline.
PARAMETERS:
p_pspnr TYPE prps-pspnr.
START-OF-SELECTION.
* Get the text object
gs_header-tdid = 'LTXT'. " long text
gs_header-tdspras = syst-langu.
CONCATENATE syst-langu p_pspnr
INTO gs_header-tdname.
gs_header-tdobject = 'PMS'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = gs_header-tdid
language = gs_header-tdspras
name = gs_header-tdname
object = gs_header-tdobject
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = gt_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL SCREEN '0100'.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
IF ( go_textedit IS NOT BOUND ).
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
* REPID =
* DYNNR =
* SIDE = DOCK_AT_LEFT
* EXTENSION = 50
* STYLE =
* LIFETIME = lifetime_default
* CAPTION =
* METRIC = 0
RATIO = 90
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_textedit
EXPORTING
* MAX_NUMBER_CHARS =
* STYLE = 0
wordwrap_mode =
c_textedit_control=>wordwrap_at_windowborder
* WORDWRAP_POSITION =
wordwrap_to_linebreak_mode =
c_textedit_control=>true
* FILEDROP_MODE = DROPFILE_EVENT_OFF
parent = go_docking
* LIFETIME =
* NAME =
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_textedit->set_text_as_r3table
EXPORTING
table = gt_lines
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_textedit->set_enable
EXPORTING
enable = CL_GUI_cfw=>false
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
others = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
SET SCREEN 0. LEAVE SCREEN.
ENDMODULE. " USER_COMMAND_0100 INPUT
Dynpro '0100' has no elements with the following flow logic:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
You simply add the button on your ALV list. When the user pushes this button you have to handle event BUTTON_CLICK. There you could call a function module containing the sample code above (has to be adjusted a little bit) which displays the long text.
Regards
Uwe -
Dear Experts,
How to add pushbutton in alv report.....
*& Report ZTT_TEST_ALV
REPORT ZTT_TEST_ALV.
*data declarations
type-pools : SLIS.
* data : BEGIN OF wa_kna1,
* kunnr type kunnr,
* name1 type name1,
* end of wa_kna1,
* it_kna1 like tABLE OF wa_kna1.
data : begin of wa_mara,
matnr type matnr,
end of wa_mara,
it_mara like table of wa_mara.
data : it_fcat type slis_t_fieldcat_alv,
wa_fcat like line of it_fcat.
*selection screen
SELECTION-SCREEN begin of block k with frame title text-001.
* select-OPTIONS : s_kunnr for wa_kna1-kunnr.
select-OPTIONS : s_matnr for wa_mara-matnr.
SELECTION-SCREEN end of block k.
*select auery
*SELECT kunnr name1 INTO table it_kna1 from kna1 where kunnr in s_kunnr.
select matnr into table it_mara from mara where matnr in s_matnr.
*for displaying fieldcatalog
PERFORM fcat using '1' 'MATNR' 'material Number' 'C410' '20'.
* PERFORM fcat using '2' 'NAME1' 'Customer Name' 'C410' '36'.
*for displaying output
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
* I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
I_GRID_TITLE = 'Report for Customer Details'
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = it_fcat[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_HTML_HEIGHT_TOP = 0
* I_HTML_HEIGHT_END = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_mara.
* 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.
*CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
* EXPORTING
**** I_INTERFACE_CHECK = ' '
**** I_CALLBACK_PROGRAM =
**** I_CALLBACK_PF_STATUS_SET = ' '
**** I_CALLBACK_USER_COMMAND = ' '
**** IS_LAYOUT =
* IT_FIELDCAT = it_fcat
**** IT_EXCLUDING =
**** IT_SPECIAL_GROUPS =
**** IT_SORT =
**** IT_FILTER =
**** IS_SEL_HIDE =
**** I_SCREEN_START_COLUMN = 0
**** I_SCREEN_START_LINE = 0
**** I_SCREEN_END_COLUMN = 0
**** I_SCREEN_END_LINE = 0
**** I_DEFAULT = 'X'
**** I_SAVE = ' '
**** IS_VARIANT =
**** IT_EVENTS =
**** IT_EVENT_EXIT =
*** i_tabname_header =
*** i_tabname_item =
**** I_STRUCTURE_NAME_HEADER =
**** I_STRUCTURE_NAME_ITEM =
*** is_keyinfo =
**** IS_PRINT =
**** IS_REPREP_ID =
**** I_BYPASSING_BUFFER =
**** I_BUFFER_ACTIVE =
**** IR_SALV_HIERSEQ_ADAPTER =
**** IT_EXCEPT_QINFO =
**** I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
**** IMPORTING
**** E_EXIT_CAUSED_BY_CALLER =
**** ES_EXIT_CAUSED_BY_USER =
* tables
** t_outtab_header = it_
* t_outtab_item = it_kna1.
**** 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 FCAT
* text
* -->P_0052 text
* -->P_0053 text
* -->P_0054 text
form FCAT using fp_col_pos
fp_fieldname
fp_seltext_m
fp_emphasize
fp_outputlen..
wa_fcat-col_pos = fp_col_pos.
wa_fcat-fieldname = fp_fieldname.
wa_fcat-seltext_m = fp_seltext_m.
wa_fcat-emphasize = fp_emphasize.
wa_fcat-outputlen = fp_outputlen.
append wa_fcat to it_fcat.
clear : wa_fcat.
endform. " FCAT
FORM SET_PF_STATUS .
SET PF-STATUS 'ZNEWSTATUS' .
"Copy of 'STANDARD' pf_status from fgroup SALV
endform.
i need one push button in alv output display.
Thanks and Regards,
Thirukumaran. RHI THIRU TRY FOLLOWING CODES:
*& Report ZSAMPLE
REPORT ZSAMPLE.
TABLES:MARA.
TYPE-POOLS: SLIS.
TYPES:BEGIN OF TY_ITAB,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
END OF TY_ITAB.
DATA:ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE.
DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FCAT TYPE SLIS_FIELDCAT_ALV,
LAYOUT TYPE SLIS_LAYOUT_ALV,
WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS:P_MATNR TYPE MARA-MATNR.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM FIELDCAT.
LAYOUT-ZEBRA = 'X'.
PERFORM OUTPUT.
*& Form PF_STATUS
text
-->RT_EXTAB text
FORM PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'BUTT'.
ENDFORM. "PF_STATUS
*& Form PUSH_BUTT1
text
-->R_UCOMM text
-->RS_SELFIELD text
FORM GET USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'GET'.
IF SY-SUBRC EQ 0.
CALL TRANSACTION 'SE11'.
ELSE.
ENDIF.
WHEN 'EXIT' OR 'CANCEL' .
LEAVE PROGRAM.
ENDCASE.
ENDFORM. "PUSH_BUTT1
*& Form FIELDCAT
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FCAT-SELTEXT_L = 'Select'.
WA_FCAT-COL_POS = '1'.
WA_FCAT-FIELDNAME = 'CHECK'.
WA_FCAT-CHECKBOX = 'X'.
WA_FCAT-TABNAME = 'ITAB'.
WA_FCAT-OUTPUTLEN = '4'.
WA_FCAT-INPUT(1) = 'X'.
WA_FCAT-EDIT_MASK(1) = 'X'.
WA_FCAT-EDIT(1) = 'X'.
APPEND WA_FCAT TO FCAT.
CLEAR WA_FCAT.
WA_FCAT-SELTEXT_L = 'Material Number'.
WA_FCAT-COL_POS = '2'.
WA_FCAT-FIELDNAME = 'MATNR'.
WA_FCAT-TABNAME = 'ITAB'.
WA_FCAT-OUTPUTLEN = '18'.
APPEND WA_FCAT TO FCAT.
CLEAR WA_FCAT.
WA_FCAT-SELTEXT_L = 'Date'.
WA_FCAT-COL_POS = '3'.
WA_FCAT-FIELDNAME = 'ERSDA'.
WA_FCAT-TABNAME = 'ITAB'.
WA_FCAT-OUTPUTLEN = '8'.
APPEND WA_FCAT TO FCAT.
CLEAR WA_FCAT.
ENDFORM. " FIELDCAT
*& Form OUTPUT
text
--> p1 text
<-- p2 text
FORM OUTPUT .
SELECT MATNR ERSDA FROM MARA
INTO TABLE ITAB
WHERE MATNR EQ P_MATNR.
IF SY-SUBRC EQ 0.
PERFORM GRID.
ELSE.
MESSAGE 'No Records Found' TYPE 'I'.
ENDIF.
ENDFORM. " OUTPUT
*& Form GRID
text
--> p1 text
<-- p2 text
FORM GRID .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'GET'
IS_LAYOUT = LAYOUT
IT_FIELDCAT = FCAT
I_DEFAULT = 'X'
TABLES
T_OUTTAB = ITAB.
ENDFORM. " GRID
REGARDS,
SAKTHIVEL.VT -
Error in clicking save to local file button in alv grid?
Hi
I am getting error , While clicking on some buttons like save as local file button in alv grid display
How to rectify it
Thanks in advanceIn your REUSE_ALV_GRID_DISPLAY
EXPORTING
I_SAVE = 'U'
put this field....and then check it will definitely work... -
Wan to add push button in the output of ALV Grid display.
Hi Friends,
I wan to add a Push button in the output of ALV GRID display with STANDARD ikons.
How to copy standard ikons of GRID output.
How to apply the copied status into my code.
Regards,
VijiHi,
Goto SE41, create a pf-status for your alv report program.
On the next screen, click menu EXTRAS --> click option ADJUST TEMPLATES and select radiobutton LIST VIEWER --> you will get all standard buttons of alv in the pf-status.
Delete the unwanted buttons and also you can add new buttons if reqd.
Activate pf-status --> and apply in alv program.
Now to apply this pf-status in your alv report follow code:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
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 pf
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
* -->RT_EXTAB
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'. "<--pass pf-status name here
ENDFORM. "pf
*& Form USER_COMMAND
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
WHEN '<function_code>'. "<--to handle user actions
ENDCASE.
ENDFORM. "USER_COMMAND
Hope this helps you.
Regards,
Tarun -
Problem with ALV Grid Display screen Back Button
Dear Friends ,
I have an ALV Grid Display,Here am facing a problem for my 'Back' button,i haven't defined any PF Status and is using the standard one.But after the Display when i press Back Button a blank Screen is appearing n then again i have to press back button to go to my Selection Screen.
Please Suggest if i have to take care of something else.
I want my Selection Screen when i press Back on my Display Screen.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = 'ZRMMPD01A'
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
Thanks and Regards,
AshwiniHi Vijay ,
No i dont have any write statement in my proggram.
Here it is
REPORT ZRMMPD01A NO STANDARD PAGE HEADING.
TABLES : EQUI,SER03,MKPF,OBJK.
TYPE-POOLS : SLIS.
DATA IT_EQUI LIKE EQUI OCCURS 0 WITH HEADER LINE.
DATA IT_OBJK LIKE OBJK OCCURS 0 WITH HEADER LINE..
DATA IT_SER03 LIKE SER03 OCCURS 0 WITH HEADER LINE.
DATA IT_MKPF LIKE MKPF OCCURS 0 WITH HEADER LINE .
DATA : BEGIN OF IT_DISPLAY OCCURS 0,
MATNR LIKE EQUI-MATNR,
SERNR LIKE EQUI-SERNR,
BWART LIKE SER03-BWART,
WERK LIKE SER03-WERK,
CHARGE LIKE SER03-CHARGE,
LAGERORT LIKE SER03-LAGERORT,
MBLNR LIKE SER03-MBLNR,
MJAHR LIKE SER03-MJAHR,
ZEILE LIKE SER03-ZEILE,
BUDAT LIKE MKPF-BUDAT,
BKTXT LIKE MKPF-BKTXT,
USNAM LIKE MKPF-USNAM,
XBLNR LIKE MKPF-XBLNR,
END OF IT_DISPLAY.
DATA : WA_DISPLAY LIKE IT_DISPLAY.
DATA IT_FINAL LIKE IT_DISPLAY OCCURS 0 WITH HEADER LINE.
DATA IT_TEMP LIKE IT_DISPLAY OCCURS 0 WITH HEADER LINE.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA :I_LAYOUT TYPE SLIS_LAYOUT_ALV,
I_EVENTS TYPE SLIS_T_EVENT.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_MATNR FOR EQUI-MATNR MATCHCODE OBJECT MCD,"OBLIGATORY
S_SERNR FOR EQUI-SERNR, "MATCHCODE OBJECT MCD OBLIGATORY
S_MBLNR FOR SER03-MBLNR MATCHCODE OBJECT MCD,
S_BWART FOR SER03-BWART MATCHCODE OBJECT MCD,
S_WERK FOR SER03-WERK MATCHCODE OBJECT MCD,
S_LAGET FOR SER03-LAGERORT MATCHCODE OBJECT MCD,
S_BUDAT FOR MKPF-BUDAT MATCHCODE OBJECT MCD,
S_XBLNR FOR MKPF-XBLNR MATCHCODE OBJECT MCD.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X',
R2 RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B2.
START-OF-SELECTION.
*Fetch Data.
PERFORM GET_DATA.
*Fill Display Fields.
PERFORM FILL_TABLE.
*Segregate data according to radio button selection.
PERFORM SELECT_CONDITION.
*Fill The Feild catalog.
PERFORM FIELD_CATALOG.
*Display Output.
PERFORM OUTPUT_DISPLAY..
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM GET_DATA.
SELECT * FROM EQUI INTO TABLE IT_EQUI
WHERE MATNR IN S_MATNR
AND SERNR IN S_SERNR.
SELECT * FROM OBJK INTO TABLE IT_OBJK
FOR ALL ENTRIES IN IT_EQUI
WHERE EQUNR = IT_EQUI-EQUNR.
SELECT * FROM SER03 INTO TABLE IT_SER03
FOR ALL ENTRIES IN IT_OBJK
WHERE OBKNR = IT_OBJK-OBKNR
AND MBLNR IN S_MBLNR
AND BWART IN S_BWART
AND WERK IN S_WERK
AND LAGERORT IN S_LAGET.
SELECT * FROM MKPF INTO TABLE IT_MKPF
FOR ALL ENTRIES IN IT_SER03
WHERE MBLNR = IT_SER03-MBLNR
AND BUDAT IN S_BUDAT
AND XBLNR IN S_XBLNR.
ENDFORM. " GET_DATA
*& Form FILL_TABLE
text
--> p1 text
<-- p2 text
FORM FILL_TABLE.
LOOP AT IT_EQUI.
LOOP AT IT_OBJK.
IF IT_OBJK-EQUNR <> IT_EQUI-EQUNR.
SKIP.
ELSE.
READ TABLE IT_SER03 WITH KEY OBKNR = IT_OBJK-OBKNR.
IF SY-SUBRC = 0.
WA_DISPLAY-MATNR = IT_EQUI-MATNR.
WA_DISPLAY-SERNR = IT_EQUI-SERNR.
WA_DISPLAY-BWART = IT_SER03-BWART.
WA_DISPLAY-WERK = IT_SER03-WERK.
WA_DISPLAY-CHARGE = IT_SER03-CHARGE.
WA_DISPLAY-LAGERORT = IT_SER03-LAGERORT.
WA_DISPLAY-MBLNR = IT_SER03-MBLNR.
WA_DISPLAY-MJAHR = IT_SER03-MJAHR.
WA_DISPLAY-ZEILE = IT_SER03-ZEILE.
READ TABLE IT_MKPF WITH KEY MBLNR = IT_SER03-MBLNR.
IF SY-SUBRC = 0.
WA_DISPLAY-BUDAT = IT_MKPF-BUDAT.
WA_DISPLAY-BKTXT = IT_MKPF-BKTXT.
WA_DISPLAY-USNAM = IT_MKPF-USNAM.
WA_DISPLAY-XBLNR = IT_MKPF-XBLNR.
ENDIF.
ENDIF.
ENDIF.
IF NOT WA_DISPLAY IS INITIAL.
APPEND WA_DISPLAY TO IT_DISPLAY.
CLEAR WA_DISPLAY.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDFORM. " FILL_TABLE
*& Form FIELD_CATALOG
text
--> p1 text
<-- p2 text
FORM FIELD_CATALOG.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'MATNR'.
FIELDCAT-SELTEXT_M = 'Material Number'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'SERNR'.
FIELDCAT-SELTEXT_M = 'Serial number'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'MBLNR'.
FIELDCAT-SELTEXT_L = 'Number of material document'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'BWART'.
FIELDCAT-SELTEXT_M = 'Movement type'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'WERK'.
FIELDCAT-SELTEXT_M = 'Plant'.
FIELDCAT-OUTPUTLEN = 5.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'CHARGE'.
FIELDCAT-SELTEXT_M = 'Batch number'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'LAGERORT'.
FIELDCAT-SELTEXT_M = 'Storage Location'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'MJAHR'.
FIELDCAT-SELTEXT_M = 'Material doc. year'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'ZEILE'.
FIELDCAT-SELTEXT_L = 'Item in material document'.
FIELDCAT-OUTPUTLEN = 18.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'BUDAT'.
FIELDCAT-SELTEXT_L = 'Posting date in the document'.
FIELDCAT-OUTPUTLEN = 10.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'BKTXT'.
FIELDCAT-SELTEXT_L = 'Document header text'.
FIELDCAT-OUTPUTLEN = 25.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'USNAM'.
FIELDCAT-SELTEXT_M = 'User name'.
FIELDCAT-OUTPUTLEN = 15.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
FIELDCAT-TABNAME = 'IT_DISPLAY'.
FIELDCAT-FIELDNAME = 'XBLNR'.
FIELDCAT-SELTEXT_L = 'Reference document number'.
FIELDCAT-OUTPUTLEN = 25.
APPEND FIELDCAT TO IT_FIELDCAT.
CLEAR FIELDCAT.
ENDFORM. " FIELD_CATALOG
*& Form DISPLAY_OUTPUT
text
--> p1 text
<-- p2 text
FORM OUTPUT_DISPLAY.
IF R1 = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZRMMPD01A'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
TABLES
T_OUTTAB = IT_DISPLAY
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.
REFRESH IT_DISPLAY.
CLEAR IT_DISPLAY.
ELSEIF R2 = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'ZRMMPD01A'
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
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.
REFRESH IT_DISPLAY.
CLEAR IT_DISPLAY.
ENDIF.
ENDFORM. " DISPLAY_OUTPUT
*& Form SELECT_CONDITION
text
--> p1 text
<-- p2 text
FORM SELECT_CONDITION.
IF R2 = 'X'.
CLEAR WA_DISPLAY.
SORT IT_DISPLAY BY MATNR SERNR MBLNR ZEILE.
DELETE ADJACENT DUPLICATES FROM IT_DISPLAY.
LOOP AT IT_DISPLAY WHERE ZEILE = '0002'.
READ TABLE IT_DISPLAY WITH KEY MATNR = IT_DISPLAY-MATNR
SERNR = IT_DISPLAY-SERNR ZEILE = '0001'.
IF SY-SUBRC = 0.
DELETE IT_DISPLAY.
ENDIF.
ENDLOOP.
SORT IT_DISPLAY BY MATNR SERNR BWART MBLNR.
DELETE ADJACENT DUPLICATES FROM IT_DISPLAY.
LOOP AT IT_DISPLAY.
IF WA_DISPLAY IS INITIAL.
WA_DISPLAY = IT_DISPLAY.
ENDIF.
LOOP AT IT_DISPLAY WHERE MATNR = WA_DISPLAY-MATNR
AND SERNR = WA_DISPLAY-SERNR.
IF IT_DISPLAY-BUDAT > WA_DISPLAY-BUDAT.
WA_DISPLAY = IT_DISPLAY.
ELSE.
DELETE IT_DISPLAY.
ENDIF.
ENDLOOP.
APPEND WA_DISPLAY TO IT_TEMP.
CLEAR WA_DISPLAY.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM IT_TEMP.
IF NOT IT_TEMP[] IS INITIAL.
IT_FINAL[] = IT_TEMP[].
ENDIF.
ENDIF.
ENDFORM. " SELECT_CONDITION
Regards,
Ashwini -
Button in alv grid cell using REUSE_ALV_GRID_DISPLAY
Hi all,
I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
Thanks.this may helps u
u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
status : <b>STANDARD_FULLSCREEN</b>
and copy it ...
Type-pool
type-pools slis.
Tables
tables: mara,sscrfields.
Selection screen
select-options: s_matnr for mara-matnr.
PARAMETERS: p_email TYPE somlreci1-receiver.
TYPES: BEGIN OF t_charmara,
matnr(18) TYPE c, " Material Number
ernam(12) TYPE c, " Person Credited
aenam(12) TYPE c, " Person Changed Object
pstat(15) TYPE c, " Maintenance Status
END OF t_charmara.
Data Declarations
data: rt_extab type slis_t_extab, " Table of inactive function
codes
wa_charmara TYPE t_charmara, " work area of mara Table
fs_fieldcat type slis_t_fieldcat_alv,
" Field catalog with field
descriptions
t_fieldcat like line of fs_fieldcat,
" Table of Field catalog
r_ucomm like sy-ucomm, " User Command
rs_selfield TYPE slis_selfield. " cursor position ALV
data: filedlayout type slis_layout_alv,
heading type slis_t_listheader with header line,
t_event type slis_t_event.
data: fs_event like line of t_event.
data: fs_sort type slis_sortinfo_alv,
t_sort type slis_t_sortinfo_alv.
data: w_char(200) type c,
w_matnr type mara-matnr.
fs_sort-fieldname = 'MATNR'.
fs_sort-up = 'X'.
fs_sort-group = '*'.
append fs_sort to t_sort.
clear fS_sort.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
Internal Tables
data: begin of it_mara occurs 0,
matnr like mara-matnr, " Material Number
ernam like mara-ernam, " Person Credited
aenam like mara-aenam, " Person Changed Object
pstat like mara-pstat, " Maintenance Status
end of it_mara.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
*at selection-screen on field event
AT SELECTION-SCREEN on s_matnr.
PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
start-of-selection.
retrive Data from the data base table Mara
perform retrive_data_from_mara.
end-of-selection.
*Field catalog with field descriptions
perform fieldcat.
*perform top_of_page.
PERFORM EVENT_LIST.
*ALV Grid Display
perform alv_display.
Creating one Push button ENTER
perform maratab1 USING RT_EXTAB.
*& Form f0100_VALIDATE_MATERIAL_NUMBER
text
There are no interface parameters to be passed to this subroutine
FORM F0100_VALIDATE_MATERIAL_NUMBER .
select matnr " Material Number
from mara
up to 1 rows
into mara-matnr
where matnr in s_matnr.
endselect.
IF sy-subrc NE 0.
clear sscrfields-ucomm.
MESSAGE e000 WITH 'Enter valid Material number'(003).
ENDIF. " IF sy-subrc NE 0
ENDFORM. " f0100_VALIDATE_MATERIAL_NUMBER
*& Form retrive_data_from_mara
text
*There are no interface parameters to be passed to this subroutine
FORM retrive_data_from_mara .
select matnr " Material Number
ernam " Person Credited
aenam " Person Changed Object
pstat " Maintenance Status
from mara
into table It_mara
where matnr in s_matnr.
IF sy-subrc NE 0.
MESSAGE i001 WITH 'Records are not found'.
exit.
stop.
ENDIF. " IF sy-subrc NE 0
ENDFORM. " retrive_data_from_mara
*& Form fieldcat
text
*There are no interface parameters to be passed to this subroutine
FORM fieldcat .
*field catalog for MATNR
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'MATNR'.
t_fieldcat-col_pos = 1.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for ERNAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'ERNAM'.
t_fieldcat-col_pos = 2.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for AENAM
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'AENAM'.
t_fieldcat-col_pos = 3.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
*field catalog for PSTAT
t_FIELDCAT-REF_TABNAME = 'MARA'.
t_fieldcat-fieldname = 'PSTAT'.
t_fieldcat-col_pos = 4.
append t_fieldcat to fs_fieldcat.
clear t_fieldcat.
ENDFORM. " fieldcat
*& Form EVENT_LIST
text
*There are no interface parameters to be passed to this subroutine
FORM EVENT_LIST .
fs_event-name ='TOP_OF_PAGE'.
fs_event-form = 'TOP_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_PAGE'.
fs_event-form = 'END_PAGE'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
fs_event-name ='END_OF_LIST'.
fs_event-form = 'LIST_END'.
append fs_event TO t_EVENT.
CLEAR FS_EVENT.
ENDFORM. " EVENT_LIST
*& Form alv_display
text
*There are no interface parameters to be passed to this subroutine
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'MARATAB1'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_STRUCTURE_NAME =
IS_LAYOUT =
IT_FIELDCAT = FS_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT = T_SORT
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS = T_EVENT
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IR_SALV_LIST_ADAPTER =
IT_EXCEPT_QINFO =
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_MARA[]
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. " alv_display
form TOP_PAGE.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = 'Created by : Vijay Pawar'.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' Date ' sy-datum into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
wa_listheader-typ = 'S'.
concatenate ' From ' s_matnr-low ' To ' s_matnr-high into
wa_listheader-info separated by space.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form TOP_PAGE.
form END_PAGE.
STATICS W_PAGE TYPE I .
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = W_PAGE.
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
add 1 to w_page.
endform. " form END_PAGE.
form list_end.
data:tbl_listheader type slis_t_listheader,
wa_listheader type slis_listheader .
wa_listheader-typ = 'S'.
wa_listheader-info = '......................................Last Page'
append wa_listheader to tbl_listheader.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = tbl_listheader
I_LOGO =
I_END_OF_LIST_GRID =
I_ALV_FORM =
endform. " form list_end.
*& Form maratab1
text
-->P_RT_EXTAB text
FORM maratab1 USING P_RT_EXTAB.
SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
ENDFORM. " maratab1
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
case r_ucomm.
when 'ENTER'.
perform bulid_xls_data_table.
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email "'[email protected]'
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
endcase. " case r_ucomm.
endform. " FORM user_command
perform populate_email_message_body.
PERFORM initiate_mail_execute_program.
CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
EXPORTING
DATA_FILENAME = 'MARA.XLS'
DATA_PATH_FLAG = 'W'
DATA_ENVIRONMENT =
DATA_TABLE = ITAB[]
MACRO_FILENAME =
MACRO_PATH_FLAG = 'E'
MACRO_ENVIRONMENT =
WAIT = 'X'
DELETE_FILE = 'X'
EXCEPTIONS
NO_BATCH = 1
EXCEL_NOT_INSTALLED = 2
INTERNAL_ERROR = 3
CANCELLED = 4
DOWNLOAD_ERROR = 5
NO_AUTHORITY = 6
FILE_NOT_DELETED = 7
OTHERS = 8
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
leave to list-processing.
endcase.
*& Form bulid_xls_data_table
text
*There are no interface parameters to be passed to this subroutine
FORM bulid_xls_data_table .
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT It_mara INTO wa_charmara.
CONCATENATE wa_charmara-matnr wa_charmara-ernam
wa_charmara-aenam wa_charmara-pstat
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP. " LOOP AT it_mara INTO...
ENDFORM. " bulid_xls_data_table
*& Form send_file_as_email_attachment
Send email
-->P_IT_MESSAGE text
-->P_IT_ATTACH text
-->P_P_EMAIL text
-->P_0387 text
-->P_0388 text
-->P_0389 text
-->P_0390 text
-->P_0391 text
-->P_0392 text
<--P_GD_ERROR text
<--P_GD_RECIEVER text
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM. " send_file_as_email_attachment
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test mara records'.
APPEND it_message.
endform. "form populate_email_message_bod
rewards if it helps u
Maybe you are looking for
-
Smart Form printing issue in repeate page
Hi, We have one smartfforms printing some notification details in which Only one page layout is use and it is repeated again at one block Upper margin is 18.23 and Height is 9.60 CM on first page it is printing properly but on second page it is
-
How to wake a computer from a remote location
How to wake an imac 9 simply) from a remote location with a macbook
-
I have 3 computers in my home and would like for all to b...
i have 3 computers in my home and would like for all to be able yto connect to the internet using my linksys router. the only one currently able to connect is the one he router is connected yto. can you help
-
Hi, I would like to use mutiple valution to meet report requirement. In our company, we have to provide two sets report which comply local GAAP and group GAAP, CO will using group GAAP. For example, certain transaction will belong to cost in local GA
-
Hello, Dose anybody else use a dedicated network for there DPM back up traffic? I only ask as yesterday we had a Hyper-V environment failure due to (copyied from even viewer) " Failed to allocate VMQ for NIC + Maximum number of VMQs supported on the