SAP 分页打印产品合格证书

*&---------------------------------------------------------------------*
*& Report ZQM007
*&---------------------------------------------------------------------*
*&PROGRAM NAME : <ZQM207>
*---------------------------------------------------------------------*
* VERSION:            V1.0
* DATE CREATED :      2019/07/15
* CREATED BY   :      XXXXXX
* TRANSPORT REQUEST:  XXXXXXXXXX
* DESCRIPTION  :      Print Certifcate of Quality.
* request raised by:  XXXXXX
REPORT zqm207.

TABLES : lips.
********************************
* INNITIALIZATION
********************************

TYPES : BEGIN OF ltype_lips,
          vbeln TYPE lips-vbeln,   "发货单号
          posnr TYPE lips-posnr,   "发货单行号
          matnr TYPE lips-matnr,   "物料
          lfimg TYPE lips-lfimg,   "发货单数量
          arktx TYPE lips-arktx,   "物料描述
          vgbel TYPE lips-vgbel,   "销售单号
        END OF ltype_lips.


DATA : gt_lips TYPE TABLE OF ltype_lips,
       gs_lips LIKE LINE OF gt_lips.

DATA : gwk_fname    TYPE rs38l_fnam.

DATA : lc_print   TYPE  ssfcompop,        "默认打印机
       lc_control TYPE  ssfctrlop.        "预览设定

********************************
* SELECTION-SCREEN
********************************
SELECTION-SCREEN BEGIN OF BLOCK 01 WITH FRAME.

SELECT-OPTIONS : s_vbeln FOR lips-vbeln.

SELECTION-SCREEN END OF BLOCK 01.


********************************
* START OF SELECTION
********************************
IF s_vbeln IS INITIAL.

  MESSAGE 'Please input the delivery' TYPE 'W'.

ELSE.

  PERFORM frm_get_data.   "获取数据

  PERFORM frm_alv_disp.   "显示数据


ENDIF.
*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_get_data .

  CLEAR gt_lips[].
  SELECT
    vbeln
    posnr
    matnr
    lfimg
    arktx
    vgbel
   FROM lips
   INTO CORRESPONDING FIELDS OF TABLE gt_lips
   WHERE vbeln IN s_vbeln.

ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_PRINT_CARD
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_print_card .

  lc_print-tdnewid     = 'X'.              "新假脱机请求
  lc_print-tddest    = 'LOCL'.
  lc_print-tdimmed = 'X'.
  DATA xssfctrlop LIKE ssfctrlop.

  DATA it_print LIKE TABLE OF gs_lips WITH HEADER LINE.
  SORT gt_lips BY vbeln ASCENDING posnr ASCENDING."DN排序

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZSF_QM0070'
        IMPORTING
          fm_name            = gwk_fname
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  LOOP AT gt_lips INTO gs_lips.

    AT FIRST.
      xssfctrlop-no_close = 'X'.
    ENDAT.

    AT LAST.
      xssfctrlop-no_close = ''.
    ENDAT.
    gs_lips-posnr = gs_lips-posnr / 10.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
      EXPORTING
        input  = gs_lips-posnr
      IMPORTING
        output = gs_lips-posnr.

    "   MODIFY gt_lips FROM gs_lips TRANSPORTING posnr.

    APPEND gs_lips TO it_print.
    AT END OF vbeln.


      CALL FUNCTION gwk_fname
        EXPORTING
           control_parameters = xssfctrlop
        TABLES
