Skip to Content

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.
typepools: slis.                                 “ALV Declarations
*Data Declaration
*—————-
TYPES : BEGIN OF ty_final,
           belnr TYPE bkpfbelnr,
           budat TYPE bkpfbudat,
           gjahr TYPE bkpfgjahr,
           cpudt TYPE bkpfcpudt,
           awkey TYPE bkpfawkey,
          END OF ty_final.
TYPES : BEGIN OF ty_final1,
           belnr1 TYPE bkpfbelnr,
         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 syrepid,
       gt_events     type slis_t_event,
       gd_prntparams type slis_print_alv.

************************************************************************
*Start-of-selection.
STARTOFSELECTION.

   BREAK 10115.
   perform data_retrieval.
   if it_final[] IS INITIAL.
     MESSAGE ‘Data is not found’ TYPE ‘I’.
     LEAVE LISTPROCESSING.
   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 text001 .
   SELECT-OPTIONS s_doc for bkpfbelnr.
*  SELECT-OPTIONS s_year for bkpf-gjahr.
   SELECT-OPTIONS s_date for bkpfbudat.
   SELECT-OPTIONS s_vndr for bkpfcpudt.
   PARAMETERS  s_year LIKE bkpfgjahr 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.

   fieldcatalogfieldname   = ‘BELNR’.
   fieldcatalogseltext_m   = ‘Document NO.’.
   fieldcatalogcol_pos     = 1.
   fieldcatalogemphasize   = ‘X’.
   fieldcatalogkey         = ‘X’.
   append fieldcatalog to fieldcatalog.
   clear  fieldcatalog.

   fieldcatalogfieldname   = ‘GJAHR’.
   fieldcatalogseltext_m   = ‘Fiscal Year’.
   fieldcatalogcol_pos     = 2.
   fieldcatalogemphasize   = ‘X’.
   fieldcatalogkey         = ‘X’.
   append fieldcatalog to fieldcatalog.
   clear  fieldcatalog.

   fieldcatalogfieldname   = ‘BUDAT’.
   fieldcatalogseltext_m   = ‘Posting Date’.
   fieldcatalogcol_pos     = 3.
   fieldcatalogemphasize   = ‘X’.
   fieldcatalogkey         = ‘X’.
   append fieldcatalog to fieldcatalog.
   clear  fieldcatalog.

   fieldcatalogfieldname   = ‘CPUDT’.
   fieldcatalogseltext_m   = ‘Entry Date’.
   fieldcatalogcol_pos     = 4.
   fieldcatalogoutputlen   = 10.
   fieldcatalogemphasize   = ‘X’.
   fieldcatalogkey         = ‘X’.
   append fieldcatalog to fieldcatalog.
   clear  fieldcatalog.

   fieldcatalogfieldname   = ‘AWKEY’.
   fieldcatalogseltext_m   = ‘Ref Key’.
   fieldcatalogcol_pos     = 5.
   append fieldcatalog to fieldcatalog.
   clear  fieldcatalog.

endform.                    ” BUILD_FIELDCATALOG

*&———————————————————————*
*&      Form  BUILD_LAYOUT
*&———————————————————————*
*       Build layout for ALV grid report
*———————————————————————-*
form build_layout.
   gd_layoutno_input          = ‘X’.
   gd_layoutcolwidth_optimize = ‘X’.
   gd_layouttotals_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 = syrepid.
   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 sysubrc <> 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_final1belnr1 = wa_finalbelnr.
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 topofpage.
*ALV Header declarations
   data: t_header type slis_t_listheader,
         wa_header type slis_listheader,
         t_line like wa_headerinfo,
         ld_lines type i,
         ld_linesc(10) type c.

* Title
   wa_headertyp  = ‘H’.

   wa_headerinfo = ‘MRBR R BLocke Remover Report’.
   append wa_header to t_header.
   clear wa_header.

* Date
   wa_headertyp  = ‘S’.
   wa_headerkey = ‘Date: ‘.
   CONCATENATE  sydatum+6(2) ‘.’
                sydatum+4(2) ‘.’
                sydatum(4) INTO wa_headerinfo.   “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_headertyp  = ‘A’.
   wa_headerinfo = 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 syucomm
                   rs_selfield TYPE slis_selfield.
   CASE r_ucomm.
     WHEN ‘&IC1’.
*   Check field clicked on within ALVgrid report
       IF  rs_selfieldfieldname = ‘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_lsign = ‘I’.
  r_belnr_lOPTION = ‘EQ’.
  r_belnr_lLOW = wa_finalawkey.
  r_belnr_lhigh = ‘ ‘.
  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 sysubrc = 0.
     move ‘END_OF_PAGE’ to ls_eventform.
     append ls_event to gt_events.
   endif.

   read table gt_events with key name slis_ev_end_of_list
                          into ls_event.
   if sysubrc = 0.
     move ‘END_OF_LIST’ to ls_eventform.
     append ls_event to gt_events.
   endif.
endform.                    ” BUILD_EVENTS

*&———————————————————————*
*&      Form  BUILD_PRINT_PARAMS
*&———————————————————————*
*       Setup print parameters
*———————————————————————-*
form build_print_params.
   gd_prntparamsreserve_lines = ‘3’.   “Lines reserved for footer
   gd_prntparamsno_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: syuline(50).
   skip.
   write:/40 ‘Page:’, sypagno .
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:’, sypagno .
endform.                    “END_OF_LIST

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply