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

ALV PRINT

Former Member
0 Likes
563

Using ALv without displaying the report output i want to print the output.

how to do this

Using ALv without displaying the report output i want to print the output.

how to do this

2 REPLIES 2
Read only

Former Member
0 Likes
519

Hi

Pass the printer name in the exportin parameter IS_PRINT of the function module.

Thanks

Vasudha

Read only

Former Member
0 Likes
519

NEW-PAGE - spool_options

Syntax

... { PRINT ON [NEW-SECTION] PARAMETERS pri_params

[ARCHIVE PARAMETERS arc_params]

NO DIALOG }

| { PRINT OFF } ... .

Extras:

1. ... PRINT ON [NEW-SECTION]

2. ... PARAMETERS pri_params

3. ... ARCHIVE PARAMETERS arc_params

4. ... NO DIALOG

5. ... PRINT OFF

Effect

The addition PRINT ON causes all following output statements to be written in a print list. The [ARCHIVE] PARAMETERS additions are used to specify the print and archive parameters of the spool request. The addition PRINT OFF closes a print list which was begun with PRINT ON.

Addition 1

... PRINT ON [NEW-SECTION]

Effect

The addition PRINT ON creates a new print list level. The first output statement after a NEW-PAGE PRINT ON opens a new spool request and writes in a print list in the SAP spool system. The number of the spool request is placed into sy-spono by the first output statement. During its creation, the print list is sent to the SAP spool system page by page.

If the current list is a screen list, its creation is interrupted and the new print list level is stacked in it.

If the current list is a print list which was not created using NEW-PAGE PRINT ON, its creation is interrupted and the new list is stacked in it.

If the current list is a print list created using a NEW-PAGE PRINT ON and the NEW-SECTION addition is not used, a treatable exception of the CX_SY_NESTED_PRINT_ON class occures.

If the current list is a print list created using a NEW-PAGE PRINT ON, the NEW-SECTION addition is used, the specified print parameters correspond to those of the newly created list and the print parameter PRNEW in the structure pri_params is initial then no new spool request will be generated and the output is appended to the current print list.

If the current list is a print list, the NEW-SECTION addition is used and the specified print parameters do not correspond to the newly created list or the print parameter PRNEW in structure pri_params is not initial, the current spool request is closed implicitly with NEW-PAGE PRINT OFF and a new spool request is created.

It is not possible to use NEW-PAGE PRINT ON to directly stack a further print list level to a print list level created using NEW-PAGE PRINT ON.

A print list level created using NEW-PAGE PRINT ON can be closed using NEW-PAGE PRINT OFF or NEW-PAGE PRINT ON NEW-SECTION, by leaving a screen sequence or by the end of the program.

The NEW SECTION addition can be used to avoid the CX_SY_NESTED_PRINT_ON exception. The use of NEW SECTION allows the output to be continued in the previous print list, this is not possible in exception handling using CATCH.

Notes

Every NEW-PAGE PRINT ON statement should be explicitly closed with NEW-PAGE PRINT OFF before the end of the program or leaving a screen sequence.

For the NEW-PAGE PRINT ON statement there are obsolete additions/>.

Addition 2

... PARAMETERS pri_params

Addition 3

... ARCHIVE PARAMETERS arc_params

Addition 4

... NO DIALOG

Effect

Use these additions to provide the spool request with print parameters and archiving parameters. The latter are necessary if you want to archive the print list using ArchiveLink.

Use addition PARAMETERS to pass the print parameters in a structure pri_params of data type PRI_PARAMS from the ABAP Dictionary. If in pri_params, archiving is specified, you must pass archiving parameters with the addition ARCHIVE PARAMETERS in a structure arc_params of data type ARC_PARAMS from the ABAP Dictionary.

Structures of data types PRI_PARAMS and ARC_PARAMS must exclusively be filled with the function module GET_PRINT_PARAMETERS. When calling the function module, you can set individual or all print parameters in the program and/or display a print dialog window. The function module creates in its output parameters a set of valid print and archiving parameters to be used as pri_params and arc_params.

Addition NO DIALOG suppresses the dialog window that by default appears when using the PRINT ON addition.

Notes

Always use these additions and use them as described above. Especially suppress the print dialog window that appears by default. When using the default print dialog window, inconsistent parameters may be passed to the program, if the user leaves the window using Cancel. Instead, display the print dialog window when you execute function module GET_PRINT_PARAMETERS. This function module has an output parameter VALID, which signals the consistency of the generated print parameters.

Using addition NO DIALOG without simultaneously passing print parameters is allowed only outside of ABAP Objects and results in a warning in the systax check. The print parameters are then taken from the user master record, as far as possible.

Apart from the additions shown here, there is a number of obsolete print parameters.

Example

Creating print lists during the list event AT LINE-SELECTION. The print parameters are determined by the function module GET_PRINT_PARAMETERS before the basic list is created.

REPORT demo NO STANDARD PAGE HEADING.

DATA: spfli_wa TYPE spfli,

sflight_wa TYPE sflight.

DATA: print_parameters TYPE pri_params,

valid_flag TYPE c LENGTH 1.

START-OF-SELECTION.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

IMPORTING

out_parameters = print_parameters

valid = valid_flag

EXCEPTIONS

invalid_print_params = 2

OTHERS = 4.

IF valid_flag = 'X' AND sy-subrc = 0.

SELECT carrid connid

FROM spfli

INTO CORRESPONDING FIELDS OF spfli_wa.

WRITE: / spfli_wa-carrid, spfli_wa-connid.

HIDE: spfli_wa-carrid, spfli_wa-connid.

ENDSELECT.

ELSE.

...

ENDIF.

AT LINE-SELECTION.

NEW-PAGE PRINT ON PARAMETERS print_parameters

NO DIALOG.

SELECT *

FROM sflight

INTO sflight_wa

WHERE carrid = spfli_wa-carrid AND

connid = spfli_wa-connid.

WRITE: / sflight_wa-carrid, sflight_wa-connid,

sflight_wa-fldate ...

ENDSELECT.

NEW-PAGE PRINT OFF.

Addition 5

... PRINT OFF

Effect

Addition PRINT OFF closes a print list level created using NEW-PAGE PRINT ON, in doing so the current page is sent to the SAP spool system and the corresponding spool request is released. Further output statements write in the screen list or print list in which the now closed print list level was stacked. The system field sy-spono is not immediately converted to a print list, this happens after the next output statement.

NEW-PAGE PRINT OFF has no effect on print list levels that were not created using NEW-PAGE PRINT ON.

Note

At the end of the program and at every list event AT LINE-SELECTION, AT PF## and AT USER-COMMAND, implicitly the statement NEW-PAGE PRINT OFF is executed.

Exceptions

Catchable Exceptions

CX_SY_NESTED_PRINT_ON

Cause: Gestapeltes NEW-PAGE PRINT ON.

Runtime Error: NESTED_PRINT_ON