cancel
Showing results for 
Search instead for 
Did you mean: 

Gateway enhancement options for Generic Approve Requests Fiori App

Former Member
0 Kudos

Hi Gurus,

I have seen quite a few fiori extensibility documents talking about redefining the gateway service from txn SEGW. However, when we started implementing the generic Approve Requests fiori app(CA_ALL_APV) for our Customer Invoice approval scenario, it became confusing. The app implementation information in help.sap.com does not provide any information about the gateway extensibility options for this particular app, nor i found any other documentation on SCN showing how to enhance the gateway to add additional fields to the OData service for this particular app. There is actually no gateway project for this application.

We have configured the standard app to show workitems from our custom workflow approval task and it is working perfectly fine. But, we need to show fields which are not currently exposed via OData, like Vendor ID, Vendor Name, Baseline Date, etc. I understand this is a generic application but the options to extend the app at the gateway level are not available.

So,we figured out that we should probably enhance(not modify) the standard model provider and data provider classes. So we created implicit enhancements as post-exits to the standard method DEFINE_VERSION of the model provider class /IWPGW/CL_TGW_SVC_MODEL to create new custom entity types with the property key as the the workitem id, so that we can bring the details we need for each workitem.

We call a custom method ZCREATE_CUSTOM_FIELDS_ENTITY in the post exit, which has the below implementation.

METHOD ZCREATE_CUSTOM_FIELDS_ENTITY .

   DATA lo_entity_type TYPE REF TO /iwbep/if_mgw_odata_entity_typ.

   DATA lo_property    TYPE REF TO /iwbep/if_mgw_odata_property.

   lo_entity_type = model->create_entity_type( 'InvApproval' ).

   lo_entity_type->set_creatable( abap_false ).

   lo_entity_type->set_updatable( abap_false ).

   lo_entity_type->set_deletable( abap_false ).

   lo_entity_type->set_subscribable( abap_false ).

   lo_entity_type->set_filter_required( abap_false ).

   lo_entity_type->set_addressable( abap_true ).

   lo_property = lo_entity_type->create_property( iv_property_name = 'InstanceId' iv_abap_fieldname = 'INST_ID').

   lo_property->set_is_key( abap_true ).

   lo_property = lo_entity_type->create_property( iv_property_name = 'VendorNo' iv_abap_fieldname = 'VENDORNO').

   lo_property->set_is_key( abap_false ).

   lo_property = lo_entity_type->create_property( iv_property_name = 'BaselineDt' iv_abap_fieldname = 'BASELINEDT').

   lo_property->set_is_key( abap_false ).

   lo_entity_type->bind_structure( '/IWPGW/CL_TGW_SVC_MODEL=>INVAPPROVAL' ).

   lo_entity_type->create_entity_set( 'InvApprovals' ).

ENDMETHOD.


I defined the fields INST_ID, VENDORNO, BASELINEDT under 'Types' of the same class. and i created the structure INVAPPROVAL too under 'Types' as shown below:

types:

     BEGIN OF INVAPPROVAL,

     INST_ID TYPE STRING,

     VENDORNO TYPE LIFNR,

     BASELINEDT TYPE DZFBDT,

     END OF INVAPPROVAL .

Post the changes and error free, I tested the service again, but the metadata of the service doesn't show the new entity type.


Am i doing it incorrectly?

What is the recommended and correct way to do it specifically for the 'Approve Requests' generic fiori application?


Best Regards,

Varun

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Varun

I believe this question has already been asked in

Please refer to my response in the earlier question where I have provided code snippets as well as approach.

You need to create Z project using /iwpgw/taskprocessing service as baseline and then redefine some methods that I have described in my earlier response.

Whatever you are describing and event more is possible using APPROVE REQUESTS App extension using oData enhancements and sapui5 extension project. I have built totally custom UI with several custom fields and drill downs using this approach.

thanks

Ashish

Former Member
0 Kudos

Hi Ashish,

Thanks for the info.

That information make my life easier.

Actually the enhancement i did on the standard model provider started working when i cleared the cache.

However, it looks like your approach to create a new project in SEGW might be using /iwpgw/taskprocessing as baseline will be a more sustainable one.

Thanks again. I will try it out and let you know.

Best Regards,

Varun

Former Member
0 Kudos

Hi Ashish,

Thanks again for the info.

I redefined using the service /IWPGW/TASKPROCESSING in SEGW.

Then i added our custom entity type with few properties -> created the entity set -> created the association to TaskCollection -> Generated the runtime artfacts.

Then in the data provider ext class, i redefined the below methods and placed breakpoints in all of them to check by debugging as to which methods would i actually need to add our code for retrieving the data.

GET_ENTITYSET

GET_ENTITYSET_DELTA

GET_EXPANDED_ENTITYSET

GET_EXPANDED_ENTITY

CASE_GET_ENTITY

CASE_GET_ENTITYSET.

I added our code in CASE_GET_ENTITY.

I tested with the URL /sap/opu/odata/sap/ZVFIORI_2_SRV/TaskCollection('000016511673')/InvoiceDetails

I debugged the method CASE_GET_ENTITY and it works fine. However, i get an error saying "Type of data container returned by DPC is wrong. 'Structure' is expected." I am not sure why this is happening. After debugging a bit more, i found that the error happens as the if statement fails at line 123 of class    /IWBEP/CL_MGW_ABS_DATA method READ_ENTITY. Any idea as to what is missing?

From your other post, you mentioned that you will need to redefine few more methods. How do you determine as to which method should be redefined? What methods am i missing?

Thanks,

Varun

Former Member
0 Kudos

You only need 3 methods to be redefined in your redefinition project:

1. /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY

2.CASE_EXPANDED_ENTITY

3. ENTITYSET_TASK

No other redefinitions are needed as these will be called for S2, S3 and s4 if you have line item details screen.

Please check.

thanks

A

Former Member
0 Kudos

Hi Ashish,

I am testing with these 2 URI's

/sap/opu/odata/sap/ZVFIORI_NEW_SRV/TaskCollection('000016511673')/InvoiceDetails

/sap/opu/odata/sap/ZVFIORI_NEW_SRV/InvoiceDetailsCollection('000016511673')

InvoiceDetails is my entity, InvoiceDetailsCollection is my entity set

I placed breakpoints in the above methods. However, they do not stop at these methods.

Also, both the times i get the same error saying "Type of data container returned by DPC is wrong. 'Structure' is expected."

If you want, I can send you the error file from/IWFND/ERROR_LOG.

Regards,

Varun

Former Member
0 Kudos

Thanks Ashish for your comments. I figured everything out finally.

Former Member
0 Kudos

This message was moderated.

Answers (0)