Skip to Content
author's profile photo Former Member
Former Member

GET/SET_PRINT_PARAMETERS

Hi all!

How can I pass variable with PRINTERNAME to function GET/SET_PRINT_PARAMETERS..

If I use this code it stil print with default printer?

FORM print.

  PERFORM read_fields.

  DATA: val,
      pripar LIKE pri_params,
      arcpar LIKE arc_params,
      h_plist LIKE pri_params-plist.

  DATA:l_params TYPE pri_params,
       l_valid TYPE c.

  DATA: pa_dest LIKE pri_params-pdest.

  pa_dest = '3070'.

  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING     
      no_dialog              = 'X'
      immediately            = 'X'
    IMPORTING
      out_parameters         = pripar      
      out_archive_parameters = arcpar
      valid                  = val
    EXCEPTIONS
      archive_info_not_found = 1
      invalid_print_params   = 2
      invalid_archive_params = 3
      OTHERS                 = 4.

  IF val <> space AND sy-subrc = 0.

    CALL FUNCTION 'SET_PRINT_PARAMETERS'
      EXPORTING
        destination = pa_dest.

    NEW-PAGE PRINT ON PARAMETERS pripar NO DIALOG.

    PERFORM print_selectie_per_klant_f.

    NEW-PAGE PRINT OFF.
  ELSE.

    PERFORM fout.

  ENDIF.

ENDFORM.  

Adibo..:)

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:15 PM

    Check out this sample program

    http://www.sapdevelopment.co.uk/reporting/rep_print.htm

    Regards,

    Santosh

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:16 PM

    Hi,

    There is a Exporting field called <b>DESTINATION</b>. This is the 'output device

    Regards

    Sudheer

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:17 PM
    have you called the FM SET_PRINT_PARAMETERS in the  events  INITIALIZATION  or AT SELECTION-SCREEN.
    
    AT SELECTION-SCREEN.
    
    CALL FUNCTION 'SET_PRINT_PARAMETERS'
          EXPORTING
            destination = pa_dest.
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:18 PM

    check below code...

    *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

    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:/ 'data'.

    NEW-PAGE PRINT OFF.

    *Write to printer

    DATA: ld_params LIKE pri_params,

    ld_valid TYPE c,

    ld_lay TYPE pri_params-paart,

    • Example of seting default layout

    ld_lay = 'X_65_255'.

    CALL FUNCTION 'GET_PRINT_PARAMETERS'

    EXPORTING

    immediately = 'X'

    LAYOUT = ld_layout

    LIST_NAME = 'TEST'

    LIST_TEXT = 'Test page'

    NEW_LIST_ID = 'X'

    no_dialog = ' '

    release = 'X'

    IMPORTING

    out_parameters = ld_params

    valid = ld_valid

    EXCEPTIONS

    archive_info_not_found = 1

    invalid_print_params = 2

    invalid_archive_params = 3

    OTHERS = 4.

    IF sy-subrc EQ 0.

    IF ld_valid <> space.

    new-page print on parameters ld_params NO dialog.

    write: 'This text will be printed on page'.

    write: 'This text will be printed on page'.

    • Stop spool report appearing, maybe option to remove this

    leave to screen 0.

    ENDIF.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:19 PM

    Hi adibo,

    i believe the pri_params-pdest (structure pri_params field pdest lenght is only of 4 characters) takes the length of 4. however spool devices are assigned numbers in the case '3070' device...

    hope this helps u a bit,

    all the best,

    regards,

    sampath

    • mark helpful answers

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:30 PM

    @Chandrasekhar and everyone

    I tried this:

    AT SELECTION-SCREEN.
      CALL FUNCTION 'SET_PRINT_PARAMETERS'
        EXPORTING
          destination = pa_dest.
    

    FORM print.
    
      PERFORM read_fields.
    
      DATA: val,
          pripar LIKE pri_params,
          arcpar LIKE arc_params,
          h_plist LIKE pri_params-plist.
    
      DATA : c_copies LIKE pri_params-prcop.
    
    
      DATA:l_params TYPE pri_params,
           l_valid TYPE c.
    
      DATA: pa_dest LIKE pri_params-pdest.
    
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING      
          no_dialog              = ' '
          immediately            = 'X'
        IMPORTING
          out_parameters         = pripar            out_archive_parameters = arcpar
          valid                  = val
        EXCEPTIONS
          archive_info_not_found = 1
          invalid_print_params   = 2
          invalid_archive_params = 3
          OTHERS                 = 4.
    
      IF val <> space AND sy-subrc = 0.
    
        NEW-PAGE PRINT ON PARAMETERS pripar NO DIALOG.
        PERFORM print_selectie_per_klant_f.
        NEW-PAGE PRINT OFF.
      ELSE.
    
        PERFORM fout.
    
      ENDIF.
    
    ENDFORM.  
    

    Won't work..I still see my default printer..

    I'am using VPN at the moment..I don't know if this is the problem..:S

    Adibo..:)

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 30, 2007 at 02:37 PM

    if ur using VPN, then ur mostly connecting to ur client from somewhere else. so it takes default printer and prints normally. Normally, users can print from client location to the correct printer.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.