Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Print alv data

Former Member
0 Likes
1,142

hello, i need to print data on alv by sending it to transaction SP02! Anyone can guide me with the pseudo code below?

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

destination = printer

list_text = Daily Stock Report

mode = X

no_dialog = X

user = sy-uname

IMPORTING

out_parameters = printer_params

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Call the following FM to get the printing parameters:

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = Report-id

is_layout = layout

it_fieldcat = GT_FIELDCAT

i_default = X

i_save = A

is_print = printer_params

i_suppress_empty_data = abap_false

TABLES

t_outtab = GT_FINAL

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.

7 REPLIES 7
Read only

venkat_o
Active Contributor
0 Likes
1,054

Hi, You need to pass print related structure to REUSE_ALV_LIST_DISPLAY function module like below.


  REPORT ztest_notepad.
  DATA:
      i_t001 TYPE t001 OCCURS 0,
      pdf    LIKE tline OCCURS 0.
  DATA:
       g_spool   TYPE tsp01-rqident,
       g_program TYPE sy-repid VALUE sy-repid.

  TYPE-POOLS:slis.
  DATA: w_print TYPE slis_print_alv,
        w_print_ctrl TYPE alv_s_pctl.

  START-OF-SELECTION.
    SELECT * FROM t001 INTO TABLE i_t001 UP TO 100 ROWS.
    w_print-print = 'X'.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program = g_program
        i_structure_name   = 'T001'
        is_print           = w_print
      TABLES
        t_outtab           = i_t001.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,054

I dont want to print it directly but send it for spool print and the print the alv from transaction SP02

Read only

0 Likes
1,054

Hi, <li> When you execute the ALV report , Dialog box for print parameters will be appeared.->Click on properties button->Under General properties node, you will see Print out immediately ->Double click on Print out immediately ->you will see Time of print listbox ->click on that, Select Send to SAP spool only now.->click on continue button to come back ->now print Thanks Venkat.O

Read only

Former Member
0 Likes
1,054

Hmm, ok, now i want to do that without having to navigate through the menus. i want to send the data for spool print using a function module.

Read only

0 Likes
1,054

Run it in batch mode.

Read only

0 Likes
1,054

Write the following code after creating ur ALV fm and then calling FM for get print parameters .........

Here ZALV_DEL is the name of the report program in which u have written ur ALV program it can be same program in which u r writing submit or can b different program.

SUBMIT ZALV_DEL TO SAP-SPOOL

SPOOL PARAMETERS LS_PRI_PARAM

WITHOUT SPOOL DYNPRO

AND RETURN.

Read only

Former Member
0 Likes
1,054

Hi,

You Can Do Like This

Execute the TCode

At selection Screen

Choose Program Execute in BackGround

Choose Output Device Then Enter

Choose Immediate & Save

Job Will Be Scheduled

Then Go To SP02

There you can See The spool No created for you Program

also check in SM35

Hope This helps

With Regards,

Vinu.R