abap子程序

来源:互联网 发布:nt单子上数据看男女 编辑:程序博客网 时间:2024/05/28 14:56

子程序

  语法:

       form <subr>  [<pass>].

              <statemnet block>.

       endform.

    <subr>定义子程序名。 <pass>选项用于指定如何与子程序进行数据交换。

   注释:子程序中不能包含嵌套的form-endform块。

 

内部子程序

     内部子程序调用: perform <subr> [<pass>].

 data: num1 type i,
      num2 type i,
      sum type i.
     
 num1 = 2. num2 = 4.
 perform addit.
 
 num1 = 7.num2 = 11.
 perform addit.
 
 form addit.
   sum = num1 + num2.
   perform out.
 endform.
 
 form out.
   write:/ 'Sum of', num1, 'and', num2, 'is', sum.
 endform.

 

 

外部子程序

      调用外部子程序:perform <subr> (<prog>)  [<pass>]  [if found].

  程序.

    report formpool.

    form header.

        write:/ 'Program Test'.

        uline.

    endform.

      可以从程序中调用子程序,方法如下。

       report sapmztst.

       perform header (formpool) if found.


原创粉丝点击