CL_SALV_PRINT

Hi,
I have a report with CL_SALV_TABLE. This report displays data and some header. Problem is, when user removes some extra columns from ALV, ALV row has less then 80 characters to display/print. But still header remains the same, 120 characters long. But when user prints ALV or print preview, header is shortened to 80 chars. how to solve this? I tried with CL_SALV_PRINT and various methods, but no luck.
thx
mario

Hi,
I have the same issue. It doesn't work correctly no matter what I do.
According to demo program BCALV_TEST_NPPON_1, the value of set_print_only could be the following:
'space = Online, no %_print, &prnt-Fcode'.
'N=Immed. print, incl. %_print, w/o print dialog'.
'X=Immed. print, no %_print, with print dialog'.
'P=prog.,Online, incl. %_print, &prnt-Fcode'.
It is a little confusing, just a quick translation from German, which may not be totally correct. Using the value "N" you can get rid of the dialog screen. But even doing so, it is not creating a spool request for me.
According to SAP Press book ABAP Objects, the set_print_control method will work only at a later release with a certain patch level, which could be an explanation. However we have the very latest release and it still doesn't work.

Similar Messages

  • END_OF_PAGE in ALV Object model

    Dear all,
    I am using ALV Object model, but the END_OF_PAGE is not triggering. I have pasted the sample code below. Let me know how to get  END_OF_PAGE  in ALV OM.
    REPORT  ztest_rr.
    DATA : it_sflight TYPE TABLE OF sflight.
    DATA : gr_sflight TYPE REF TO cl_salv_table,
           gr_content TYPE REF TO cl_salv_form_element,
           gr_sorts   TYPE REF TO cl_salv_sorts,
           gr_events  TYPE REF TO cl_salv_events,
           gr_print   TYPE REF TO cl_salv_print.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_top_of_page FOR EVENT
              top_of_page OF cl_salv_events
              IMPORTING
              page
              table_index
              r_top_of_page,
          handle_end_of_page FOR EVENT
              end_of_page OF cl_salv_events
              IMPORTING
              page
              r_end_of_page.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    DATA : gr_handler TYPE REF TO lcl_eventhandler.
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_top_of_page.
        PERFORM create_alv_form_content_top
          USING    page
                   table_index
          CHANGING gr_content.
        r_top_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_top_of_page
      METHOD handle_end_of_page.
        PERFORM create_alv_form_content_eop
        USING    page
        CHANGING gr_content.
        r_end_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_end_of_page
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT *
      FROM sflight
      INTO TABLE it_sflight.
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>true
       r_container    =
       container_name =
            IMPORTING
              r_salv_table   = gr_sflight
            CHANGING
              t_table        = it_sflight
        CATCH cx_salv_msg .
      ENDTRY.
      CALL METHOD gr_sflight->get_sorts
        RECEIVING
          value = gr_sorts.
      CALL METHOD gr_sorts->set_group_active
        EXPORTING
          value = if_salv_c_bool_sap=>true.
      TRY.
          CALL METHOD gr_sorts->add_sort
            EXPORTING
              columnname = 'CARRID'
       position   =
       sequence   = IF_SALV_C_SORT=>SORT_UP
       subtotal   = IF_SALV_C_BOOL_SAP=>FALSE
               group      = if_salv_c_sort=>group_with_newpage
       obligatory = IF_SALV_C_BOOL_SAP=>FALSE
    receiving
       value      =
        CATCH cx_salv_not_found .
        CATCH cx_salv_existing .
        CATCH cx_salv_data_error .
      ENDTRY.
      CALL METHOD gr_sflight->get_event
        RECEIVING
          value = gr_events.
      CALL METHOD gr_sflight->get_print
        RECEIVING
          value = gr_print.
      CALL METHOD gr_print->set_reserve_lines
        EXPORTING
          value = 5.
      CREATE OBJECT gr_handler.
      SET HANDLER gr_handler->handle_top_of_page FOR gr_events.
      SET HANDLER gr_handler->handle_end_of_page FOR gr_events.
      CALL METHOD gr_sflight->display
    *&      Form  CREATE_ALV_FORM_CONTENT_TOP
          text
         -->P_PAGE  text
         -->P_TABLE_INDEX  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_top  USING    l_page
                                               l_table_index
                                      CHANGING lr_content.
      WRITE 'HAI'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_TOP
    *&      Form  CREATE_ALV_FORM_CONTENT_EOP
          text
         -->P_PAGE  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_eop  USING    l_page
                                      CHANGING lr_content.
      WRITE 'BYE'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_EOP

    Dear all,
    I am using ALV Object model, but the END_OF_PAGE is not triggering. I have pasted the sample code below. Let me know how to get  END_OF_PAGE  in ALV OM.
    REPORT  ztest_rr.
    DATA : it_sflight TYPE TABLE OF sflight.
    DATA : gr_sflight TYPE REF TO cl_salv_table,
           gr_content TYPE REF TO cl_salv_form_element,
           gr_sorts   TYPE REF TO cl_salv_sorts,
           gr_events  TYPE REF TO cl_salv_events,
           gr_print   TYPE REF TO cl_salv_print.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_top_of_page FOR EVENT
              top_of_page OF cl_salv_events
              IMPORTING
              page
              table_index
              r_top_of_page,
          handle_end_of_page FOR EVENT
              end_of_page OF cl_salv_events
              IMPORTING
              page
              r_end_of_page.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    DATA : gr_handler TYPE REF TO lcl_eventhandler.
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_top_of_page.
        PERFORM create_alv_form_content_top
          USING    page
                   table_index
          CHANGING gr_content.
        r_top_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_top_of_page
      METHOD handle_end_of_page.
        PERFORM create_alv_form_content_eop
        USING    page
        CHANGING gr_content.
        r_end_of_page->set_content( gr_content ).
      ENDMETHOD.                    "handle_end_of_page
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT *
      FROM sflight
      INTO TABLE it_sflight.
      TRY.
          CALL METHOD cl_salv_table=>factory
            EXPORTING
              list_display   = if_salv_c_bool_sap=>true
       r_container    =
       container_name =
            IMPORTING
              r_salv_table   = gr_sflight
            CHANGING
              t_table        = it_sflight
        CATCH cx_salv_msg .
      ENDTRY.
      CALL METHOD gr_sflight->get_sorts
        RECEIVING
          value = gr_sorts.
      CALL METHOD gr_sorts->set_group_active
        EXPORTING
          value = if_salv_c_bool_sap=>true.
      TRY.
          CALL METHOD gr_sorts->add_sort
            EXPORTING
              columnname = 'CARRID'
       position   =
       sequence   = IF_SALV_C_SORT=>SORT_UP
       subtotal   = IF_SALV_C_BOOL_SAP=>FALSE
               group      = if_salv_c_sort=>group_with_newpage
       obligatory = IF_SALV_C_BOOL_SAP=>FALSE
    receiving
       value      =
        CATCH cx_salv_not_found .
        CATCH cx_salv_existing .
        CATCH cx_salv_data_error .
      ENDTRY.
      CALL METHOD gr_sflight->get_event
        RECEIVING
          value = gr_events.
      CALL METHOD gr_sflight->get_print
        RECEIVING
          value = gr_print.
      CALL METHOD gr_print->set_reserve_lines
        EXPORTING
          value = 5.
      CREATE OBJECT gr_handler.
      SET HANDLER gr_handler->handle_top_of_page FOR gr_events.
      SET HANDLER gr_handler->handle_end_of_page FOR gr_events.
      CALL METHOD gr_sflight->display
    *&      Form  CREATE_ALV_FORM_CONTENT_TOP
          text
         -->P_PAGE  text
         -->P_TABLE_INDEX  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_top  USING    l_page
                                               l_table_index
                                      CHANGING lr_content.
      WRITE 'HAI'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_TOP
    *&      Form  CREATE_ALV_FORM_CONTENT_EOP
          text
         -->P_PAGE  text
         <--P_GR_CONTENT  text
    FORM create_alv_form_content_eop  USING    l_page
                                      CHANGING lr_content.
      WRITE 'BYE'.
    ENDFORM.                    " CREATE_ALV_FORM_CONTENT_EOP

  • Hiding columns in ALV Grid output

    Hi all,
    Please find below my piece of code. I want to hide couple of columns in the grid output. Could you please tell me how to achieve it.
      DATA: gr_alv        TYPE REF TO cl_salv_table,
            lr_display    TYPE REF TO cl_salv_display_settings,
            lr_columns    TYPE REF TO cl_salv_columns_table,
            lr_column     TYPE REF TO cl_salv_column_table,
            lr_functions  TYPE REF TO cl_salv_functions_list,
            lr_sorts      TYPE REF TO cl_salv_sorts,
            lr_print      TYPE REF TO cl_salv_print,
            lr_column_f   TYPE REF TO cl_salv_columns,
            gr_error      TYPE REF TO cx_salv_not_found ,
            lr_event      TYPE REF TO cl_salv_events_table,
            lr_handler    TYPE REF TO znew_gc_event_handler,
            lr_layout     TYPE REF TO cl_salv_layout.
      DATA: key     TYPE salv_s_layout_key,
            gr_msg  TYPE string.
      TRY.
    * Create ALV instance - use CALL METHOD since this is a static method
          CALL METHOD cl_salv_table=>factory
            IMPORTING
              r_salv_table = gr_alv
            CHANGING
              t_table      = lt_to_header.
          lr_display = gr_alv->get_display_settings( ).
          lr_display->set_list_header( text-ttl ).
    * Get functions object and then set all the functions to be allowed
          lr_functions = gr_alv->get_functions( ).
          lr_functions->set_all( ).
          DATA: lv_field TYPE lvc_fname.
    * Get column settings object and then optimize the column widths to the
    * data
          lr_columns = gr_alv->get_columns( ).
          lr_columns->set_optimize( ).
    *--- set column header for custom field Todays Date
          TRY.
              lr_column ?= lr_columns->get_column( 'ZZDATE' ).
              lr_column->set_output_length('12').
              lr_column->set_long_text( 'Todays Date' ).
            CATCH cx_salv_not_found INTO gr_error.
              gr_msg = gr_error->get_text( ).
              MESSAGE gr_msg TYPE 'I'.
          ENDTRY.
    *--- set column header for custom field Age of Open
          TRY.
              lr_column ?= lr_columns->get_column( 'ZZ_AGE_OF_OPEN' ).
              lr_column->set_output_length('12').
              lr_column->set_long_text( 'Age of Open' ).
            CATCH cx_salv_not_found INTO gr_error.
              gr_msg = gr_error->get_text( ).
              MESSAGE gr_msg TYPE 'I'.
          ENDTRY.
    *--- set column header for custom field Age when Confirmed
          TRY.
              lr_column ?= lr_columns->get_column( 'ZZ_AGE_CONFIRMED' ).
              lr_column->set_output_length('18').
              lr_column->set_long_text( 'Age when Confirmed' ).
            CATCH cx_salv_not_found INTO gr_error.
              gr_msg = gr_error->get_text( ).
              MESSAGE gr_msg TYPE 'I'.
          ENDTRY.
          lr_event = gr_alv->get_event( ).
          CREATE OBJECT lr_handler.
          SET HANDLER: lr_handler->on_double_click FOR lr_event.
    *... Set Sort
          lr_sorts = gr_alv->get_sorts( ).
    *        " Optimize the column widths for printing.
          lr_print = gr_alv->get_print( ).
          lr_print->set_print_parameters_enabled( value = 'X' ).
          lr_print->set_column_optimization( value = 'X' ).
    *--- This code is to get the layout,save the layout and display the
    *    layout
          lr_layout = gr_alv->get_layout( ).
          key-report = sy-repid.
          lr_layout->set_key( key ).
          lr_layout->set_save_restriction( cl_salv_layout=>restrict_none )
          DATA: init_layout TYPE slis_vari.
          init_layout = p_layout.
          lr_layout->set_initial_layout( init_layout ).
    *--- display report
          gr_alv->display( ).
        CATCH cx_salv_msg.
          WRITE: 'Error displaying grid! - cx_salv_msg'.
        CATCH cx_salv_not_found.
          WRITE: 'Error displaying grid! - cx_salv_not_found'.
        CATCH cx_salv_data_error.
          WRITE: 'Error displaying grid! - cx_salv_data_error'.
        CATCH cx_salv_existing.
          WRITE: 'Error displaying grid! - cx_salv_existing'.
      ENDTRY.
    Thanks,
    Salil

    HI
    THIS IS THE LOGIC
    SELECTION-SCREEN BEGIN OF BLOCK charly
                     WITH FRAME TITLE text-100.
    PARAMETERS: rb_dis RADIOBUTTON GROUP rb DEFAULT 'X'
                                      USER-COMMAND ucomm ,
                rb_hid RADIOBUTTON GROUP rb .
               P_DEL TYPE VBAK-VKGRP .
    SELECTION-SCREEN END   OF BLOCK charly.
    *SELECTION sCREEN FOR PO TABLE
    SELECTION-SCREEN BEGIN OF BLOCK b2
                     WITH FRAME TITLE v_text.
    SELECT-OPTIONS : s_xblnr  FOR  zmshub-xblnr MODIF ID gr2,
                     s_bstkd   FOR  zmshub-bstkd MODIF ID gr2,
                     s_posex   FOR  zmshub-posex_e MODIF ID gr2,
                     s_kdmat  FOR  zmshub-kdmat MODIF ID gr2.
    PARAMETERS : p_upload LIKE ibipparms-path LENGTH 90  MODIF ID gr3 ,
                 p_down LIKE ibipparms-path  DEFAULT 'C:\output_log.txt'
                                           MODIF ID gr3.
    SELECTION-SCREEN END OF BLOCK b2.
    *SELECTION sCREEN FOR  DOWNLOADING
    SELECTION-SCREEN BEGIN OF BLOCK b4
                     WITH FRAME TITLE text-105.
    PARAMETERS :
              rb_n_d_f  RADIOBUTTON GROUP rb1 DEFAULT 'X' ,
              rb_ftp   RADIOBUTTON GROUP rb1 ,
              p_f_n TYPE c LENGTH 25 DEFAULT 'FILE NAME .TXT',
              rb_ws_d  RADIOBUTTON GROUP rb1 ,
              p_dw_f_n TYPE c LENGTH 25 DEFAULT 'C:
    TEMP\FILE.TXT',
              rb_op_ds RADIOBUTTON GROUP rb1 ,
              p_log_p LIKE filename-pathintern  DEFAULT 'ZHKWEB01',
              p_pa_fn LIKE rlgrap-filename MODIF ID gr1
                     DEFAULT  '//SOME-DIR/FILE.TXT',
              rb_ob_dw    RADIOBUTTON GROUP rb1,
             p_file LIKE filename-pathintern   "logical path
                        DEFAULT 'ZHKWEB01',       "name
             p_fname LIKE rlgrap-filename MODIF ID gr1     "path &
    *filename
                     DEFAULT text-t02,             "/some-dir/file.txt
              p_f_name TYPE c LENGTH 25 DEFAULT
    SOME-SERVERNAME\SOME-DIR\SOME-FILE.TXT'.
    SELECTION-SCREEN END OF BLOCK b4.
    AT SELECTION-SCREEN OUTPUT.
      IF NOT rb_dis IS INITIAL.
        LOOP AT SCREEN.
          IF screen-group1 = 'GR3'.
            screen-invisible = 1.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT SCREEN.
          IF screen-group1 = 'GR2'.
            screen-invisible = 0.
            screen-input = 0.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.

  • Totalling the columns in ALV Grid

    Hello All,
    I have a output with amount and currencies. The problem i am facing is, the amount is in USD and in GBP and it is giving me single value. It is not splitting the USD amount from the GBP amount.
    Also, I am doing a subtotal based on material. This is the most important requirement.
    Can anybody help me out in this.
    Thanks,
    Salil
    I am giving the below piece of code if you want to refer it.
      DATA: gr_alv        TYPE REF TO cl_salv_table,
            lr_display    TYPE REF TO cl_salv_display_settings,
            lr_columns    TYPE REF TO cl_salv_columns_table,
            lr_column     TYPE REF TO cl_salv_column_table,
            lr_functions  TYPE REF TO cl_salv_functions_list,
            lr_sorts      TYPE REF TO cl_salv_sorts,
            lr_print      TYPE REF TO cl_salv_print,
            lr_column_f   TYPE REF TO cl_salv_columns,
            gr_error      TYPE REF TO cx_salv_not_found ,
            lr_layout     TYPE REF TO cl_salv_layout.
      DATA: key     TYPE salv_s_layout_key,
            gr_msg  TYPE string.
      IF NOT lt_output[] IS INITIAL.
        TRY.
    * Create ALV instance - use CALL METHOD since this is a static method
            CALL METHOD cl_salv_table=>factory
              IMPORTING
                r_salv_table = gr_alv
              CHANGING
                t_table      = lt_output.
            lr_display = gr_alv->get_display_settings( ).
            lr_display->set_list_header( text-ttl ).
    * Get functions object and then set all the functions to be allowed
            lr_functions = gr_alv->get_functions( ).
            lr_functions->set_all( ).
            DATA: lv_field TYPE lvc_fname.
    * Get column settings object and then optimize the column widths to the
    * data
            lr_columns = gr_alv->get_columns( ).
            lr_columns->set_optimize( ).
    *--- set column header for custom field Difference in Qty
            TRY.
                lr_column ?= lr_columns->get_column( 'BUCHM2' ).
                lr_column->set_output_length('12').
                lr_column->set_long_text( 'Diff Qty' ).
                lr_column->set_short_text( 'Diff Qty' ).
                lr_column->set_medium_text( 'Diff Qty' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Qty Abs
            TRY.
                lr_column ?= lr_columns->get_column( 'BUCHM3' ).
                lr_column->set_output_length('13').
                lr_column->set_long_text( 'Diff Qty(Abs)' ).
                lr_column->set_medium_text( 'Diff Qty(Abs)' ).
    *            lr_column->set_short_text( 'Diff Qty(Abs)' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Value
            TRY.
                lr_column ?= lr_columns->get_column( 'VALUE' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Value Diff' ).
                lr_column->set_medium_text( 'Value Diff' ).
                lr_column->set_short_text( 'Value Diff' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Difference in Value Abs
            TRY.
                lr_column ?= lr_columns->get_column( 'VALUE_ABS' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Value Diff(Abs)' ).
                lr_column->set_medium_text( 'Value Diff(Abs)' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Status
            TRY.
                lr_column ?= lr_columns->get_column( 'STATUS' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'PI Item Status' ).
                lr_column->set_medium_text( 'PI Item Status' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    *--- set column header for custom field Status
            TRY.
                lr_column ?= lr_columns->get_column( 'TOTAL' ).
                lr_column->set_output_length('15').
                lr_column->set_long_text( 'Total Value Diff' ).
                lr_column->set_medium_text( 'Total Value Diff' ).
              CATCH cx_salv_not_found INTO gr_error.
                gr_msg = gr_error->get_text( ).
                MESSAGE gr_msg TYPE 'I'.
            ENDTRY.
    * Optimize the column widths for printing.
            lr_print = gr_alv->get_print( ).
            lr_print->set_print_parameters_enabled( value = 'X' ).
            lr_print->set_column_optimization( value = 'X' ).
    *--- This code is to get the layout,save the layout and display the
    *    layout
            lr_layout = gr_alv->get_layout( ).
            lr_layout->set_default( cl_salv_layout=>true ).  " allow default
            key-report = sy-repid.
            lr_layout->set_key( key ).
           lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
            DATA: init_layout TYPE slis_vari.
            init_layout = p_layout.
            lr_layout->set_initial_layout( init_layout ).
    *--- display report
            gr_alv->display( ).
          CATCH cx_salv_msg.
            WRITE: 'Error displaying grid! - cx_salv_msg'.
          CATCH cx_salv_not_found.
            WRITE: 'Error displaying grid! - cx_salv_not_found'.
          CATCH cx_salv_data_error.
            WRITE: 'Error displaying grid! - cx_salv_data_error'.
          CATCH cx_salv_existing.
            WRITE: 'Error displaying grid! - cx_salv_existing'.
        ENDTRY.
      ELSE.
        MESSAGE s004.
      ENDIF.

    Can you use something like function module CONVERT_CURRENCY_BY_RATE to convert one set of currencies so all amounts are in the same currency before you display them in the ALV?
    - April King

  • How to enable the check box using cl_salv_table?

    Hi Experts,
                 what code will change for to enable the check box in the following Report program?
    REPORT  ZMA_ALV_OOPS2.
    TABLES:MARA.
    TYPES:BEGIN OF T_MARA,
          SEL   TYPE C,
          MATNR TYPE MARA-MATNR,
          WERKS TYPE MARC-WERKS,
          LGORT TYPE MARD-LGORT,
          LABST TYPE MARD-LABST,
         END OF T_MARA.
    DATA:TB_MARA TYPE STANDARD TABLE OF T_MARA,
         WA_MARA TYPE T_MARA.
    DATA: GR_TABLE TYPE REF     TO CL_SALV_TABLE.
      DATA: GR_FUNCTIONS TYPE REF TO CL_SALV_FUNCTIONS.
      DATA: GR_DISPLAY TYPE REF   TO CL_SALV_DISPLAY_SETTINGS.
      DATA: GR_COLUMNS TYPE REF   TO CL_SALV_COLUMNS_TABLE.
      DATA: GR_COLUMN TYPE REF    TO CL_SALV_COLUMN_TABLE.
      DATA: GR_SORTS TYPE REF     TO CL_SALV_SORTS.
      DATA: GR_AGG TYPE REF       TO CL_SALV_AGGREGATIONS.
      DATA: GR_FILTER TYPE REF    TO CL_SALV_FILTERS.
      DATA: GR_LAYOUT TYPE REF    TO CL_SALV_LAYOUT.
      DATA: GR_PRINT TYPE REF     TO CL_SALV_PRINT.
      DATA: GR_SELE TYPE REF      TO CL_SALV_SELECTIONS.
      DATA: GC_TRUE TYPE SAP_BOOL VALUE 'X'.
      DATA: GR_ITEM TYPE REF      TO  CL_SALV_ITEM.
      DATA: COLUMNNAME TYPE REF TO LVC_FNAME.
    top of list for CCL
      DATA: GR_CONTENT_CCL TYPE REF TO CL_SALV_FORM_ELEMENT.
      DATA: GR_COL TYPE REF TO CL_SALV_COLUMN.
      DATA: LT_SORT TYPE SALV_T_SORT_REF,
            LS_SORT TYPE SALV_S_SORT_REF,
            L_SEQUENCE TYPE SALV_DE_SORT_SEQUENCE,
            T_SORT TYPE REF TO SALV_T_SORT_REF.
      DATA: KEY TYPE SALV_S_LAYOUT_KEY.
      DATA: COLOR TYPE LVC_S_COLO.
      DATA: GR_EVENTS TYPE REF TO CL_SALV_EVENTS_TABLE.
      DATA: GR_SELECTIONS TYPE REF TO CL_SALV_SELECTIONS.
    **--Selection screen
    SELECT-OPTIONS:S_MATNR FOR MARA-MATNR.
    SELECT MATNR WERKS LGORT LABST
             FROM MARD
             INTO CORRESPONDING FIELDS OF TABLE TB_MARA
             WHERE MATNR IN S_MATNR.
    TRY.
          CALL METHOD CL_SALV_TABLE=>FACTORY
            IMPORTING
              R_SALV_TABLE = GR_TABLE
            CHANGING
              T_TABLE      = TB_MARA.
        CATCH CX_SALV_MSG.
      ENDTRY.
      GR_TABLE->SET_SCREEN_STATUS(
                  PFSTATUS = 'SALV_TABLE_STANDARD'
                  REPORT = SY-REPID
                  SET_FUNCTIONS = GR_TABLE->C_FUNCTIONS_ALL ).
    GR_FUNCTIONS = GR_TABLE->GET_FUNCTIONS( ).
      GR_FUNCTIONS->SET_ALL( ABAP_TRUE ).
      GR_DISPLAY = GR_TABLE->GET_DISPLAY_SETTINGS( ).
      GR_SELE = GR_TABLE->GET_SELECTIONS( ).
      GR_SELE->SET_SELECTION_MODE(  ).
      GR_TABLE->SET_TOP_OF_LIST( GR_CONTENT_CCL ).
    *--- To change the column headings
      GR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
      GR_COLUMNS->SET_OPTIMIZE( GC_TRUE ).
      GR_SORTS = GR_TABLE->GET_SORTS(  ).
      TRY.
          GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'SEL' )  .
          GR_COLUMN->SET_CELL_TYPE( IF_SALV_C_CELL_TYPE=>CHECKBOX ).
          GR_COLUMN->SET_LONG_TEXT( 'CHECKBOX' ).
        CATCH CX_SALV_NOT_FOUND.
      ENDTRY.
      GR_COLUMN->SET_CELL_TYPE( 6 ).
      GR_COLUMN->SET_SHORT_TEXT( 'Check Box' ).
      GR_COLUMN->SET_LONG_TEXT( 'Check Box' ).
    ******Check box edit
      TRY.
          GR_SORTS->ADD_SORT( COLUMNNAME = 'MATNR' SEQUENCE =
          IF_SALV_C_SORT=>SORT_UP ).
        CATCH CX_SALV_DATA_ERROR
              CX_SALV_NOT_FOUND
              CX_SALV_EXISTING.
      ENDTRY.
      GR_LAYOUT = GR_TABLE->GET_LAYOUT( ).
      KEY-REPORT = SY-REPID.
      GR_LAYOUT->SET_KEY( KEY ).
      GR_LAYOUT->SET_SAVE_RESTRICTION( CL_SALV_LAYOUT=>RESTRICT_NONE ).
      TRY.
          GR_COLUMN ?= GR_COLUMNS->GET_COLUMN( 'MATNR' ).
        CATCH CX_SALV_NOT_FOUND.
      ENDTRY.
      COLOR-COL = '8'.
      COLOR-INT = '0'.
      COLOR-INV = '1'.
      GR_COLUMN->SET_COLOR( COLOR ).
      GR_TABLE->DISPLAY( ).
    Thanks,
    Mahesh.

    Hi,
    You can use the method set_selection_mode to automatically show the checkbox for each row..and use the method get_selected_rows to get the rows selected..
    Check this sample report..
    TYPES: BEGIN OF type_output,
             matnr TYPE matnr,
           END OF type_output.
    DATA:lt_output   TYPE STANDARD TABLE OF type_output,
         lwa_rows    TYPE int4,
         lwa_output  TYPE type_output,
         lt_rows     TYPE salv_t_row.
    * Local declarations.
    DATA: lr_table      TYPE REF TO cl_salv_table,
          lr_selections TYPE REF TO cl_salv_selections.
    DATA: lr_columns    TYPE REF TO cl_salv_columns_table.
    START-OF-SELECTION.
    * Prepare data.
      lwa_output-matnr = 'TEST1'.APPEND lwa_output TO lt_output.
      lwa_output-matnr = 'TEST2'.APPEND lwa_output TO lt_output.
      lwa_output-matnr = 'TEST3'.APPEND lwa_output TO lt_output.
    * Call the factory method
      TRY.
          cl_salv_table=>factory(
            EXPORTING
              list_display = 'X'
            IMPORTING
              r_salv_table = lr_table
            CHANGING
              t_table      = lt_output ).
        CATCH cx_salv_msg.                                  "#EC NO_HANDLER
      ENDTRY.
    * Column selection
      lr_selections = lr_table->get_selections( ).
      lr_selections->set_selection_mode( if_salv_c_selection_mode=>row_column ).
      lr_columns = lr_table->get_columns( ).
      lr_columns->set_optimize( abap_true ).
    * Display
      lr_table->display( ).
    * Get the selected rows.
      lt_rows = lr_selections->get_selected_rows( ).
    * Display the selected rows.
      LOOP AT lt_rows INTO lwa_rows.
        READ TABLE lt_output INTO lwa_output INDEX lwa_rows.
        WRITE: / lwa_output-matnr.
      ENDLOOP.
    Thanks
    Naren

  • SALV to spool

    Hi All,
                I have developed an ALV report using SALV  (cl_salv_table=>factory) . The requirement is to download the ALV output to PDF.
    Inorder to achieve this I will have to write the output to the spool and then convert the spool to PDF.
    Please do let me know how the ALV output can be written to spool.
    Thanks,
    Maansi

    *       CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD on_user_command.
        DATA: lr_selections TYPE REF TO cl_salv_selections.
        DATA: lt_rows TYPE salv_t_row.
        DATA: ls_rows TYPE i.
        DATA: message TYPE string.
        TYPES:
           t_pripar TYPE pri_params,
           t_arcpar TYPE arc_params.
        DATA:
              gw_valid TYPE c,
              lw_print_ctrl TYPE alv_s_pctl ,
              lo_print TYPE REF TO cl_salv_print,
               gw_pparams TYPE t_pripar,
               g_spool   TYPE tsp01-rqident.
        lo_print = gr_table->get_print( ).
    * Get the selection rows
        lr_selections = gr_table->get_selections( ).
        lt_rows = lr_selections->get_selected_rows( ).
        CASE e_salv_function.
          WHEN 'PDF'.
            MESSAGE 'test' TYPE 'I'.
    / get print parameters
            CALL FUNCTION 'GET_PRINT_PARAMETERS'
              EXPORTING
                no_dialog              = 'X'
              IMPORTING
                valid                  = gw_valid
                out_parameters         = gw_pparams
              EXCEPTIONS
                archive_info_not_found = 1
                invalid_print_params   = 2
                invalid_archive_params = 3
                OTHERS                 = 4.
            CONCATENATE 'test' sy-datum sy-uzeit INTO gw_pparams-prtxt SEPARATED BY space.
            lw_print_ctrl = lo_print->get_print_control( ).
            lw_print_ctrl-pri_params = gw_pparams.
            lo_print->set_print_control( lw_print_ctrl ).
            lo_print->set_print_only( if_salv_c_bool_sap=>true ).
            gr_table->display( ).
            g_spool = sy-spono.
            MESSAGE sy-spono TYPE 'I'.
            CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
              EXPORTING
                src_spoolid              = g_spool
              TABLES
                pdf                      = pdf
              EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
            IF sy-subrc  <> 0.
              MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
            ELSE.
              CALL FUNCTION 'GUI_DOWNLOAD'
                EXPORTING
                  filename                = iv_file
                  filetype                = 'BIN'
                TABLES
                  data_tab                = pdf
                EXCEPTIONS
                  file_write_error        = 1
                  no_batch                = 2
                  gui_refuse_filetransfer = 3
                  invalid_type            = 4
                  no_authority            = 5
                  unknown_error           = 6
                  header_not_allowed      = 7
                  separator_not_allowed   = 8
                  filesize_not_allowed    = 9
                  header_too_long         = 10
                  dp_error_create         = 11
                  dp_error_send           = 12
                  dp_error_write          = 13
                  unknown_dp_error        = 14
                  access_denied           = 15
                  dp_out_of_memory        = 16
                  disk_full               = 17
                  dp_timeout              = 18
                  file_not_found          = 19
                  dataprovider_exception  = 20
                  control_flush_error     = 21
                  OTHERS                  = 22.
              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.
        ENDCASE.
      ENDMETHOD. "on_user_command
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

  • Output has to print from the executable program

    Hi All,
    I have 'zaap01' executable program. once provided the materil,plant, batch. the out put directly has to print(Via Printer) as well as when I'm getting alv grid.. can u help me how to proceed.
    Thanks,
    srii.

    Hi Sridhar
    Users can print the ALV output on a printer or they can view the printout on the screen. You are able to change the look of these printouts by making various settings in the list-type ALV outputs using the ALV object model.
    You can make the following settings for the printout of the ALV output:
    · Output additional information
    · Output standard title of the program
    · Determine that the ALV be called in print mode
    · Take actual list size into consideration during printing
    · Optimize Column Width in the Printout
    · Reserve Rows for Event END_OF_PAGE
    Methods
    Function-Output of list information
    Class-CL_SALV_PRINT
    Method-SET_LISTINFO_ON
    Function-Check whether list information are being output
    Class-CL_SALV_PRINT
    Method-IS_LISTINFO_ON
    Function-Output selection information
    Class-CL_SALV_PRINT
    Method-SET_SELECTIONINFO_ON
    Function-Check whether selection information is being output
    Class-CL_SALV_PRINT
    Method- IS_SELECTIONINFO_ON
    Function-Output additional information on a separate page
    Class-CL_SALV_PRINT
    Method- SET_COVERPAGE_ON
    Function-Check whether additional information is being printed on a separate page
    Class-CL_SALV_PRINT
    Method- IS_COVERPAGE_ON
    Output Standard Title of the Program
    The standard title of the program comprises the current date, the title of the ALV output and the page number. You are able to show the standard title.
    Methods
    Function-Output standard title of the program
    Class- CL_SALV_PRINT
    Method
    SET_REPORT_
    STANDARD_HEADER_ON
    Determine that the ALV Be Called in Print Mode
    You are able to print the ALV output directly without having to first display it on the screen.
    Methods
    Function-Print ALV output directly
    Class- CL_SALV_PRINT
    Method- SET_PRINT_ONLY
    Function-Check whether ALV output is being printed directly
    Class- CL_SALV_PRINT
    Method- IS_PRINT_ONLY
    Take Actual List Size into Consideration During Printing
    You can use the application to determine how wide the list should be in the printout. If the width of the ALV output has changed (for example because the user is showing columns), it can be that the page is not big enough to show all the information. You are able to set that ALV determine the current size before printing and then changes the print parameters accordingly.
    Methods
    Function
    -Take actual list size into consideration during printing
    Function
    Class- CL_SALV_PRINT
    Method- SET_PRINT_PARAMETERS_ENABLED
    Function
    -Check whether the list size can be adapted
    Class- CL_SALV_PRINT
    maethod-
    IS_PRINT_PARAMETERS_
    ENABLED
    Regards.
    Eshwar.

Maybe you are looking for

  • How do I delete 88,000 emails on Mail

    I use the email from my COX Internet provider account on Safari and only once in awhile the MAIL application opens up because, for example, I am sending the link to a Web page to someone. For whatever reason, if I do end up opening MAIL, it takes a l

  • Problem with fan Trap.

    Hi all, I am having a problem resolving fan trap. I am having a universe build over a MY SQL database. The universe totaly consists of 4 tables and are related in the following way. "A one to many B one to many C many to one D" There are many 1-may j

  • AGP Driving value?????

    Does anyone know what a good AGP driving value for the Radeon 8500LE would be? I used to have a Tyan Trinity board and a Geforce 2 MX video card. There were optimal settings Tyan supplied to customers for their particular video cards. IS there anythi

  • LAN side firewall settings for Direct Access (Windows Server 2012 R2) in DMZ?

    I am currently planning to set up our first Direct Access server (Windows Server 2012 R2). I will be in our firewall DMZ and we will be using the IP-HTTPS listener. For the Internet facing rule only TCP 443 inbound/outbound is sufficient but for the

  • Unable to download newer version of OS X still operating on 10.5.8.

    My laptop was not connected to the internet for a long time so updates were not down and now I am stuck with 10.5.8 and I cant seem to get up to the most recent version but everytime go and manually check my computer is telling me that I am operating