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

GET_PRINT_PARAMETERS

Former Member
0 Likes
11,900

Hello Group,

I have an ALV report output( using CL_GUI_ALV_GRID) on custom screen. I have several screen elements on the screen. I created 'print'(function code 'DRUC') on menu bar for GUI status for that screen. And following is relevant code in PAI. When I print it Print Parameter screen popped up, I gave the correct printer name in output device and hit continue. But the report is not printing. in FM, v_valid was set to 'X' after execution. Can somebody tell me what is wrong here? Thank You

WHEN 'DRUC'.

DATA: v_uname LIKE sy-uname,

v_valid.

DATA: it_pri_params TYPE pri_params,

it_arc_params TYPE arc_params.

v_uname = sy-uname.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

archive_mode = '1'

copies = 001

immediately = 'X'

layout = 'X_65_132'

line_count = 65

line_size = 132

receiver = v_uname

user = v_uname

IMPORTING

out_archive_parameters = it_arc_params

out_parameters = it_pri_params

valid = v_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF v_valid <> space.

IF it_arc_params IS INITIAL.

NEW-PAGE PRINT ON PARAMETERS it_pri_params NO DIALOG.

ELSE.

NEW-PAGE PRINT ON ARCHIVE PARAMETERS it_arc_params PARAMETERS it_pri_params NO DIALOG.

ENDIF.

ENDIF.

Thank you,

Chandra

Hello Group,

I have an ALV report output( using CL_GUI_ALV_GRID) on custom screen. I have several screen elements on the screen. I created 'print'(function code 'DRUC') on menu bar for GUI status for that screen. And following is relevant code in PAI. When I print it Print Parameter screen popped up, I gave the correct printer name in output device and hit continue. But the report is not printing. in FM, v_valid was set to 'X' after execution. Can somebody tell me what is wrong here? Thank You

WHEN 'DRUC'.

DATA: v_uname LIKE sy-uname,

v_valid.

DATA: it_pri_params TYPE pri_params,

it_arc_params TYPE arc_params.

v_uname = sy-uname.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING

archive_mode = '1'

copies = 001

immediately = 'X'

layout = 'X_65_132'

line_count = 65

line_size = 132

receiver = v_uname

user = v_uname

IMPORTING

out_archive_parameters = it_arc_params

out_parameters = it_pri_params

valid = v_valid

EXCEPTIONS

archive_info_not_found = 1

invalid_print_params = 2

invalid_archive_params = 3

OTHERS = 4.

IF v_valid <> space.

IF it_arc_params IS INITIAL.

NEW-PAGE PRINT ON PARAMETERS it_pri_params NO DIALOG.

ELSE.

NEW-PAGE PRINT ON ARCHIVE PARAMETERS it_arc_params PARAMETERS it_pri_params NO DIALOG.

ENDIF.

ENDIF.

Thank you,

Chandra

6 REPLIES 6
Read only

Former Member
4,795

Hi,

try with this. It is working fine for me.

list_name = sy-repid.

call function 'GET_PRINT_PARAMETERS'

exporting

no_dialog = 'X'

list_name = list_name

mode = 'CURRENT'

importing

out_parameters = pri_param

out_archive_parameters = arc_param.

new-page print on parameters pri_param

archive parameters arc_param no dialog.

Read only

Former Member
0 Likes
4,795

Use this :

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING DESTINATION = USR01-SPLD

LIST_NAME = 'SY_REPID(please place ur program name here) '

LIST_TEXT = 'REPORT'

IMMEDIATELY = 'X'

RELEASE = ' '

EXPIRATION = DAYS

LINE_SIZE = 120

LINE_COUNT = 44

IMPORTING OUT_PARAMETERS = it_pri_params

VALID = VALID. (Blank )

Why don't you Use SAP Standard GuI Command &RNT to your user command. Then Print will be executed in SAP routine . There is no need to write/ add another user command.

Message was edited by: Lanka Murthy

Read only

0 Likes
4,795

I am using all the parameters and new FCODE but still no luck. Any further suggestions please?

Thanks,

Chandra

Read only

