Posted: Sat Sep 22, 2007 7:38 pm Post subject: Double click on a ALV grid and call a new transaction
Code:
report sy-repid.
type-pools : slis.
*ALV Formatting tables /structures
data: gt_fieldcat type slis_t_fieldcat_alv.
data: gt_events type slis_t_event.
data: gs_layout type slis_layout_alv.
data: gt_page type slis_t_listheader.
data: gs_page type slis_listheader.
data: v_repid like sy-repid.
*ALV Formatting work area
data: w_fieldcat type slis_fieldcat_alv.
data: w_events type slis_alv_event.
data: gt_bsid type table of bsid with header line.
*top of page event does not work without I_callback_program
v_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
i_structure_name = 'BSID'
* i_background_id = 'ALV_BACKGROUND'
i_grid_title = 'This is the grid title'
* I_GRID_SETTINGS =
is_layout = gs_layout
it_fieldcat = gt_fieldcat[]
it_events = gt_events[]
tables
t_outtab = gt_bsid
* 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..............: populate_for_fm
* Description.......: Populates fields for function module used in ALV
* Called by.........: Load_fm
* Calls.............: N/A
************************************************************************
*Can do the fieldcat this way if you prefer
form populate_for_fm using p_row
p_col
p_fieldname
p_len
p_table
p_desc.
w_fieldcat-row_pos = p_row. "Row Position
w_fieldcat-col_pos = p_col. "Column Position
w_fieldcat-fieldname = p_fieldname. "Field name
w_fieldcat-outputlen = p_len. "Column Lenth
w_fieldcat-tabname = p_table. "Table name
w_fieldcat-reptext_ddic = p_desc. "Field Description
w_fieldcat-input = '1'.
append w_fieldcat to gt_fieldcat.
clear w_fieldcat.
endform. " populate_for_fm
*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = gt_events.
read table gt_events with key name = slis_ev_user_command
into ls_event.
if sy-subrc = 0.
move slis_ev_user_command to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_top_of_page
into ls_event.
if sy-subrc = 0.
move slis_ev_top_of_page to ls_event-form.
append ls_event to gt_events.
endif.
endform. " build_events
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
* When user command is called it uses the above parameters. The itab
* passed to the ALV is in whatever order it currently is on screen.
* Therefore, you can read table itab index rs_selfield-tabindex to get
* all data from the table. You can also check r_ucomm and code
* accordingly.
read table gt_bsid index rs_selfield-tabindex.
set parameter id 'KUN' field gt_bsid-kunnr.
call transaction 'XD03' and skip first screen.
endform.
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = gt_page
i_logo = 'ENJOY_SAP'.
* Your own company logo can go here if it has been saved (OAOR)
endform.
*&---------------------------------------------------------------------*
*& Form build_fieldcat
*&---------------------------------------------------------------------*
form build_fieldcat.
*Many and varied fields are available here. Have a look at documentation
*for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.