Make the method contract visible

A caller of a delivery-summary method needs to know what it must provide and what it gets back. The parameter interface is that contract.

An input and one returned value

METHODS build
  IMPORTING iv_code TYPE string
  RETURNING VALUE(rv_text) TYPE string.

IMPORTING carries input into the method. RETURNING provides one result and makes a functional method call possible:

DATA(result) = summary->build( iv_code = 'PK-204' ).

Use meaningful names and complete types so the caller can understand the method without opening its implementation.

Parameter alternatives

  • IMPORTING: input values.
  • RETURNING: one result value; often a clear choice for a calculation or transformation.
  • EXPORTING: one or more output parameters, useful when a procedure returns several distinct outputs.
  • CHANGING: an input value that the method may also update; use only when in/out behavior is intentional.

These are not interchangeable stylistic decorations. A method can have side effects, but a method that returns a value without surprising changes is often easier to test and reuse. Avoid using CHANGING merely to avoid declaring a result.

Practice

Implement build with an importing tracking code and returning text. Call it and set result; then add environment-specific output. The checker verifies fragments only.

Version note: Some expression-style method calls and inline declarations are modern syntax; confirm support in the target release and language version.

Sources

Developer practice · ABAP

Practice: return a delivery summary

Declare a summary method that accepts a tracking code and returns formatted text. Call it and assign the result.

Choose your ABAP environment

This choice changes the output pattern checked here: WRITE belongs in a classic executable report, while out->write( ) uses the supplied output reference in an ABAP Cloud class-run method. It does not switch the language version of the other code; check release and API availability in your target system.

Complete the task and include the output statement shown for your selected environment. Variable names can differ if you use them consistently. This browser checker checks structure only; it does not compile or run ABAP.

0 required structures detected · 0 checks

Debug this code

Assume lcl_dispatch declares label as an instance method. Repair the call so it uses an object instance.

Edit the code, then check for the expected repair. This is a structure check, not an ABAP compiler.