Abobe Interactive Form Practice – 2

0711490


开始我们的第二个比较具体的例子, 在本例中,我们将对练习1中的接口进行扩展, 添加销售订单行项目表, 以及两个地址信息, 本次练习主要针对数量, 日期,地址等特殊类型做些详细的说明. 而本次练习的Logo将不用静态logo, 转为传输的参数.本例不会涉及多个SO, 只拿单个SO进行打印, 废话不多说, 让我们开始吧.

要求打印的格式如下:

image

1. 接口设计:

因为还是引用上个例子中的接口, 显然在本例中我们需要加些东西. 比如销售订单的明细, 地址信息等.

为了能够更多的用到接口中的功能, 我定义了几个类型, 以及全局变量, 并且也使用了初始化代码以及子程序, 如下图:

全局变量:

image

类型定义:

image

初始化代码:

image

子程序:

image

Field symbol:

image

用到的地方:在初始化代码的地方添加如下代码:

image

传入参数中, 我们添加了销售订单的行项目数据以及logo的连接地址:

image

2. Form设计:

2.1 Context定义:

image

注意wa_header中, 因为我们只需要两个字段,所以要记得把不用的字段deactive掉.

2.2 设计Master页, 这里大家可以看到我使用了很多subform来组织各种信息, 这样的好处是直观,容易组织,也容易理解.

image

image

2.3 Master页面的数据绑定:

订货方: 绑定到wa_soldto

送货方: 绑定到wa_shipto

销售订单: 绑定到wa_header-vbeln

创建日期: 绑定到wa_header-erdat

2.4 Content Area的设计

将我们需要的item数据直接拖到content area:

image

3. 编写程序:

*&---------------------------------------------------------------------*
*& Report  ZBOBO_PDF_DEMO_002
*&
*&---------------------------------------------------------------------*
*& 作者:翱翔云天
*& 博客:www.abaptech.com
*& 描述:SO 抬头信息打印
*&---------------------------------------------------------------------*
 
REPORT  zbobo_pdf_demo_003.
TABLES: vbak.
 
*定义Form的名字
DATA: lv_form_name TYPE fpwbformname.
*定义得到的函数名字,这个函数就是form的接口
DATA: lv_fm_name TYPE rs38l_fnam.
*定义打印参数
DATA: lwa_fp_params TYPE sfpoutputparams.
*定义处理结果
DATA: lv_result TYPE sfpjoboutput.
 
data: it_header type table of vbak.
data: it_item type table of vbap.
data: url type string.
 
parameters: s_vbeln like vbak-vbeln.
 
START-OF-SELECTION.
 
  select * from vbak into corresponding fields of table it_header
   where vbeln = s_vbeln.
  select * from vbap into corresponding fields of table it_item
   where vbeln = s_vbeln.
 
*取得函数的名字
  lv_form_name = 'ZBOBO_PDF_DEMO_003'.
  CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
    EXPORTING
      i_name     = lv_form_name
    IMPORTING
      e_funcname = lv_fm_name.
 
* 这个是RFC的名字
  lwa_fp_params-connection = 'ADS'.
* 打开一个打印job
  CALL FUNCTION 'FP_JOB_OPEN'
    CHANGING
      ie_outputparams = lwa_fp_params
    EXCEPTIONS
      cancel          = 1
      usage_error     = 2
      system_error    = 3
      internal_error  = 4
      OTHERS          = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
 
*调用真正的form接口函数
  url = 'http://www.sap.com/global/images/sap_logo.gif'.
  CALL FUNCTION lv_fm_name
    EXPORTING
      it_header                = it_header
      it_item                  = it_item
      IMAGE_URL                = url
            .
 
* 关闭打印job
  CALL FUNCTION 'FP_JOB_CLOSE'
    IMPORTING
      e_result       = lv_result
    EXCEPTIONS
      usage_error    = 1
      system_error   = 2
      internal_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.

4. 执行测试:

image


About The Author

从事SAP行业有些年头,对SAP技术稍有了解; 如无特别声明,本博客文章为原创,转载请注明; 博主MSN:xuchunbo0901@hotmail.com; 博主邮箱:bob.xu@abaptech.com。

6 Comments

  1. 滕龙 说道:

    您好,代码初始化位置提示 it_item is neither specified under “tables” nor defined as a internal table. 但是我的导出位置已经定义了 it_item type zpc_customer01(数据库表) 请问我应该如何解决呢?

  2. adober 说道:

    SE11定义好了以后,出现错误:
    “ZTVBAK” is not a pre-defined type or a type from a type group.

  3. 翱翔云天 说道:

    @adober 在se11中定义.

  4. adober 说道:

    ztvbap
    ztvbak
    在哪里定义?

    谢谢! :???:

Leave A Reply


注意: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。使用'@all ',将会将评论发送给之前所有其它评论者。请务必注意user必须和评论者名相匹配(大小写一致)。

无觅相关文章插件,快速提升流量