0

I am trying to call a BAPI in SAP Cloud SDK Java, not sure whats wrong with below code. Please help me here

final Destination destination =
        DestinationAccessor.getDestination("MyErpSystem").asRfc()
        .decorate(DefaultErpHttpDestination::new);
final BapiRequestResult result = new BapiRequest("BAPI_COSTCENTER_GETLIST1")
                .withExporting("CONTROLLINGAREA", "BAPI0012_GEN-CO_AREA", "A000")
                .withTable("COSTCENTERLIST", "BAPI0012_CCLIST").end().withTableAsReturn("BAPIRET2")
                .execute(destination);

it shows syntax error at destination creation.

  • 1
    Hi Prakash, welcome to stack overflow. Please always include the exact, full error message and stack trace. Also please point out what SDK version you are using. – MatKuhr Aug 20 '20 at 12:39

1 Answers1

0

One problem with your code seems to be that you try to decorate an RfcDestination as DefaultErpHttpDestination. RFC and HTTP are distinct protocols, so this decoration doesn't quite make sense and is not needed. The RfcDestination you get via asRfc() should suffice.

Check out this guide that explains in detail how to use the Cloud SDK to perform BAPI calls.

MatKuhr
  • 505
  • 4
  • 13
  • If i change the Destination type as Rfc, now the execute method call with destination is failing. The method execute(Destination) in the type BapiRequest is not applicable for the arguments (RfcDestination)Java(67108979) – Prakash Sep 21 '20 at 07:58
  • As I commented above please include the full error message and stack trace as well as the SDK version. Also update your question to reflect your updated code. Without that I can only point to the guide I already linked above. – MatKuhr Sep 30 '20 at 07:33