Dear All,
Below code are Example to doble click on Column and Upload what ever you want to in Select Option. Below Code For MRBR. in MRBR directly upload document number which are show in Report just Double click on zreport column-document and upload all document no.
*&---------------------------------------------------------------------*
*& Report ZMRBR_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMRBR_REPORT.
*&---------------------------------------------------------------------*
*& Report ZALDEMO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
TABLES: bkpf.
type-pools: slis. "ALV Declarations
*Data Declaration
*----------------
TYPES : BEGIN OF ty_final,
belnr TYPE bkpf-belnr,
budat TYPE bkpf-budat,
gjahr TYPE bkpf-gjahr,
cpudt TYPE bkpf-cpudt,
awkey TYPE bkpf-awkey,
END OF ty_final.
TYPES : BEGIN OF ty_final1,
belnr1 TYPE bkpf-belnr,
END OF ty_final1.
data : it_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final,
it_final1 TYPE STANDARD TABLE OF ty_final1,
wa_final1 TYPE ty_final1.
*
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
BREAK 10115.
perform data_retrieval.
if it_final[] IS INITIAL.
MESSAGE 'Data is not found' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*
* SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001 .
* SELECT-OPTIONS s_purch for ekko-ebeln. ""Purchase Document
* SELECT-OPTIONS s_code for ekpo-werks. ""Plant
* SELECT-OPTIONS s_date for ekko-bedat. "Document Date
* SELECT-OPTIONS s_vndr for ekko-lifnr. "Vendor
* SELECT-OPTIONS s_mtnr for ekpo-matkl. "Material Group
* SELECT-OPTIONS s_mat for ekpo-matnr. "Material
* SELECT-OPTIONS S_DAT FOR eket-eindt. "Posting Date
* SELECTION-SCREEN END OF BLOCK a1.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001 .
SELECT-OPTIONS s_doc for bkpf-belnr.
* SELECT-OPTIONS s_year for bkpf-gjahr.
SELECT-OPTIONS s_date for bkpf-budat.
SELECT-OPTIONS s_vndr for bkpf-cpudt.
PARAMETERS s_year LIKE bkpf-gjahr DEFAULT '2012'.
SELECTION-SCREEN END OF BLOCK a1.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
DATA : RS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
fieldcatalog-fieldname = 'BELNR'.
fieldcatalog-seltext_m = 'Document NO.'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GJAHR'.
fieldcatalog-seltext_m = 'Fiscal Year'.
fieldcatalog-col_pos = 2.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BUDAT'.
fieldcatalog-seltext_m = 'Posting Date'.
fieldcatalog-col_pos = 3.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'CPUDT'.
fieldcatalog-seltext_m = 'Entry Date'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AWKEY'.
fieldcatalog-seltext_m = 'Ref Key'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
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.
endform. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
SELECT belnr
budat
gjahr
cpudt
awkey
FROM bkpf
INTO TABLE it_final
WHERE belnr in s_doc
AND budat in s_date
AND cpudt in s_vndr
AND gjahr = s_year.
delete adjacent duplicates FROM it_final .
BREAK 10115.
LOOP AT it_final INTO wa_final.
wa_final1-belnr1 = wa_final-belnr.
APPEND wa_final1 to it_final1.
ENDLOOP.
* delete adjacent duplicates FROM it_final COMPARING ALL FIELDS.
endform. " DATA_RETRIEVAL
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'MRBR R BLocke Remover Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_final lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform. "top-of-page
*------------------------------------------------------------------*
* FORM USER_COMMAND *
*------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*------------------------------------------------------------------*
*************************Double click Event**************************
*********************************************************************
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'AWKEY'.
BREAK 10115.
data: r_belnr type range of awkey,
r_belnr_l like line of r_belnr.
*now in the code replace1 your loop by this:
loop at it_final into wa_final.
r_belnr_l-sign = 'I'.
r_belnr_l-OPTION = 'EQ'.
r_belnr_l-LOW = wa_final-awkey.
r_belnr_l-high = ' '.
append r_belnr_l to r_belnr.
endloop.
SUBMIT RM08RELEASE VIA SELECTION-SCREEN WITH SO_BELNR IN r_belnr AND RETURN.
* LOOP AT it_final INTO wa_final.
ENDIF.
ENDCASE.
ENDFORM.
** Check field clicked on within ALVgrid report
* IF rs_selfield-fieldname = 'AWKEY'.
** Read data table, using index of row user clicked on
* READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.
* BREAK 10115.
** Set parameter ID for transaction screen field
* SET PARAMETER ID 'AWK' FIELD wa_final-AWKEY.
* SET PARAMETER ID 'AWK' FIELD wa_final-AWKEY.
** Sxecute transaction MRBR, and skip initial data entry screen
* CALL TRANSACTION 'MRBR' AND SKIP FIRST SCREEN.
* ENDIF.
"user_command
*&---------------------------------------------------------------------*
*& Form BUILD_EVENTS
*&---------------------------------------------------------------------*
* Build events table
*----------------------------------------------------------------------*
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_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*&---------------------------------------------------------------------*
*& Form BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
* Setup print parameters
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
*& Form END_OF_PAGE
*&---------------------------------------------------------------------*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_PAGE
*&---------------------------------------------------------------------*
*& Form END_OF_LIST
*&---------------------------------------------------------------------*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_LIST