cancel
Showing results for 
Search instead for 
Did you mean: 

Integrate cloud workflow to Fiori elements based application

0 Kudos

Hi,

I have created fiori application using RAP. Iam trying call workflow when user use create option. So when user create new record workflow need to generate for approval.

Am Developing workflow and fiori in business application studio.

Any guided document available for this.

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor
0 Kudos

you can check the api hub, it shows what code needs to be written to call the cloud platform workflow. Below is the link, I also copied the code and pasting here

https://api.sap.com/api/SAP_CP_Workflow_CF/resource

It's very similar to how Dj adams explained in the Devtoberfest, check the below video as well, but u just need to use the below abap code to call workflow in your RAP action

https://youtu.be/SKfEfYOVQYA

TRY.
"create http destination by url; API endpoint for API sandbox 
DATA(lo_http_destination) = 
     cl_http_destination_provider=>create_by_url( 'https://sandbox.api.sap.com/workflow-service/rest/v1/workflow-instances' ).
  "alternatively create HTTP destination via destination service
    "cl_http_destination_provider=>create_by_cloud_destination( i_name = '<...>'
     "                            i_service_instance_name = '<...>' )
    "SAP Help: https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/f871712b816943b0ab5e04b6079...

"Available API Endpoints
"https://api.workflow-sap.cfapps.ap10.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.ap11.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.ap21.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.br10.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.eu10.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.eu20.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.jp10.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.jp20.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.us10.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.us20.hana.ondemand.com/workflow-service/rest
"https://api.workflow-sap.cfapps.us21.hana.ondemand.com/workflow-service/rest


"create HTTP client by destination
DATA(lo_web_http_client) = cl_web_http_client_manager=>create_by_http_destination( lo_http_destination ) .


"adding headers with API Key for API Sandbox
DATA(lo_web_http_request) = lo_web_http_client->get_http_request( ).
lo_web_http_request->set_header_fields( VALUE #( 
(  name = 'Content-Type' value = 'application/json' )
(  name = 'Accept' value = 'application/json' )
(  name = 'APIKey' value = '<API_KEY>' )
 ) ).


"Available Security Schemes for productive API Endpoints
"OAuth 2.0, OAuth 2.0
lo_web_http_request->set_text('{"definitionId":"string","context":{},"attachments":{"rootFolder":"string","groups":{"additionalProp1":{"folder":"string","refs":[{"objectId":"string"}]},"additionalProp2":{"folder":"string","refs":[{"objectId":"string"}]},"additionalProp3":{"folder":"string","refs":[{"objectId":"string"}]}}}}').


"set request method and execute request
DATA(lo_web_http_response) = lo_web_http_client->execute( if_web_http_client=>POST ).
DATA(lv_response) = lo_web_http_response->get_text( ).


CATCH cx_http_dest_provider_error cx_web_http_client_error cx_web_message_error.
    "error handling
ENDTRY.


"uncomment the following line for console output; prerequisite: code snippet is implementation of if_oo_adt_classrun~main
"out->write( |response:  { lv_response }| ).
0 Kudos

Thankq mahesh.. Your inputs helped me a lot.

maheshpalavalli
Active Contributor
0 Kudos
karimulla8 Welcome 🙂
0 Kudos

Hi Mahesh,

I am facing one issue, i have tested the work flow service from SAP API BUSINESS HUB working as expected.

i have implemented the code in RAP action, getting error like "Full authentication is required to access this resource".

i have added all the roles and scopes, still am unable to access the cloud workflow from Cloud ABAP.

any idea for this issue?

Thanks in advance..

Answers (0)