Former Member
0 Likes
4,795

See this sample code and change accordingly

*Print parameter declarations
DATA: val(1) TYPE c,
      pripar TYPE pri_params,
      arcpar TYPE arc_params,
      lay   TYPE pri_params-paart,
      lines TYPE pri_params-linct,
      rows  TYPE pri_params-linsz.


  lay = 'X_65_255'.
  lines = 255.
  rows  = 65.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
       EXPORTING
            in_archive_parameters  = arcpar
            in_parameters          = pripar
            layout                 = lay
*            line_count             = lines
*            line_size              = rows
*            no_dialog              = 'X'
       IMPORTING
            out_archive_parameters = arcpar
            out_parameters         = pripar
            valid                  = val
       EXCEPTIONS
            archive_info_not_found = 1
            invalid_print_params   = 2
            invalid_archive_params = 3
            OTHERS                 = 4.

check val EQ 'X'.
NEW-PAGE PRINT ON
    NEW-SECTION
    PARAMETERS pripar
    ARCHIVE PARAMETERS arcpar
    NO DIALOG.

Write:/ 'Hello'.

NEW-PAGE PRINT OFF.

Read only

Former Member
0 Likes
4,795

Use the function module GET_PRINT_PARAMETERS.

Documentation for that is:

Functionality

The function module GET_PRINT_PARAMETERS is used to define, modify and display the print and archive parameters. Using this function module is the only correct way to modify a print or archive parameter record. The print parameters are closely related and contain a check total. This check total becomes invalid if any of the print parameters are changed and causes a runtime error when the print parameters are used later.

The required parameters are defined in the structure IN_PARAMETERS or IN_ARCHIVE_PARAMETERS. These input parameters must originate from another call of GET_PRINT_PARAMETERS or must be initial. The resulting print and archive parameters are returned with the function parameters OUT_PARAMETERS or OUT_ARCHIVE_PARAMETERS. The remaining IMPORT parameters, such as DESTINATION, LIST_NAME etc., are used to define the values to be passed to OUT_PARAMETERS or OUT_ARCHIVE_PARAMETERS. The output parameter VALID has the value BLANK in an interactive call if the user canceled the print screen.

You can use the function module with dialog (parameter NO_DIALOG = SPACE) or without dialog. If you use a dialog, a screen appears on which the user can change the print parameters.

Note: The "Print from page to page" option on the screen is not suitable for printing from ABAP programs, and is therefore not part of the structure PRI_PARAMS.

The module recognizes the following modes (values of parameter MODE):

'PARAM' Normal case. Define the print parameters for the

current program. The values that are not defined

are specified from the user master record or are

assigned default values. The print parameter screen

displays the PRINT key. This mode is used

if the MODE parameter is not specified.

'PARAMSEL' Like PARAMS, except that the print parameter screen

includes an option to activate the selection screen.

'BATCH' Define the print parameters for a background job.

In this mode, the name of the report to be started

is passed with the REPORT parameter.The REPORT

statement of the specified report is checked for

LINE-SIZE and LINE-COUNT definitions. These

definitions are passed as default specifications.

Furthermore, the SAVE key is offered

instead of the PRINT key in this mode.

'CURRENT' Define the current valid print parameters:

These parameters come from the following sources:

1.) From the user-specific print parameters

2.) From the LINECOUNT and LINESIZE additions in

the REPORT statement

3.) If the report is running in the background or

with Execute and Print, from the print parameters

passed from the report.

Otherwise it behaves as with PARAMSEL. In general, you should

set import parameter NO_DIALOG in this modus,

becausethis mode is only pointful, if it is run in the background.

'DEFVALS' Display for the default values.

Some of the default values are stored in the user defaults,

others can be maintained specifically for users and reports

using System -> List -> Print -> User-specific print

parameters.

The sytem returns the values for the current user and

report.

'DISPLAY' Displays the print parameters passed.

IMPORTANT:

In DEFVALS mode, the fields in out_parameters that are not contained in the user defaults are initial (type unknown). This means that the fields are not considered if out_parameters is passed again in a subsequent call of GET_PRINT_PARAMETERS.

