Adding color to few rows in ALV report output

Hi,
I have developed a ALV report program which displays the project details of the employees.In the output the rows containing the employees who have been part of the project should be displayed in different color.I have used necessary code for this but still the rows are not displayed in different color.
Given below is my program.Please suggest me possible solution for this.
REPORT  ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
      empid like zheempl-empid,
      grade like zheempl-grade,
      location like zheempl-location,
      pu like zheempl-pu,
      name1 like zheempl-name1,
      end of ty_zheempl.
types: begin of ty_zhealoc,
      project like zhealoc-project,
      stdat like zhealoc-stdat,
      endat like zhealoc-endat,
      role like zhealoc-role,
      end of ty_zhealoc.
types: begin of ty_output,
      empid like zheempl-empid,
      grade like zheempl-grade,
      location like zheempl-location,
      pu    like zheempl-pu,
      name1 like zheempl-name1,
      role like zhealoc-role,
      stdat like zhealoc-stdat,
      endat like zhealoc-endat,
      cellcolor(4) type c,
      end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
      t_zhealoc type standard table of ty_zhealoc,
      t_output type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
      wa_zhealoc type ty_zhealoc,
      wa_output type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
      wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
      wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
                s_empid   for wa_zheempl-empid.
parameters:     p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters:      p_prtosr  radiobutton group g1 default 'X',
                 p_prusly  radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters:      p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters:      p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
  IF p_shwhis = 'X'.
SELECT l~empid
       l~grade
       l~location
       l~pu
       l~name1
       c~role
       c~stdat
       c~endat
  INTO TABLE t_output
  FROM ( zheempl AS l
  INNER JOIN zhealoc
  AS c ON lempid = cempid )
  where project IN s_proj
  AND endat < p_date
  OR endat > p_date.
   t_output-cellcolor = 'C310'.
   MODIFY t_output transporting cellcolor where endat < p_date.
  ELSE.
  select l~empid
       l~grade
       l~location
       l~pu
       l~name1
       c~role
       c~stdat
       c~endat
  INTO TABLE t_output
  FROM ( zheempl AS l
  INNER JOIN zhealoc
  AS c ON lempid = cempid )
  WHERE project in s_proj
  AND   endat > p_date.
   ENDIF.
  wa_fieldcat-col_pos = '1'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'EMPID'.
  wa_fieldcat-seltext_m = 'Employee ID'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '2'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'NAME1'.
  wa_fieldcat-seltext_m = 'Name 1'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '3'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'ROLE'.
  wa_fieldcat-seltext_m = 'Role of employee in the project'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '4'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'STDAT'.
  wa_fieldcat-seltext_m = 'Start Date'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '5'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'ENDAT'.
  wa_fieldcat-seltext_m = 'End Date'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '6'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'GRADE'.
  wa_fieldcat-seltext_m = 'Salary Level'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '7'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'PU'.
  wa_fieldcat-seltext_m = 'Department Number'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '8'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'LOCATION'.
  wa_fieldcat-seltext_m = 'Work Location'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  t_layout-no_input = 'X'.
  t_layout-colwidth_optimize = 'x'.
  t_layout-info_fieldname = 'LINE_COLOR'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
    I_INTERFACE_CHECK                 = ' '
    I_BYPASSING_BUFFER                = ' '
    I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                = SY-REPID
     i_callback_top_of_page            = 'TOP'
     is_layout                         = t_layout
     IT_FIELDCAT                       = T_FIELDCAT
     i_save                            = 'X'
    TABLES
      t_outtab                          = T_OUTPUT
  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 top.
  Refresh it_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Requestor'.
  wa_top-info = sy-uname.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Program'.
  wa_top-info = sy-repid.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Page'.
  wa_top-info = sy-pagno.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Date'.
  wa_top-info = sy-datum.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'H'.
  wa_top-info = 'Project Details'.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top.
  ENDFORM.

