技术开发 频道

如何在SAP里设置打印机参数

【IT168 技术文章】

    1、关于打印函数参见sap的函数模块SPRI,对于打印参数常用函数有:
    GET_PRINT_PARAMETERS
    SET_PRINT_PARAMETERS

    2、申明变量

           begin of g_ty_s_tests,
             select_amount            type i,
             only_db_info             type char1,
             excp_condense            type char1,
             layo_title               type lvc_s_layo
-grid_title,
             layo_zebra               type char1,
             layo_no_vert_lines       type char1,
             layo_no_horiz_lines      type char1,
             layo_cell_merge          type char1,
             layo_count               type char1,
             layo_no_colhead          type char1,
             layo_column_optimize     type char1,
             layo_keys_hotspot        type char1,
             layo_no_keyfix           type char1,
             layo_hotspot_field       type slis_fieldname,
             layo_no_hotspot          type char1,
             layo_no_scrolling        type char1,
             layo_no_authcheck        type char1,
             layo_no_min_linesize     type char1,
             layo_min_linesize        type sylinsz,
             layo_max_linesize        type sylinsz,
             layo_group_change_edit   type char1,
             layo_get_selinfo         type char1,
             layo_confirmation_prompt type char1,
             layo_f2code              type syucomm,
             layo_reprep              type char1,
             sum_before               type char1,
             sum_no_sumline           type char1,
             sum_no_sumchoice         type char1,
             sum_numc                 type char1,
             sum_no_unitsplit         type char1,
             sum_totals_only          type char1,
             sum_totals_text          type symsgli,
             sum_no_subtotals         type char1,
             sum_no_subchoice         type char1,
             sum_subtotals_text       type symsgli,
             vari_none                type char1,
             vari_save                type char1,
             vari_default             type char1,
             vari_layout              type disvariant
-variant,
             prnt_print               type char1,
             prnt_reserve_lines       type lvc_s_prnt
-reservelns,
             prnt_no_listinfo         type char1,
             prnt_no_selinfo          type char1,
             prnt_with_title          type char1,
             prnt_footline            type lvc_s_prnt
-footline,
             prnt_printinfo           type char1,
             prnt_no_coverp(企业资源计划2)age        type char1,
             prnt_no_new_page         type char1,
             prnt_no_change_print_params type char1,
             pri_params_set           type char1,
             pri_archive_id           type arc_params
-archiv_id,
             pri_archive_info         type arc_params
-info,
             pri_archive_mode         type pri_params
-armod,
             pri_archive_text         type arc_params
-arctext,
             pri_archive_object       type arc_params
-ar_object,
             pri_authority            type pri_params
-prber,
             pri_copy                 type pri_params
-prcop,
             pri_coverp(企业资源计划2)age            type pri_params
-prbig,
             pri_dataset              type pri_params
-prdsn,
             pri_department           type pri_params
-prabt,
             pri_destination          type pri_params
-pdest,
             pri_expiration           type pri_params
-pexpi,
             pri_immediatly           type pri_params
-primm,
             pri_layout               type pri_params
-paart,
             pri_line_count           type pri_params
-linct,
             pri_line_size            type pri_params
-linsz,
             pri_list_name            type pri_params
-plist,
             pri_list_text            type pri_params
-prtxt,
             pri_new_list_id          type pri_params
-prnew,
             pri_receiver             type pri_params
-prrec,
             pri_release              type pri_params
-prrel,
             pri_sap_coverp(企业资源计划2)age        type pri_params
-prsap,
             pri_host_coverp(企业资源计划2)age       type pri_params
-prunx,
             pri_priority             type pri_params
-priot,
             pri_sap_object           type arc_params
-sap_object,
             pri_type                 type pri_params
-ptype,
             pri_footline             type pri_params
-footl,
             buffer_active            type char1,
             bypassing_buffer         type char1,
             current_display          type i,
             current_page             type i,
           end   of g_ty_s_tests.
    gs_test     type g_ty_s_tests.

    3、调用'SET_PRINT_PARAMETERS'函数设置打印参数

      call function 'SET_PRINT_PARAMETERS'
       exporting
           archive_id                  
