cancel
Showing results for 
Search instead for 
Did you mean: 

Print from table

Former Member
0 Kudos

Hi,

Need expert advice in using print button, i had try few example in this forums and search it through out the Google but i'm still unable to do this

i had try using above link but when i had click the print button there is no spool generated or error.

Please help and advice.



  DATA: it_scarr TYPE STANDARD TABLE OF scarr.

  select *
from scarr
into table it_scarr
 .

  DATA lo_nd_et_result TYPE REF TO if_wd_context_node.
  DATA lo_el_et_result TYPE REF TO if_wd_context_element.
  DATA ls_et_result TYPE wd_this->element_et_result.
* navigate from <CONTEXT> to <ET_RESULT> via lead selection
  lo_nd_et_result = wd_context->get_child_node( name = wd_this->wdctx_et_result ).

* @TODO handle not set lead selection
  IF lo_nd_et_result IS INITIAL.
  ENDIF.

* get element via lead selection
  lo_el_et_result = lo_nd_et_result->get_element(  ).

* @TODO handle not set lead selection
  IF lo_el_et_result IS INITIAL.
  ENDIF.

* alternative access  via index
* lo_el_et_result = lo_nd_et_result->get_element( index = 1 ).
* @TODO handle non existant child
* IF lo_el_et_result IS INITIAL.
* ENDIF.

* get all declared attributes
  lo_el_et_result->get_static_attributes(
    IMPORTING
      static_attributes = ls_et_result ).


* Print web dynpro table using ALV object print functionality
  data it_datatab type ref to data.
* assign table containing data to it_datatab
  get reference of it_scarr into it_datatab.
  FIELD-SYMBOLS: <tab> TYPE table.

  ASSIGN it_datatab->* TO <tab>. "assign data table to field symbol
  DATA: it_alvtable TYPE REF TO cl_salv_table.
  DATA: ld_prnt_params TYPE pri_params,
  ld_valid(1) TYPE c.
* Get print parameters
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      copies                 = '1' "print_options-copies
      layout                 = 'X_65_255'
      no_dialog              = abap_true
      IMMEDIATELY            =  abap_true
    IMPORTING
      out_parameters         = ld_prnt_params
      valid                  = ld_valid
    EXCEPTIONS
      archive_info_not_found = 1
      invalid_print_params   = 2
      invalid_archive_params = 3
      OTHERS                 = 4.
  IF sy-subrc ne 0 OR ld_valid NE abap_true.
* invalid print parameters
    return.
  ENDIF.
* Start List Processing using generated print parameters
  NEW-PAGE PRINT ON PARAMETERS ld_prnt_params NO DIALOG.
*  NEW-PAGE PRINT ON PARAMETERS ld_prnt_params.
*  write: 'HelloWorld'.
* If you insert ABAP write statements here they will apear on your printout
* Create the ALV Object
  DATA: error_string TYPE string.


  cl_salv_table=>factory(
    EXPORTING
      list_display = abap_true
     IMPORTING
        r_salv_table = it_alvtable
      CHANGING
         t_table = <tab>
        )
      .
* Process the ALV Columns
  DATA: columns TYPE REF TO cl_salv_columns_table.
* Reference ALV columns object
  columns = it_alvtable->get_columns( ).
* Set columns to optimised width.
  columns->set_optimize( abap_false ).
*Set ALV to print in the background
  it_alvtable->display( ).
  NEW-PAGE PRINT OFF.
* Display print complete message



Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

i'm google up little and found the answer, sorry forgot the links

Answers (0)