*         gtd_header_text       = head_text    "header table
          gtd_item         = it_print "gt_lips    "item table
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          user_canceled    = 4
          OTHERS           = 5.

      xssfctrlop-no_open = 'X'.

      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CLEAR:it_print,it_print[].
    ENDAT.

  ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_ALV_DISP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM frm_alv_disp .

  DATA: l_repid     TYPE sy-repid,
        ls_layout   TYPE slis_layout_alv,
        lt_event    TYPE slis_t_event,
        lt_fieldcat TYPE slis_t_fieldcat_alv.
  PERFORM frm_build_layout CHANGING ls_layout.
  PERFORM frm_build_fieldcat CHANGING lt_fieldcat.
  MOVE sy-repid TO l_repid.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = l_repid
      is_layout                = ls_layout
      it_fieldcat              = lt_fieldcat
      it_events                = lt_event
      i_callback_user_command  = 'FRM_USER_COMMAND'
      i_callback_pf_status_set = 'FRM_PF_STATUS_SET'
    TABLES
      t_outtab                 = gt_lips.

ENDFORM.
FORM frm_build_fieldcat  CHANGING ct_fieldcat TYPE slis_t_fieldcat_alv.

  DATA : ls_fieldcat LIKE LINE OF ct_fieldcat.
  REFRESH ct_fieldcat.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'ZQM007_STR_LIST'
    CHANGING
      ct_fieldcat      = ct_fieldcat.

  LOOP AT ct_fieldcat INTO ls_fieldcat.

    CASE ls_fieldcat-fieldname.
      WHEN 'VGBEL'.
        IF sy-langu = '1'.
          ls_fieldcat-seltext_l = '销售单'.
        ELSE.
          ls_fieldcat-seltext_l = 'Sales Order'.
          ls_fieldcat-seltext_m = 'Sales Order'.
          ls_fieldcat-seltext_s = 'Sales Order'.
        ENDIF.

    ENDCASE.

    MODIFY ct_fieldcat FROM ls_fieldcat TRANSPORTING seltext_l seltext_m seltext_s.

  ENDLOOP.

ENDFORM.                    " frm_build_fieldcat
FORM frm_pf_status_set USING re_extab TYPE slis_t_extab.
  SET PF-STATUS 'SET_COQ_ALV'.
ENDFORM.                    "SET_PO_ALV
*&---------------------------------------------------------------------*
*&      Form  frm_build_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->CS_LAYOUT  text
*----------------------------------------------------------------------*
FORM frm_build_layout CHANGING cs_layout TYPE slis_layout_alv.
  CLEAR cs_layout.
  MOVE 'X' TO cs_layout-detail_popup.
  MOVE 'X' TO cs_layout-colwidth_optimize.
  MOVE 'COLOR' TO cs_layout-info_fieldname.
*  MOVE 'SELECTED' TO cs_layout-box_fieldname.
ENDFORM.                    "frm_build_layout
*&---------------------------------------------------------------------*
*&      Form  FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->U_UCOMM           text
*      -->US_SELECTE_FIELD  text
*----------------------------------------------------------------------*
FORM frm_user_command USING u_ucomm LIKE sy-ucomm
                            us_selecte_field TYPE slis_selfield.
  DATA: lt_selected TYPE TABLE OF zfi0030s_display,
        ls_selected LIKE LINE OF lt_selected.
  DATA: l_lines TYPE i VALUE 0.
  DATA: ls_control TYPE ssfctrlop.

  MOVE 'X' TO us_selecte_field-refresh.

  CASE u_ucomm.
    WHEN '&IC1'.  "//双击行"
      "//取得用户选择的行

      IF  us_selecte_field-fieldname EQ 'VBELN'.      "//双击销售订单,进入VA03显示界面
        READ TABLE gt_lips INTO gs_lips INDEX us_selecte_field-tabindex.
        SET PARAMETER ID 'AUN' FIELD gs_lips-vbeln. "//销售订单号
        CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
      ENDIF.

    WHEN '&PRINT'.
      PERFORM clear.
      PERFORM frm_print_card.
      PERFORM clear.
    WHEN OTHERS.

  ENDCASE.
ENDFORM.                    "FRM_USER_COMMAND
*&---------------------------------------------------------------------*
*&      Form  CLEAR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM clear .

ENDFORM.

 

  • 0
    点赞
  • 1
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:编程工作室 设计师:CSDN官方博客 返回首页
评论

打赏作者

wtxhai

你的鼓励将是我最大的动力!

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值