In all other modes, all fields of out_parameters are filled with values (possibly default values). This means that the fields are considered if out_parameters is passed in a subsequent call of GET_PRINT_PARAMETERS.

You should normally query the value of VALID. It has the possible values TRUE and FALSE. If it is FALSE, the user has either canceled the print dialog, or the function module has been called with parameters that cannot be used to print properly (for example, printing in the background on a frontend printer).

Example

  • Normal definition of the print parameters

DATA: PARAMS LIKE PRI_PARAMS,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING DESTINATION = 'LT50'

IMPORTING OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS PARAMS.

ENDIF.

  • Definition of the parameters for printing and archiving

DATA: PRI_PARAMS LIKE PRI_PARAMS,

ARC_PARAMS LIKE ARC_PARAMS,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

IMPORTING OUT_PARAMETERS = PRI_PARAMS

OUT_ARCHIVE_PARAMETERS = ARC_PARAMS

VALID = VALID.

IF VALID <> SPACE.

NEW-PAGE PRINT ON PARAMETERS PRI_PARAMS

ARCHIVE PARAMETERS ARC_PARAMS.

ENDIF.

  • Definition of the parameters for a background job

DATA: PARAMS LIKE PRI_PARAMS,

VALID TYPE C.

CALL FUNCTION 'GET_PRINT_PARAMETERS'

EXPORTING MODE = 'BATCH'

REPORT = 'MYREPORT'

IMPORTING OUT_PARAMETERS = PARAMS

VALID = VALID.

IF VALID <> SPACE.

CALL FUNCTION 'JOB_OPEN' .... EXPORTING JOBCOUNT ...

SUBMIT MYREPORT VIA JOB 'MY_JOB' NUMBER JOBCOUNT

TO SAP-SPOOL WITHOUT SPOOL DYNPRO

SPOOL PARAMTERS PARAMS.

CALL FUNCTION 'JOB_CLOSE' ...

ENDIF.

  • Modifying the print parameters

CALL FUNCTION 'GET_PRINT_PARAMETERS' "Obtain print

EXPORTING NO_DIALOG = 'X' "parameters

IMPORTING OUT_PARAMETERS = PARAMS.

...

CALL FUNCTION 'GET_PRINT_PARAMETERS' "Modify print

EXPORTING NO_DIALOG = 'X' "parameters

IN_PARAMETERS = PARAMS

LIST_NAME = 'NEW-LIST'

IMPORTING OUT_PARAMETERS = PARAMS.

Parameters

ARCHIVE_ID

ARCHIVE_INFO

ARCHIVE_MODE

ARCHIVE_TEXT

AR_OBJECT

ARCHIVE_REPORT

AUTHORITY

COPIES

COVER_PAGE

DATA_SET

DEPARTMENT

DESTINATION

EXPIRATION

IMMEDIATELY

IN_ARCHIVE_PARAMETERS

IN_PARAMETERS

LAYOUT

LINE_COUNT

LINE_SIZE

LIST_NAME

LIST_TEXT

MODE

NEW_LIST_ID

PROTECT_LIST

NO_DIALOG

RECEIVER

RELEASE

REPORT

SAP_COVER_PAGE

HOST_COVER_PAGE

PRIORITY

SAP_OBJECT

TYPE

USER

USE_OLD_LAYOUT

UC_DISPLAY_MODE

DRAFT

ABAP_LIST

USE_ARCHIVENAME_DEF

DEFAULT_SPOOL_SIZE

PO_FAX_STORE

NO_FRAMES

OUT_ARCHIVE_PARAMETERS

OUT_PARAMETERS

VALID

Exceptions

ARCHIVE_INFO_NOT_FOUND

INVALID_PRINT_PARAMS

INVALID_ARCHIVE_PARAMS

Function Group

SPRI

Read only

Former Member
0 Likes
4,795

hi

In the exporting parameters u have given the archive mode is '1' and you are passing the archiving parameters .

dont pass the archiving parameters your report will get printed as the output is getting archived.

comment archive_mode = 1

and the out_archive_parameters = it_arc_params

Regards.

Lavanya.