{ REPORT  ZPROJ_ALL_DETAILS.
TYPE-POOLS: SLIS.
Tables: zheempl,zhealoc,zheproj,zheskil.
types: begin of ty_zheempl,
      empid like zheempl-empid,
      grade like zheempl-grade,
      location like zheempl-location,
      pu like zheempl-pu,
      name1 like zheempl-name1,
      end of ty_zheempl.
types: begin of ty_zhealoc,
      project like zhealoc-project,
      stdat like zhealoc-stdat,
      endat like zhealoc-endat,
      role like zhealoc-role,
      end of ty_zhealoc.
types: begin of ty_output,
      empid like zheempl-empid,
      grade like zheempl-grade,
      location like zheempl-location,
      pu    like zheempl-pu,
      name1 like zheempl-name1,
      role like zhealoc-role,
      stdat like zhealoc-stdat,
      endat like zhealoc-endat,
      cellcolor(4) type c,
      end of ty_output.
data: t_zheempl type standard table of ty_zheempl,
      t_zhealoc type standard table of ty_zhealoc,
      t_output type standard table of ty_output with header line,
      t_output1 type standard table of ty_output with header line.
data: wa_zheempl type ty_zheempl,
      wa_zhealoc type ty_zhealoc,
      wa_output type ty_output,
      wa_output1 type ty_output.
DATA : T_FIELDCAT TYPE slis_t_fieldcat_alv.
Data : wa_fieldcat type slis_fieldcat_alv.
Data: it_top TYPE slis_t_listheader,
      wa_top TYPE slis_listheader.
Data: t_cellcolor TYPE lvc_t_scol WITH HEADER LINE,
      wa_cellcolor TYPE lvc_s_scol.
Data: t_layout TYPE slis_layout_alv.
*selection-screen
selection-screen: begin of block b1 with frame title text-001.
select-options: s_proj for wa_zhealoc-project,
                s_empid   for wa_zheempl-empid.
parameters:     p_date like sy-datum obligatory.
selection-screen: end of block b1.
selection-screen: begin of block b2 with frame title text-002.
parameters:      p_prtosr  radiobutton group g1 default 'X',
                 p_prusly  radiobutton group g1.
selection-screen: end of block b2.
selection-screen: begin of block b3 with frame title text-003.
parameters:      p_dwtodk as checkbox default 'X'.
selection-screen: end of block b3.
selection-screen: begin of block b4 with frame title text-004.
parameters:      p_shwhis as checkbox default 'X'.
selection-screen: end of block b4.
Start-of-selection
  IF p_shwhis = 'X'.
SELECT l~empid
       l~grade
       l~location
       l~pu
       l~name1
       c~role
       c~stdat
       c~endat
  INTO TABLE t_output
  FROM ( zheempl AS l
  INNER JOIN zhealoc
  AS c ON lempid = cempid )
  where project IN s_proj
  AND endat < p_date
  OR endat > p_date.
   t_output-cellcolor = 'C310'.
   MODIFY t_output transporting cellcolor where endat < p_date.
  ELSE.
  select l~empid
       l~grade
       l~location
       l~pu
       l~name1
       c~role
       c~stdat
       c~endat
  INTO TABLE t_output
  FROM ( zheempl AS l
  INNER JOIN zhealoc
  AS c ON lempid = cempid )
  WHERE project in s_proj
  AND   endat > p_date.
   ENDIF.
  wa_fieldcat-col_pos = '1'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'EMPID'.
  wa_fieldcat-seltext_m = 'Employee ID'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '2'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'NAME1'.
  wa_fieldcat-seltext_m = 'Name 1'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '3'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'ROLE'.
  wa_fieldcat-seltext_m = 'Role of employee in the project'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '4'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'STDAT'.
  wa_fieldcat-seltext_m = 'Start Date'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '5'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'ENDAT'.
  wa_fieldcat-seltext_m = 'End Date'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '6'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'GRADE'.
  wa_fieldcat-seltext_m = 'Salary Level'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '7'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'PU'.
  wa_fieldcat-seltext_m = 'Department Number'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  wa_fieldcat-col_pos = '8'.
  wa_fieldcat-tabname = 't_output'.
  wa_fieldcat-fieldname = 'LOCATION'.
  wa_fieldcat-seltext_m = 'Work Location'.
  wa_fieldcat-hotspot = 'X'.
  APPEND wa_fieldcat to t_fieldcat.
  CLEAR wa_fieldcat.
  t_layout-no_input = 'X'.
  t_layout-colwidth_optimize = 'x'.
  t_layout-info_fieldname = 'LINE_COLOR'.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
    I_INTERFACE_CHECK                 = ' '
    I_BYPASSING_BUFFER                = ' '
    I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                = SY-REPID
     i_callback_top_of_page            = 'TOP'
     is_layout                         = t_layout
     IT_FIELDCAT                       = T_FIELDCAT
     i_save                            = 'X'
    TABLES
      t_outtab                          = T_OUTPUT
  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 top.
  Refresh it_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Requestor'.
  wa_top-info = sy-uname.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Program'.
  wa_top-info = sy-repid.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Page'.
  wa_top-info = sy-pagno.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'S'.
  wa_top-key = 'Date'.
  wa_top-info = sy-datum.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  wa_top-typ = 'H'.
  wa_top-info = 'Project Details'.
  APPEND wa_top to it_top.
  CLEAR wa_top.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary       = it_top.
  ENDFORM.}

