SAP ABAP SMARTFORMS打印

SMARTFORMS绘制:

详细绘制可参考:https://www.cnblogs.com/liujiameiblogs/p/15899360.html

1.SMARTFORMS样式

2.SMARTFORMS模板

 3.创建结构、创建表

 

 

 

 4.将接口填入SMARTFORMS

 

 5.调用SMARTFORMS

 *&---------------------------------------------------------------------*
*& Form FRM_CALL_SF
*&---------------------------------------------------------------------*
*& text:调用打印SMARTFORMS
*&---------------------------------------------------------------------*
FORM FRM_CALL_SF .

  DATA: lf_fm_name        TYPE rs38l_fnam.
  DATA: ls_control_param  TYPE ssfctrlop.
  DATA: ls_composer_param TYPE ssfcompop.
  DATA: ls_sender         TYPE swotobjid.
  DATA: lf_formname       TYPE tdsfname.
  DATA: ls_info           TYPE ssfcrescl.

* ls_control_param-no_dialog = 'X'.
  ls_control_param-preview     'X'.
  ls_control_param-langu       = sy-langu.
  ls_control_param-no_open   'X'.
  ls_control_param-no_close  'X'.
*  ls_composer_param-TDPAGESLCT = 2.
  ls_composer_param-tdnewid 'X'.

  CALL FUNCTION 'SSF_OPEN'
    EXPORTING
      control_parameters = ls_control_param
      output_options     = ls_composer_param
    EXCEPTIONS
      formatting_error   1
      internal_error     2
      send_error         3
      user_canceled      4
      OTHERS             5.
  IF sy-subrc <> 0.
    IF sy-subrc EQ 4.
      MESSAGE TEXT-t34 TYPE 'S' DISPLAY LIKE 'W'.
      EXIT.
    ELSE.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      EXIT.
    ENDIF.
  ENDIF.

  lf_formname 'YTEST_VIL_F_09'.
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname           = lf_formname
    IMPORTING
      fm_name            = lf_fm_name
    EXCEPTIONS
      no_form            1
      no_function_module 2
      OTHERS             3.
  IF sy-subrc <> 0.
    MESSAGE 'Call SSF_FUNCTION_MODULE_NAME Error' TYPE 'E'.
    EXIT.
  ENDIF.

* 调用smartform函数执行打印
  CALL FUNCTION lf_fm_name
    EXPORTING
      control_parameters = ls_control_param
      output_options     = ls_composer_param
      user_settings      ' '
    IMPORTING
      job_output_info    = ls_info
    TABLES
      it_head            = gt_head    "表头
      it_item            = gt_item  "行项目
    EXCEPTIONS
      formatting_error   1
      internal_error     2
      send_error         3
      user_canceled      4
      OTHERS             5.
  IF sy-subrc <> 0.
    MESSAGE 'Call SmartForms Error' TYPE 'E'.
  ENDIF.

  CALL FUNCTION 'SSF_CLOSE'
    EXCEPTIONS
      formatting_error 1
      internal_error   2
      send_error       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.

ENDFORM.

posted @ 2022-07-07 10:57  LikZ-WM  阅读(455)  评论(0编辑  收藏  举报