ABAP code to Print abap web dynpro table
Once you have created a basic table on your web dynpro for ABAP application your users might want to be able to print this table, and not just the records currently displayed but all the records in the table.
With the ABAP code below this becomes a fairly simply process! This will print the table to the users SAP printer or any printer setup in SAP.
Step 1 - Create Print button within your abap web dynpro application Step 2 - Retrieve data displayed to user within ABAP web dynpro table
* Retrieve new data
select *
from scarr
into table it_scarr
where CARRID = 'AA' .
* 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
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.
* If you insert ABAP write statements here they will apear on your printout
* write: 'HelloWorld'.
* 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 =
Website Navigation to related information
|
||||||||||