Skip to Content

ABAP Objects issue

when calling to method in abap objects we can write

CALL METHOD method_name

EXPORTING

param =: value1 , value2 , .... ,valuen .

but how can i call method if it get 2 parameters ?

means like

CALL METHOD method_name

EXPORTING

param1 =: ???????

param2 =: ??????? .

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Dec 13, 2004 at 03:31 PM

    Your Sample uses the repetion logic. This can only be used if the tail of the statement can be replaced in a unique manner. This case is not given for a method with several parameters due one must specify each argument by name.

    cref->method(
      arg1 = act1
      arg2 = act2).
    

    you may of course use macros:

    define mac_call_m1.
      cref->Method( arg1 = &1 arg2 = &2 ).
    end-of-definition.
    mac_call_m1:
      1  2,
      4  9.
    

    But thats nothing special for OO.

    Kind Regards

    Klaus

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2004 at 03:34 PM

    Example

    CALL METHOD object=>method

    EXPORTING

    param1 = 'PARAM1'

    param2 = 'PARAM2'.

    Another example:

    CALL METHOD cl_gui_frontend_services=>file_open_dialog

    CHANGING

    file_table = filetable

    rc = rc

    EXCEPTIONS

    file_open_dialog_failed = 1

    cntl_error = 2

    error_no_gui = 3

    not_supported_by_gui = 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.

    Please give points if it helps.

    Message was edited by: Fuat Ulugay

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 13, 2004 at 07:16 PM

    Hi Herzel

    Klaus' solution is the best way I believe. Statement chaining is a good feature of ABAP syntax, however it is restricted to some extent.

    Hence, try defining a macro as Klaus suggested or writing a subroutine.

    *--Serdar

    P.S.: Fuat, Herzel's question is not about the method calling statement, but about chaining it.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Dec 13, 2004 at 07:21 PM

    Hi,

    If you are entering a CALL METHOD within the ABAP editor, you should consider using the "Pattern" button (Ctrl+F6 in 4.6C). The Insert Statement popup has an option for "ABAP Objects patterns" (in 4.6C). Enter the Instance, Class, and Method in the Call Method section of the OO statement popup.

    Just as with function modules, it is advisable to always use the Pattern button when possible. This will help avoid typing errors and ensure that you use the correct interface and syntax. It also makes our lives much easier...

    Best Regards,

    James Gaddis

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Dec 13, 2004 at 07:37 PM

    Sorry,

    I misunderstood the original question. I saw the colons but assumed they were just part of Herzel's notation.

    Regards,

    James Gaddis

    Add comment
    10|10000 characters needed characters exceeded