sap script form 最简单例子

 report zform1 .

data: p_address(30) type c,
      p_date type dats.

data: result     like itcpp,
      rdi_result like rdiresult.

move '中国上海' to p_address.
move sy-datum   to p_date.

types: begin of st,
         col1 type i,
         col2 type i,
       end of st.

data: it_tab type table of st with header line,
      st_tab type          st.


do 5 times.
  st_tab-col1 = sy-index.
  st_tab-col2 = sy-index ** 2.
  append st_tab to it_tab.
enddo.

call function 'OPEN_FORM'
     exporting
          form                        = 'ZFORM1'
          language                    = sy-langu
     exceptions
          canceled                    = 1
          device                      = 2
          form                        = 3
          options                     = 4
          unclosed                    = 5
          mail_options                = 6
          archive_error               = 7
          invalid_fax_number          = 8
          more_params_needed_in_batch = 9
          spool_error                 = 10
          others                      = 11.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.


call function 'WRITE_FORM'
     exporting
          element                  = 'HEADER'
          type                     = 'BODY'
          window                   = 'HEADER'
     exceptions
          element                  = 1
          function                 = 2
          type                     = 3
          unopened                 = 4
          unstarted                = 5
          window                   = 6
          bad_pageformat_for_print = 7
          spool_error              = 8
          others                   = 9.
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 it_tab.

  call function 'WRITE_FORM'
       exporting
            element                  = 'DEC'
            type                     = 'BODY'
            window                   = 'MAIN'
       exceptions
            element                  = 1
            function                 = 2
            type                     = 3
            unopened                 = 4
            unstarted                = 5
            window                   = 6
            bad_pageformat_for_print = 7
            spool_error              = 8
            others                   = 9.
  if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

endloop.

call function 'CLOSE_FORM'
 importing
   result                         = result
   rdi_result                     = rdi_result
* TABLES
*   OTFDATA                        =
 exceptions
   unopened                       = 1
   bad_pageformat_for_print       = 2
   send_error                     = 3
   spool_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.

 

==========================================================
SE71 中的代码:

第一个write form 调用的
*** header
/E   HEADER
F1   交货地址: &P_ADDRESS& &AAA& 交货日期: &P_DATE&

----------------------------------------------------------
第二个write form 调用的
*** dec
/E   DEC
/:   SET TIME MASK = 'HH:MM'
/    &IT_TAB-COL1&,,&IT_TAB-COL2&

 

**-----------------------------------------------------------------------

补充:

**-----------------------------------------------------------------------

 

/:   BOX WIDTH 15 CM HEIGHT 1 CM FRAME 10 TW INTENSITY
F2   ID,,,,,,NAME,,,,DATA
/:   BOX WIDTH 15 CM HEIGHT 2 CM FRAME 10 TW
/:   BOX WIDTH 15 CM HEIGHT 3 CM FRAME 10 TW
/:   BOX WIDTH 15 CM HEIGHT 4 CM FRAME 10 TW
/:   BOX XPOS 3 CM WIDTH 0 TW HEIGHT 4 CM FRAME 10 TW
/:   BOX XPOS 6 CM WIDTH 0 TW HEIGHT 4 CM FRAME 10 TW
/:   BOX XPOS 9 CM WIDTH 0 TW HEIGHT 4 CM FRAME 10 TW
/:   BOX XPOS 9 CM WIDTH 0 TW HEIGHT 4 CM FRAME 10 TW
/:   BOX XPOS 9 CM WIDTH 0 TW HEIGHT 4 CM FRAME 10 TW

这个可以画出一个表格出来

 

 

 

*

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值