cancel
Showing results for 
Search instead for 
Did you mean: 

How to populate custom field for app Manage Customer Line Items ?

mathieu_l1
Participant
0 Kudos

I'm trying to populate a custom field in the Manage Customer Line Items app. I've redefined method ITEMSET_GET_ENTITYSET to loop over the entity set to update the custom field, but the changes are not reflected in the Fiori App where the custom field remains blank. However, updating any standard field (like ASSIGNMENTREFERENCE) does work.

Here are the steps I've followed so far:

Create APPEND structure to FAR_IFIARLINEITEM_EX containing custom field ZZTXT.

Create APPEND structure to INCL_EEW_FAR_CLI_ITEM_MD containing custom field ZZTXT.

Create SEGW project ZFAR_CUSTOMER_LINE_ITEMS and redefine data model of OData service (SAP GW) FAR_CUSTOMER_LINE_ITEMS.

Add a custom property ZZTXT to the "Item" entity type, ABAP field matching the custom field. "Creatable" "updatable" "sortable" "filterable" and "nullable" are unchecked.

Redefine ZCL_ZFAR_CUSTOMER_L_01_DPC_EXT~ITEMSET_GET_ENTITYSET to call the super method, loop over the entityset and update the ZZTXT.

Activate the project in SEGW (without errors).

This is the code in the redefined ITEMSET_GET_ENTITYSET method:

 method ITEMSET_GET_ENTITYSET.

CALL METHOD super->itemset_get_entityset
EXPORTING
iv_entity_name = iv_entity_name
iv_entity_set_name = iv_entity_set_name
iv_source_name = iv_source_name
it_filter_select_options = it_filter_select_options
is_paging = is_paging
it_key_tab = it_key_tab
it_navigation_path = it_navigation_path
it_order = it_order
iv_filter_string = iv_filter_string
iv_search_string = iv_search_string
io_tech_request_context = io_tech_request_context
IMPORTING
et_entityset = et_entityset
es_response_context = es_response_context.
* loop at result set and calculate the new field(s)
LOOP AT et_entityset ASSIGNING FIELD-SYMBOL(<fs_es>).
<fs_es>-zztxt = 'TEST 1234'.
<fs_es>-assignmentreference = 'ABABA'.
ENDLOOP.
endmethod.
jino_jose
Active Participant
0 Kudos

Hi Mathieu,

We have similar requirement, when you redefined the data model, have you picked all the models from the service FAR_CUSTOMER_LINE_ITEMS or only redefining the item models is sufficient.

I tried to redefine only the items models with overwrite base or extended service option , the additional field are visible but after that the search help on the standard fields on the app stop working.

Thanks,

Jino.

Accepted Solutions (1)

Accepted Solutions (1)

PoojaThareja
Participant

Hi mathieu.l

You can check the metadata of the service and if the other fields in the service have some aggregations properties set then you have to add those properties in MPC_EXT for your field as well. It might help to get the data. I had same issue with some another app and I followed this approach and it helped as well.

in MPC_EXT- Define method try this approach hopefully it may resolve your issue.

 LOOP AT lt_property_names ASSIGNING FIELD-SYMBOL(<ls_property_name>).
CASE <ls_property_name>-external_name.
WHEN --- Your field Name-----
<ls_property_name>-property->/iwbep/if_mgw_odata_annotatabl~create_annotation( 'sap' )->add(
EXPORTING
iv_key = 'unicode'
iv_value = 'false' ).

<ls_property_name>-property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
/iwbep/if_mgw_med_odata_types=>gc_sap_namespace
)->add(
iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).
ENDCASE.
ENDLOOP.
mathieu_l1
Participant
0 Kudos

Thanks! You're right that was the problem. I had to change your code a bit but it really helped me.

This is the code I've used:

  method DEFINE.
super->define( ).
DATA(lo_entity_type) = model->get_entity_type( 'Item' ).
lo_entity_type->set_semantic( /iwbep/if_ana_odata_types=>gcs_ana_odata_semantic_value-query-aggregate ).
lo_entity_type->get_property( 'ZZTXT' )->/iwbep/if_mgw_odata_annotatabl~create_annotation(
/iwbep/if_mgw_med_odata_types=>gc_sap_namespace )->add(
iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).
endmethod.

Answers (1)

Answers (1)

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi folks,

Glad you made it through! But just as a general warning for anyone reading this...

Please BE VERY CAREFUL to follow the correct approach for your software release... I've just had a customer on SAP S/4HANA 1909 attempting this approach in this very old way because they picked up on help from SAP Simple Finance and got into a lot of trouble.

We don't have software release context in this question... but the question mentions an approach that was used for Simple Finance and is *not* the recommended approach for current SAP S/4HANA releases.

It's so important to make sure you double-check the software release information for any help you find... Google search is notorious for giving you some REALLY old and outdated suggestions.

The correct extensibility help is available from the Fiori Apps Library - go to the app > then the Implementation tab > then the Extensibility help. Or search in the SAP Help Portal from the SAP S/4HANA product page at https://help.sap.com/s4hana_op - select your release and search for your app name e.g. App Extensibility Manage Customer Line Items.

This confirms that the correct approach is to use the SAP Fiori app F1481 Custom Fields which takes care of both the dictionary changes and the service updates. This avoids a lot of problems up front.

You can also find more information and latest techniques in the SAP Community topic page https://community.sap.com/topics/fiori/s4hana

Best

Jocelyn

dhanudjro
Participant
0 Kudos
What input should be given to API FAR_CUSTOMER_LINE_ITEMS for the ITEM(Entity) in the field Generated ID