Similar Messages

  • Select  mutiple rows in ALV report output

    Hi All,
    I want to select the Multiple records i in ALV report output with out holding the CNTL(Control Key).
    Is there any options in Layout?
    Please let me know
    regards,
    Ajay
    Edited by: Ajay reddy on May 30, 2010 3:27 PM

    Hi Ajay,
    To select several rows without Control button, if the rows are adjacent:
    - select the first and the last of the desired rows with Shift button pressed
    or
    - select a row, keep the mouse button pressed, and pass over the desired rows
    I don't know an option without Control if the rows are not adjacent.
    http://help.sap.com/saphelp_bw/helpdata/en/d1/7d9d37664e4d45e10000009b38f8cf/content.htm
    Regards,
    Paulo Carvalho

  • Adding/Enabling Totals & Subtotals Button in ALV Report Output

    Hi Guys,
    I would like to know , how to add / enable Totals & Subtotals Button on the application tool bar in alv report output.
    Regards,
    Kishan

    ok so here i am sending my code....its also interactive...
    and in second list i am displaying quantity....
    *& Report  ZINT_ALV
    REPORT  zint_alv.
    TYPE-POOLS:slis.
    TABLES:mara,
           makt,
           mseg.
    DATA:BEGIN OF itab OCCURS 0,
          matnr LIKE mara-matnr,
          maktx LIKE makt-maktx,
         END OF itab.
    DATA:BEGIN OF itab1 OCCURS 0,
          mblnr LIKE mseg-mblnr,
          menge LIKE mseg-menge,
          meins LIKE mseg-meins,
          werks LIKE mseg-werks,
         END OF itab1.
    DATA:fcat TYPE slis_t_fieldcat_alv,
         fcat1 TYPE slis_t_fieldcat_alv,
         eve TYPE slis_t_event,
         eve1 TYPE slis_t_event.
    DATA:t_mat LIKE mara-matnr,
         s_mat LIKE mara-matnr,
         g_repid LIKE sy-repid.
    SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:mat FOR mara-matnr OBLIGATORY.
    SELECTION-SCREEN:END OF BLOCK blk1.
    INITIALIZATION.
      PERFORM build_fcat USING fcat.
      PERFORM build_eve.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM dis_data.
    *&      Form  build_fcat
          text
         -->T_FCAT     text
    FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat TYPE slis_fieldcat_alv.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-ref_fieldname = 'MATNR'.
      wa_fcat-ref_tabname = 'MARA'.
      wa_fcat-seltext_m = 'Material'.
    wa_fcat-input = ' '.
    wa_fcat-edit = 'X'.
      wa_fcat-input = 'X'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Description'.
      APPEND wa_fcat TO t_fcat.
      CLEAR wa_fcat.
    ENDFORM.                    "build_fcat
    *&      Form  build_eve
          text
    FORM build_eve.
      DATA:t_eve TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type           = 0
       IMPORTING
         et_events             = eve
    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.
    ENDFORM.                    "build_eve
    *&      Form  get_data
          text
    FORM get_data.
      SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt
      ON maramatnr = maktmatnr
      WHERE mara~matnr IN mat.
    ENDFORM.                    "get_data
    *&      Form  dis_data
          text
    FORM dis_data.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid         "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND'
         i_grid_title                      = 'Interactive ALV'
         it_fieldcat                       = fcat
         it_events                         = eve
        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.
    ENDFORM.                    "dis_data
    *&      Form  user_command
          text
         -->U_COM      text
    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.
      CLEAR fcat1.
      CASE u_com.
        WHEN '&IC1'.
          READ TABLE itab INDEX sel_field-tabindex.
          IF sel_field-fieldname = 'MATNR'.
            IF sy-subrc = 0.
              t_mat = itab-matnr.
              PERFORM build_cat1 USING fcat1.
              PERFORM build_eve1.
              PERFORM get_data1.
              PERFORM dis_data1.
            ENDIF.
          ENDIF.
         SET PARAMETER ID 'MAT' FIELD t_mat.
         CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  build_fcat1
          text
         -->T_FCAT1    text
    FORM build_cat1 USING t_fcat1 TYPE slis_t_fieldcat_alv.
      DATA:wa_fcat1 TYPE slis_fieldcat_alv.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MBLNR'.
      wa_fcat1-seltext_m = 'Material Doc.'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MENGE'.
      wa_fcat1-seltext_m = 'Quantity'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'MEINS'.
      wa_fcat1-seltext_m = 'UOM'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
      wa_fcat1-tabname = 'ITAB1'.
      wa_fcat1-fieldname = 'WERKS'.
      wa_fcat1-seltext_m = 'Plant'.
      APPEND wa_fcat1 TO t_fcat1.
      CLEAR wa_fcat1.
    ENDFORM.                    "build_fcat1
    *&      Form  build_eve1
          text
    FORM build_eve1.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = eve1
        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.
    ENDFORM.                                                    "build_eve1
    *&      Form  get_data1
          text
    FORM get_data1.
      SELECT mblnr menge meins werks FROM mseg
      INTO CORRESPONDING FIELDS OF TABLE itab1
      WHERE matnr = t_mat.
    ENDFORM.                                                    "get_data1
    *&      Form  dis_data1
          text
    FORM dis_data1.
      g_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = g_repid              "'ZINT_ALV'
         i_callback_user_command           = 'USER_COMMAND1'
         it_fieldcat                       = fcat1
         it_events                         = eve1
        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.
    ENDFORM.                                                    "dis_data1

  • Adding color to a row in alv grid not using object oriented.

    Hello Gurus.
    I want to display a row in  color in alv grid using normal alv,  not by using object oriented programming.
    I am having one of the field say spart ie division in internal table itab.
    The spart has values like 12 , 45, 67, 68 ,88 ,99.
    when ever spart is 12 i want to display that row in color format. Here this table is sorted by mblnr so if 1st record is 12 then may be 50 th record will be 12. so when where the record contains the value has 12 then that row should be displayed in color. So please tell me how to do it. Previously i posted the same question but i got is by using object oriented. so please tell me how to do it without using object oriented.
    Thanks for all the replies.

    Check this example code.
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          mtart type mara-mtart,
          maktx type makt-maktx,
          color_line(4) type c,
          tcolor type slis_t_specialcol_alv,  "cell
          end of imara.
    data: xcolor type slis_specialcol_alv.
    start-of-selection.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      imara-matnr = 'ABC'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for ABC'.
      append imara.
      imara-matnr = 'DEF'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for DEF'.
      append imara.
      imara-matnr = 'GHI'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for GHI'.
      append imara.
      loop at imara.
        if sy-tabix = 1.
          imara-color_line = 'C410'.   " color line
        endif.
        if sy-tabix = 2.          "color CELL
          clear xcolor.
          xcolor-fieldname = 'MTART'.
          xcolor-color-col = '3'.
          xcolor-color-int = '1'. "Intensified on/off
          xcolor-color-inv = '0'.
          append xcolor to imara-tcolor.
        endif.
        modify imara.
      endloop.
    endform.
    *  WRITE_REPORT
    form write_report.
      data: layout type  slis_layout_alv.
      layout-coltab_fieldname = 'TCOLOR'.
      layout-info_fieldname = 'COLOR_LINE'.
      perform build_field_catalog.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = layout
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Type'.
      fc_tmp-fieldname  = 'MTART'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-emphasize = 'C610'.   " color column
      append fc_tmp to fieldcat.
    endform.
    Regards,
    Rich Heilman

  • Deleting rows in alv report.

    Hi Experts,
                I want to delete a row in alv report output, It is duplicating  records in the report  and 'GRAND TOTAL' also be displayed . In under the report . <<removed_by_moderator>>
    Thanks,
    Dinesh.B
    Edited by: Vijay Babu Dudla on May 11, 2009 9:15 AM

    Hi,
    use the following code for deleting duplicate and adjacent records from itab
    delete ADJACENT DUPLICATES FROM itab.
    or
    sort itab by pernr.
    delete ADJACENT DUPLICATE FROM itab COMPARING pernr.
    Also, for grand total you can use fieldcat-do_sum    =  'X'  with the field catalog. It will give you total for the required column.
    Hope this solves your problem.
    Regards,
    Ibrar Munsif.

  • To add/delete the rows in ALV report outpout

    Hi,
    Is there any way by which we can  add/delete the rows in ALV report output.
    Thanks
    Ankul

    Hi,
    Try out this way:
    data: i_modified TYPE STANDARD TABLE OF mara,"For getting modified rows
            w_modified TYPE mara.
    CASE e_ucomm.
          WHEN 'EDIT'.
          perform save_database.
          CALL METHOD ref_GRID->REFRESH_TABLE_DISPLAY.
        ENDCASE.
    FORM SAVE_DATABASE .
    data: i_selected_rows TYPE lvc_t_row,                "Selected Rows
          w_selected_rows TYPE lvc_s_row.
    * Getting the selected rows index
        CALL METHOD ref_grid->get_selected_rows
                    IMPORTING  et_index_rows = i_selected_rows.
    * Through the index capturing the values of selected rows
        LOOP AT i_selected_rows INTO w_selected_rows.
        READ TABLE it_tab INTO wa_it_tab INDEX w_selected_rows-index.
        IF sy-subrc EQ 0.
          MOVE-CORRESPONDING wa_it_tab TO w_modified.
          APPEND w_modified TO i_modified.
        ENDIF.
      ENDLOOP.
      MODIFY mara FROM TABLE i_modified.
    Thanks,
    Krishna

  • Coloring of a (specific) row in ALV report-How?

    Hi Experts,
    Am looking to assign a color for a (specific)row in ALV report.......so, pls. let me know How to get it done?
    thanq

    TABLES:LFA1.
    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    REGIO LIKE LFA1-REGIO,
    SORTL LIKE LFA1-SORTL,
    CFIELD(4) TYPE C,
    END OF ITAB.
    data:col(4).
    data:num value '1'.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
    IN LIFNR.
    LOOP AT ITAB.
    concatenate 'C' num '10' into col .
    ITAB-CFIELD = col.
    num = num + 1.
    if num = '8'.
    num = '1'.
    endif.
    MODIFY ITAB.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA:SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE.
    DATA:EVE TYPE SLIS_T_EVENT WITH HEADER LINE.
    LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
    LAYOUT-WINDOW_TITLEBAR = 'VENDORS DETAILS SCREEN'.
    LAYOUT-EDIT = 'X'.
    LAYOUT-info_fieldname = 'CFIELD'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    this is for coloring cols
    REPORT ZBHCOLOR_COLS.
    TABLES:LFA1.
    SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY
    PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',
    GRID RADIOBUTTON GROUP ALV.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    SORTL LIKE LFA1-SORTL,
    REGIO LIKE LFA1-REGIO,
    COL TYPE LVC_T_SCOL,
    END OF ITAB.
    DATA:COLR TYPE LVC_S_SCOL.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.
    LOOP AT ITAB.
    IF ITAB-LIFNR IN C_LIFNR.
    COLR-FNAME = 'NAME1'.
    COLR-COLOR-COL = '5'.
    COLR-COLOR-INT = '1'.
    COLR-COLOR-INV = '0'.
    COLR-NOKEYCOL = 'X'.
    APPEND COLR TO ITAB-COL.
    COLR-FNAME = 'LIFNR'.
    APPEND COLR TO ITAB-COL.
    MODIFY ITAB.
    ENDIF.
    ENDLOOP.
    TYPE-POOLS:SLIS.
    DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.
    LAYOUT-ZEBRA = 'X'.
    layout-coltab_fieldname = 'COL'.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    I_INCLNAME = SY-REPID
    CHANGING
    CT_FIELDCAT = FCAT.
    IF LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ELSEIF GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    TABLES
    T_OUTTAB = ITAB.
    ENDIF.
    Reward points if useful.

  • Color in certain row to ALV

    How to put color in certain  row to ALV grid report.
    Kindly help.
    Thanks..
    Moderator Message: FAQ.
    Edited by: kishan P on Nov 20, 2010 7:37 PM

    Hi
    A) You need to define a new field for color in your output table: this field has to be a CHAR 3
    B) In layout structure you need to indicate the name of the field for color: IS_LAYOUT-INFO_FIELDNAME = <field for color>
    C) While populating the output table you need to set the color attribute in the field for color:
    ITAB-COLOR = 'Cxy'.
    C is a constant (the value has to start wiht C)
    x is the color number (from 1 to 9, see the SAP help)
    y is Intensified (0 = off 1 = on)
    Max
    Moderator Message: Please do not answer basic and Frequently asked question.
    Edited by: kishan P on Nov 20, 2010 7:38 PM

  • Single row in alv report

    Hi experts...
    I want single row in alv report.
    I have use loop for fatch data into internal table using loop when i am passing data in alv report then the data comes according loop. i want onlu one data in alv row.
    how can i do such, plz help me.

    decleare two internal table.
    read table itab into  wa index  1.
    append wa to itab2.
    pass itab2 only one record display.

  • How to select multiple row in ALV report

    Hi friends,
    1. How to select multiple row in ALV report
                   ( How to set tab in ALV report and want to select multiple line.)
    Thanking you.
    Subash

    Hi Sahoo,
    If you are using the class CL_GUI_ALV_GRID. In methods SET_TABLE_FOR_FIRST_DISPLAY.
    in layout structure you will find field SEL_MODE
    pass :
    LS_LAYOUT-SEL_MODE = 'A'.
    In PAI.
      CALL METHOD GRID->GET_SELECTED_ROWS
        IMPORTING
          ET_INDEX_ROWS = T_ROWS
          ET_ROW_NO     = T_ROWID.
    Hope these will solve your problem.
    Regards,
    Kumar M.

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

  • How to apply List box for multiple selection of rows  in ALV report ?

    Hi Exprots,
    1: How to apply List box for multiple selection of rows  in ALV report ?
    Thanking you.
    Subash

    hi,
    check the below program.
    REPORT zalv_dropdowns.
    *Type pools declarations for ALV
    TYPE-POOLS : slis.
    *data declarations for ALV container,ALV grid, Fieldcatalogues & layout
    DATA: g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gt_fieldcat TYPE lvc_t_fcat,
          gs_layout TYPE lvc_s_layo.*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
    DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
          wa_outtab TYPE t517a.
    START-OF-SELECTION.*Call to ALV
      CALL SCREEN 600.*On this statement double click  it takes you to the screen painter SE51.
    *Create a Custom container and name it CCONT and OK code as OK_CODE.
    *Save check and Activate the screen painter.
    *Now a normal screen with number 600 is created which holds the ALV grid.
    PBO of the actual screen , Here we can give a title and customized menus
    Here we also call the subroutine for ALV output.
          MODULE PBO OUTPUT                                             *
    MODULE pbo OUTPUT.
      PERFORM alv_output.
    ENDMODULE.                    "pbo OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
    ENDMODULE.                    "pai INPUT
    *&      Form  BUILD_FIELDCAT
    FORM build_fieldcat.
    DATA ls_fcat TYPE lvc_s_fcat.
    *Build the field catalogue
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'T517A'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    To assign dropdown in the fieldcataogue
      LOOP AT gt_fieldcat INTO ls_fcat.   
    CASE ls_fcat-fieldname.
       WHEN 'SLART'.
    *is the first list box
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.
    is the second list box    
    WHEN 'ABART'.       
            ls_fcat-drdn_hndl = '2'.
            ls_fcat-outputlen = 15.
            MODIFY gt_fieldcat FROM ls_fcat.   
    ENDCASE.
      ENDLOOP.
    ENDFORM.                    "build_fieldcat
    *&      Form  ALV_OUTPUT
    FORM alv_output .*Create object for container
      CREATE OBJECT g_custom_container
             EXPORTING container_name = 'CCONT'.
    *create object for grid
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Build fieldcat and set column
    *Assign a handle for the dropdown listbox.
      PERFORM build_fieldcat.
    *Build layout
      PERFORM build_layout.
    Define a drop down table.
      PERFORM dropdown_table.
    *fetch values from the T517A table
      SELECT * FROM t517a INTO TABLE gt_outtab.
    *Display ALV output
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = gs_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = gt_outtab.ENDFORM.                               "ALV_OUTPUT
    *&      Form  dropdown_table
          text
    -->  p1        text
    <--  p2        text
    FORM dropdown_table.*Declarations for drop down lists in ALV.
      DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
    First SLART listbox (handle '1').
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 Primary school'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 Lower Secondary'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '1'.
      ls_dropdown-value = '03 Upper Secondary'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '04 Professional School'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '05 College'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '06 University'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '09 Other Establishment'.
      APPEND ls_dropdown TO lt_dropdown.* Second ABART listbox (handle '2').  ls_dropdown-handle = '2'.
      ls_dropdown-value = '10 Primary School certificate'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '20 Lower secondary/Junior high'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '30 High school diploma(B-levels)'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '2'.
      ls_dropdown-value = '31 Vocational'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '32 Matriculation'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '40 Specialist vocational certificate'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '50 College degree Level1'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '51 College degree Level2'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '52 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '60 Univ Degree level1'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '61 Bachelors degree'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '62 Masters degree'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '63 Licenciate'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '64 Doctors Degree Ph.D'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '89 None'.
      APPEND ls_dropdown TO lt_dropdown.  ls_dropdown-handle = '2'.
      ls_dropdown-value = '90 Unknown'.
      APPEND ls_dropdown TO lt_dropdown.*method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.ENDFORM.                               " dropdown_table
    *&      Form  build_layout
          text
    *layout for ALV output
    FORM build_layout .  gs_layout-cwidth_opt = 'X'.
      gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
      gs_layout-no_toolbar = 'X'.ENDFORM.                    " build_layout
    endform.
    Edited by: S.r.v.r.Kumar on Jun 1, 2009 2:48 PM

  • Problem when dowloading the ALV report output to Excel Sheet.

    Hi ,
    I am dowloading the ALV report output to Excel Sheet.
    There is field Condition Unit(KOMP-KMEIN) in the output of the ALV, this has values PC and CSE , but when I download to Excel Sheet, CSE is appearing as CSE ,but PC is appearing as ******.
    Can you please help me in knowing the reson for this.
    Regards,
    Madhu.

    hi
    refer to following link
    http://www.****************/Tutorials/ALV/ColorSALV/Demo.htm
    http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm
    Cheers
    Snehi
    Edited by: snehi chouhan on Jul 11, 2008 12:42 PM

  • Mailing ALV report OUTPUT

    Hi Experts,
    Can you give an example program on mailing ALV report output to any ID.
    Thanks in advance.
    Regards,
    Ram

    Hi ram
    Here i'm posting u sample code try to execute it. It will convert all the data in the related tables to excel format and transfer it to respective mail id
    *& Report  ZTESTMAIL                                                   *
    REPORT  ZTESTMAIL                               .
    tables: ekko.
    parameters: p_email type somlreci1-receiver default
    '[email protected]'.
    types: begin of t_ekpo,
    ebeln type ekpo-ebeln,
    ebelp type ekpo-ebelp,
    aedat type ekpo-aedat,
    matnr type ekpo-matnr,
    end of t_ekpo.
    data: it_ekpo type standard table of t_ekpo initial size 0,
    wa_ekpo type t_ekpo.
    types: begin of t_charekpo,
    ebeln(10) type c,
    ebelp(5) type c,
    aedat(8) type c,
    matnr(18) type c,
    end of t_charekpo.
    data: wa_charekpo type t_charekpo.
    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.
    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.
    t_object_header = 'Text.xls'. append t_object_header.
    *START_OF_SELECTION
    start-of-selection.
    * Retrieve sample data from table ekpo
    perform data_retrieval.
    * Populate table with detaisl to be entered into .xls file
    perform build_xls_data_table.
    *END-OF-SELECTION
    end-of-selection.
    * Populate message body text
    perform populate_email_message_body.
    * Send file by email as .xls speadsheet
    perform send_file_as_email_attachment
    tables it_message
    it_attach
    using p_email
    'Example .xls documnet attachment'
    'XLS'
    'filename'
    changing gd_error
    gd_reciever.
    * Instructs mail send program for SAPCONNECT to send email(rsconn01)
    perform initiate_mail_execute_program.
    *& Form DATA_RETRIEVAL
    * Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp aedat matnr
    up to 10 rows
    from ekpo
    into table it_ekpo.
    endform. " DATA_RETRIEVAL
    *& Form BUILD_XLS_DATA_TABLE
    * Build data table for .xls document
    form build_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 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    loop at it_ekpo into wa_charekpo.
    concatenate wa_charekpo-ebeln wa_charekpo-ebelp
    wa_charekpo-aedat wa_charekpo-matnr
    into it_attach separated by con_tab.
    concatenate con_cret it_attach into it_attach.
    append it_attach.
    endloop.
    endform. " BUILD_XLS_DATA_TABLE
    *& Form SEND_FILE_AS_EMAIL_ATTACHMENT
    * Send email
    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
    object_header = t_object_header
    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.
    *& 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 ekpo records'.
    append it_message.
    endform. " POPULATE_EMAIL_MESSAGE_BODY
    *PARAMETERS: psubject(40) type c default 'Testing',
    *p_email(40) type c default '[email protected]'. "use ur email id
    *data: it_packing_list like sopcklsti1 occurs 0 with header line,
    *it_contents like solisti1 occurs 0 with header line,
    *it_receivers like somlreci1 occurs 0 with header line,
    *it_attachment like solisti1 occurs 0 with header line,
    *gd_cnt type i,
    *gd_sent_all(1) type c,
    *gd_doc_data like sodocchgi1,
    *gd_error type sy-subrc.
    *data: it_message type standard table of SOLISTI1 initial size 0
    *with header line.
    **START-OF-SELECTION.
    *START-OF-SELECTION.
    *Perform populate_message_table.
    **Send email message, although is not sent from SAP until mail send
    **program has been executed(rsconn01)
    *PERFORM send_email_message.
    **Instructs mail send program for SAPCONNECT to send email(rsconn01)
    *perform initiate_mail_execute_program.
    **& Form POPULATE_MESSAGE_TABLE
    ** Adds text to email text table
    *form populate_message_table.
    *Append 'Line1' to it_message.
    *Append 'Line2' to it_message.
    *Append 'Line3' to it_message.
    *Append 'Test- 1' to it_message.
    *endform. " POPULATE_MESSAGE_TABLE
    **& Form SEND_EMAIL_MESSAGE
    ** Send email message
    *form send_email_message.
    ** Fill the document data.
    *gd_doc_data-doc_size = 1.
    ** DATA: TAB_LINES LIKE sy-tabix.
    ** DESCRIBE TABLE it_message LINES TAB_LINES.
    ** READ TABLE it_message INDEX TAB_LINES.
    ** gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
    ** Populate the subject/generic message attributes
    *gd_doc_data-obj_langu = sy-langu.
    *gd_doc_data-obj_name = 'SAPRPT'.
    *gd_doc_data-obj_descr = psubject.
    *gd_doc_data-sensitivty = 'F'.
    ** Describe the body of the message
    ** Information about structure of data tables
    *clear it_packing_list.
    *refresh it_packing_list.
    *it_packing_list-transf_bin = space.
    *it_packing_list-head_start = 1.
    *it_packing_list-head_num = 0.
    *it_packing_list-body_start = 1.
    *describe table it_message lines it_packing_list-body_num.
    *it_packing_list-doc_type = 'RAW'.
    *append it_packing_list.
    ** Add the recipients email address
    *clear it_receivers.
    *refresh it_receivers.
    *it_receivers-receiver = p_email.
    *it_receivers-rec_type = 'U'.
    ** it_receivers-com_type = 'INT'.
    ** it_receivers-notif_del = 'X'.
    ** it_receivers-notif_ndel = 'X'.
    *append it_receivers.
    ** Call the FM to post the message to SAPMAIL
    *call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    *exporting
    *document_data = gd_doc_data
    *put_in_outbox = 'X'
    *importing
    *sent_to_all = gd_sent_all
    *tables
    *packing_list = it_packing_list
    *contents_txt = it_message
    *receivers = it_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.
    ** Store function module return code
    *gd_error = sy-subrc.
    ** Get it_receivers return code
    *loop at it_receivers.
    *endloop.
    *endform. " SEND_EMAIL_MESSAGE
    **& Form INITIATE_MAIL_EXECUTE_PROGRAM
    ** Instructs mail send program for SAPCONNECT to send email.
    *form initiate_mail_execute_program.
    *wait up to 2 seconds.
    *if gd_error eq 0.
    *submit rsconn01 with mode = 'INT'
    *with output = 'X'
    *and return.
    *endif.
    *endform. " INITIATE_MAIL_EXECUTE_PROGRAM
    Rewards if helpfull
    Regards
    Pavan

  • Double Click on ALV Report Output, Bringing to selections creen

    Hello Gurus,
    Please help me When i do double click on ALV Report  output , it is going back to Selection screen, actually its working as Back button. Now how to stop it.. I did debugging but i cannot trace it.

    PERFORM SUB_CREATE_FCAT.
    DATA W_REPID LIKE SY-REPID.
        W_REPID = SY-REPID.
    ls_layout-colwidth_optimize = 'X'.
    ls_layout-zebra = 'X'.
    PERFORM SUB_SORT.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
          I_CALLBACK_PROGRAM                 = SY-CPROG
          I_CALLBACK_PF_STATUS_SET          = 'STATUS'
           I_CALLBACK_USER_COMMAND           = 'C_USERCOMMAND '
    *     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                         = ls_layout
           IT_FIELDCAT                       = IT_FIELDCAT
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
           IT_SORT                           = IT_SORT
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
    *     I_DEFAULT                         = 'X'
          I_SAVE                            = 'U'
    *     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                          = T_FINAL
    *   EXCEPTIONS
    *     PROGRAM_ERROR                     = 1
    *     OTHERS                            = 2
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.

Maybe you are looking for