cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting BAPI from Cloud SDK

former_member602262
Discoverer
0 Kudos

Hello

I'm new to SAP S/4 HANA. I'm trying to connect to a BAPI.

That BAPI is related with SAP_COM_0322 scenario (among others I wold like to connect to, also).

Is called BAPI_ALM_NOTIF_GET_DETAIL.

Our platform is Neo.

I read and follow:

(a). https://blogs.sap.com/2017/09/15/step-11-with-sap-s4hana-cloud-sdk-virtual-data-model-for-bapi/comme..., and

(b). https://blogs.sap.com/2017/12/06/deep-dive-5-with-s4hana-cloud-sdk-executing-bapis-inside-s4hana-on-...

...and many others

I was able to execute successfully the 'first-app' Cloud SDK application in order to:

- connect to business partners via odata

- connect to FinancialTransactionService via VDM (although BAPI returns an empty array, I think it's correct)

I think VDM is not available for the scenario i want to use. So, I think I must use 'the generic way' as it's said in (a) (BapiQuery...).

I get responses like:

" 500 Internal Server Error. Query execution failed with unexpected error. Response body: Headers: set-cookie: (hidden), set-cookie: (hidden), content-type: text/html, content-length: 0, connection: close, sap-server: true, sap-perf-fesrec: 30304.000000, strict-transport-security: max-age=31536000; includeSubDomains, x-xss-protection: 1; mode=block, x-content-type-options: nosniff. "

I don't know for sure if server is receiving properly the request. I'm not able to debug, monitoring the call, or similar (log is very poor...). My problem is similar to Olivier Souksamran's in (b), but I'm not able to identify a solution

Any help is welcome

Another questions:

2. Could be possible to connect to a BAPI through a simpler java project (a main, configuring endpoint, and little more ...), and not through all the infrastructure (maven archetypes with integration tests, etcetc) ?

3. Jco is an alternative here, or its purpose is different ?

Thanks in advance

Raúl

code:

@WebServlet("/notif")
public class BapiNotif extends HttpServlet {


    private static final long serialVersionUID = 1L;
    private static final Logger logger = CloudLoggerFactory.getLogger(BapiNotif.class);


    private Object getDetailsServiceNotification(String number) throws QueryExecutionException {
        final BapiQueryResult result = new BapiQuery("BAPI_ALM_NOTIF_GET_DETAIL")
                .withExporting("NUMBER", "BAPI2080_NOTHDRE_NOTIF_NO", number)
//                .withTable("NOTIFHEADER_EXPORT", "BAPI2080_NOTHDRE").end()
//                .withImporting("NOTIFHEADER_EXPORT", "BAPI2080_NOTHDRE")
//                .withTable("NOTIFHD_TEXT", "BAPI2080_NOTHDTXTE").end()
//                .withTableAsReturn("BAPIRET2")
                .execute(new ErpEndpoint());


         return result.get("NOTIFHEADER_EXPORT").getAsObject();
    }
    
    @Override
    protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
            throws ServletException, IOException {
    	
        try {
        	
        	Object o = getDetailsServiceNotification("10000005");
        	
            response.setContentType("application/json");
            response.getWriter().write(new Gson().toJson(o));


        } catch (Throwable e) {
            logger.error(e.getMessage(), e);
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            response.getWriter().write(e.getMessage());
        }
    }
}

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member186608
Active Participant
0 Kudos

Dear Raúl,

kindly consider SAP note 2447593 which, simply speaking, points out that the usage of such BAPIs in the context of S/4 Cloud is meant to be used only for the integration between S/4HANA Cloud and a SAP S/4HANA (on-premise) system.

Therefore, what you tried (to call these BAPIs from an SCP app) is not foreseen.


Kind regards

Marco

former_member186608
Active Participant
0 Kudos

I suppose you intend to connect to SAP S/4HANA Cloud. So SAP S/4HANA (on-premise) is out of scope. Is that correct?

former_member602262
Discoverer
0 Kudos

Yes, Marco, thanks