= gs_test-pri_archive_id
           archive_info                
= gs_test-pri_archive_info
           archive_mode                
= gs_test-pri_archive_mode
           archive_text                
= gs_test-pri_archive_text
           ar_object                  
= gs_test-pri_archive_object
           authority                  
= gs_test-pri_authority
           copies                      
= gs_test-pri_copy
           cover_page                  
= gs_test-pri_coverp(企业资源计划2)age
           data_set                    
= gs_test-pri_dataset
           department                  
= gs_test-pri_department
           destination                
= gs_test-pri_destination
           expiration                  
= gs_test-pri_expiration
           immediately                
= gs_test-pri_immediatly
    
*     IN_ARCHIVE_PARAMETERS       = ' '
    
*     IN_PARAMETERS               = ' '
           layout                      
= gs_test-pri_layout
           line_count                  
= gs_test-pri_line_count
           line_size                  
= gs_test-pri_line_size
           list_name                  
= gs_test-pri_list_name
           list_text                  
= gs_test-pri_list_text
           new_list_id                
= gs_test-pri_new_list_id
           receiver                    
= gs_test-pri_receiver
           release                    
= gs_test-pri_release
           sap_cover_page              
= gs_test-pri_sap_coverp(企业资源计划2)age
           host_cover_page            
= gs_test-pri_host_coverp(企业资源计划2)age
           priority                    
= gs_test-pri_priority
           sap_object                  
= gs_test-pri_sap_object
           type                        
= gs_test-pri_type
           foot_line                  
= gs_test-pri_footline.

    4、调用GET_PRINT_PARAMETERS函数读取打印参数 

    data: ls_arc_params type arc_params,
            ls_pri_params type pri_params,
            l_valid       type char1.                          
"#EC NEEDED

      call function
'GET_PRINT_PARAMETERS'
        exporting
             archive_id                  
= gs_test-pri_archive_id
             archive_info                
= gs_test-pri_archive_info
             archive_mode                
= gs_test-pri_archive_mode
             archive_text                
= gs_test-pri_archive_text
             ar_object                  
= gs_test-pri_archive_object
    
*        ARCHIVE_REPORT              = C_CHAR_UNKNOWN
             authority                  
= gs_test-pri_authority
             copies                      
= gs_test-pri_copy
             cover_page                  
= gs_test-pri_coverp(企业资源计划2)age
             data_set                    
= gs_test-pri_dataset
             department                  
= gs_test-pri_department
             destination                
= gs_test-pri_destination
             expiration                  
= gs_test-pri_expiration
             immediately                
= gs_test-pri_immediatly
    
*        IN_ARCHIVE_PARAMETERS       = ' '
    
*        IN_PARAMETERS               = ' '
             layout                      
= gs_test-pri_layout
             line_count                  
= gs_test-pri_line_count
             line_size                  
= gs_test-pri_line_size
             list_name                  
= gs_test-pri_list_name
             list_text                  
= gs_test-pri_list_text
    
*        MODE                        = ' '
             new_list_id                
= gs_test-pri_new_list_id
    
*        PROTECT_LIST                = C_CHAR_UNKNOWN
    
*        NO_DIALOG                   = C_FALSE
             receiver                    
= gs_test-pri_receiver
             release                    
= gs_test-pri_release
    
*        REPORT                      = C_CHAR_UNKNOWN
             sap_cover_page              
= gs_test-pri_sap_coverp(企业资源计划2)age
             host_cover_page            
= gs_test-pri_host_coverp(企业资源计划2)age
             priority                    
= gs_test-pri_priority
             sap_object                  
= gs_test-pri_sap_object
             type                        
= gs_test-pri_type
    
*        USER                        = SY-UNAME
    
*        USE_OLD_LAYOUT              = ' '
       importing
             out_archive_parameters      
= ls_arc_params
             out_parameters              
= ls_pri_params
             valid                        
= l_valid
       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.

      move
-corresponding ls_arc_params to gs_test.
      move
-corresponding ls_pri_params to gs_test.
0
相关文章