Search code examples
abapwebdynpro

Getting the value of a method call (like sy-subrc) - WebDynpro


I'm trying to make an error check. When a user enters, int his case, an airline code that doesn't exists, the page should show an error message. The thing is: i'm using BAPI_FLIGHT_GETLIST BAPI and when I execute EXECUTE_BAPI_FLIGHT_GETLIST method and try to get the sy-subrc value it always gets 0. My code it's like this:

...
 data lo_componentcontroller type ref to ig_componentcontroller .
    lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

      lo_componentcontroller->execute_bapi_flight_getlist(
       airline = lv_query                          " bapisflkey-airlineid
*       destination_from =                  " bapisfldst
*       destination_to =                    " bapisfldst
*       max_rows =                          " bapisflaux-bapimaxrow
      ).

  if sy-subrc <> 0.
          wd_this->error_check(
          ).
  endif.

even when the Carrier code doen't exist, the error message is not showing up. The method error_check( ) it's also working fine, because if i take way the if statement before it's call, the message is being shown. Hope I'm explaining myself. Thank you.


Solution

  • That BAPI doesn't set sy-subrc. It uses a return table like all BAPIs.

    here is the BAPI signature.

        FUNCTION BAPI_FLIGHT_GETLIST.
    *"----------------------------------------------------------------------
    *"*"Lokale Schnittstelle:
    *"  IMPORTING
    *"     VALUE(AIRLINE) LIKE  BAPISFLKEY-AIRLINEID OPTIONAL
    *"     VALUE(DESTINATION_FROM) LIKE  BAPISFLDST STRUCTURE  BAPISFLDST
    *"       OPTIONAL
    *"     VALUE(DESTINATION_TO) LIKE  BAPISFLDST STRUCTURE  BAPISFLDST
    *"       OPTIONAL
    *"     VALUE(MAX_ROWS) LIKE  BAPISFLAUX-BAPIMAXROW OPTIONAL
    *"  TABLES
    *"      DATE_RANGE STRUCTURE  BAPISFLDRA OPTIONAL
    *"      EXTENSION_IN STRUCTURE  BAPIPAREX OPTIONAL
    *"      FLIGHT_LIST STRUCTURE  BAPISFLDAT OPTIONAL
    *"      EXTENSION_OUT STRUCTURE  BAPIPAREX OPTIONAL
    *"      RETURN STRUCTURE  BAPIRET2 OPTIONAL
    *"----------------------------------------------------------------------
    

    The table RETURN will have your success or error messages, not sy-subrc.