Skip to Content
0
Former Member
Jan 18, 2012 at 08:53 AM

"Chained method call" and parameters export/import - how to?

308 Views

"chainged method call" (( new feature in abap nw 7.0 ehp2, briefly mentioned in Teched 10))

it works for me if there are no parameters.

BUT, when having an export and a changing parameter I get an Syntax error.

here is some sample ABAP-coding

class lcl_b definition.
  public section.
    methods m1 returning value(re_c) type char1.
    methods m2
      importing im_c type char1
      changing ch_c type char1.
endclass.
class lcl_b implementation.
  method m1.
    re_c = '1'.
  endmethod.
  method m2.
    write: /'method lcl_b->m2: imported:' , im_c.
    ch_c = '2'.
  endmethod.
endclass.

class lcl_a definition.
  public section.
    methods get_b returning value(re_b) type ref to lcl_b.
  private section.
    data ref_b type ref to lcl_b.
endclass.
class lcl_a implementation.
  method get_b.
    IF me->REF_B is not bound.
      create object me->REF_B. "lazy initialization
    ENDIF.
    re_b = me->REF_B.
  endmethod.
endclass.
form test_chained_oop_call_bug1.
  data l_c type char1.
  data l_s type string.
  data lr_a type ref to lcl_a.
  data lr_b type ref to lcl_b.

  create object lr_a.
  l_s = lr_a->GET_B( )->M1( ). "OK
  write: /'OK1:', l_s.

  lr_b = lr_a->GET_B( ).
  lr_b->M2( EXPORTING im_c = 'B'  CHANGING ch_c = l_c  ).
  write: /'OK2:',l_c.

  lr_a->GET_B( )->M2( EXPORTING im_c = 'B'  CHANGING ch_c = l_c  ).
  "^<->Syntax Error:
  "   Unerwartetes Wort "EXPORTING" in funktionalem Methodenaufruf
endform.