Exercise 2: Implementing a Local Function Call

Exercise 2: Implementing a Local Function Call 

Use

In all R/3 systems the CALL FUNCTION statement is an integral part of the ABAP language. This statement calls a function module locally in the same system. Write a program that calls the function module RFC_READ_SPFLI locally.

Prerequisites

To execute the program, you must have created the function group and function module described in Exercise 1.

In the procedure below we assume that you create a new APAB program using the Object Navigator. The procedure generally applies to creating new programs, even if no Programs object node exists in the object list.

Procedure

Create a Local Function Call:

  1. Call the Object Navigator (SE80).
  2. In the window Object Selection select the listbox entry Program and enter XX_RFC_Tutorial as name. Remember to replace XX with the initials of your name.
  3. Since the program XX_RFC_Tutorial does not exist, the system asks you whether to create it. Confirm with Yes.

The Create programs dialog window appears.

  1. Deactivate the With Top include option and choose Continue to leave the window.

A dialog window appears on which you can determine other program attributes.

  1. Enter the required attributes for your program and choose Save.
  2. Create the program as a Local object.

The system adds the program to the object list of the assigned development class and displays it under the Programs object node.

  1. Double-click on the program name.

The ABAP Editor appears in the tools window. It contains the program in display mode.

  1. Choose Display <-> Change ( STRG+F1 ).
  2. Write a calling program like the one below:

REPORT XX_RFC_Tutorial.

* Global Data Declaration
TABLES: spfli.
PARAMETERS: p_carrid LIKE spfli-carrid DEFAULT 'LH',
            p_connid LIKE spfli-connid DEFAULT '400'.
DATA: SYSTEM LIKE SY-SYSID.

* Calling the Function
CALL FUNCTION 'XX_RFC_READ_SPFLI'
   EXPORTING
         carrid       =  p_carrid
         connid       =  p_connid
   IMPORTING
         ex_spfli     =  spfli
         sys          =  system
   EXCEPTIONS
         invalid_data =  1.

* Handling Exceptions
CASE sy-subrc.
   WHEN 1.
       WRITE 'No data available'.
       EXIT.
ENDCASE.

* Displaying Results
WRITE: spfli-carrid,
       spfli-connid,
       spfli-cityfrom,
       spfli-cityto,
       spfli-deptime,
       spfli-arrtime.

  1. Save the program ( STRG+S ).
  2. Check the syntax ( STRG+F2 ) and activate the program ( STRG+F3 ).

If the system did not encounter any syntax errors, you can execute the program ( F8 ). To test it, you can use the pre-set values.

Result

You implemented a local function call.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值