cancel
Showing results for 
Search instead for 
Did you mean: 

Deep structure in action return

jorgehuedo
Explorer
0 Kudos

Hello experts,

my problem is the next one:

I'm trying to excecute an action that returns a deep structure, that contains an return code and a table of messages but I don't know how to define it in the model.

I have defined an entity type ActionReturn that contains the subrc and the messages.

  _entity_type = model->create_entity_type('ActionReturn').

* Properties

  _property = _entity_type->create_property( iv_property_name = 'subrc' iv_abap_fieldname = 'SUBRC' ). _property->set_type_edm_string( ).

  _property = _entity_type->create_property( iv_property_name = 'messages' iv_abap_fieldname = 'MESSAGES' ).  

  _entity_type->bind_structure('ZJHD_MODEL=>ACTIONRETURN').

And I have define the action Hello that returns the Action return defined before.

  _action = model->create_action( 'Hello' ).

  _action->set_action_for( 'User' ).

  _action->set_http_method( 'GET' ).

* Returns ActionReturns

  _action->SET_RETURN_ENTITY_TYPE('ActionReturn').

*  1..1

  _action->set_return_multiplicity( CARDINALITY_ENTITY  ).

* Input paramters are LogicalTimesheetId

  _parameter = _action->create_input_parameter( iv_parameter_name = 'userName' iv_abap_fieldname = 'USERNAME' ).

  _parameter->bind_data_element( 'SYSID' ).

Any ideas?


Accepted Solutions (1)

Accepted Solutions (1)

jibin_joy
Contributor
0 Kudos

Hi Jorge,

I hope ur getting pblm with returning message . Based on my Knowledge there are two way for  Message return .

1. Complex Type for message in entity itself

        u can add complex type in entity ( entity which is used for function return ) .The pblm with this solution is that everything will be fixed i mean "messages" property ( in above xml ) can u have only fixed child . U cannot have multiple "message"  property in single "messages" property either it should be message1 , message2 , message3 .

   In short , In entity what ever u mentioned attributes  can only used in message return (it is static) 

2. Raising Exception from Gateway service.

we can pass message to User interface by raising exception  using message container /IWBEP/IF_MGW_CONV_SRV_RUNTIME~GET_MESSAGE_CONTAINER( ) (will return message container ref)  .Using this ref u can add any number of message. The pblm with this solution is that suppose u r getting list of sales order but some sales order is not fetched because of some reason . if u raised  the exception only messages u added will be message container  will be passed on ui.

   In short , it is dynamic but it show this message only if any exception occurred .

their might be some other way for this concept but  not familiar ...

if u got any other solution

plz share in this post

Regards

Jibin Joy

jorgehuedo
Explorer
0 Kudos

Hello Jibin,

Finally I have resolved returning an entityset instead of a complexType of a plain structure normalized.

The message container weren't fit with my scenario.

If I got another solution I'll share with you!

Thanks for the help!

Jorge

jibin_joy
Contributor
0 Kudos

Hi Jorge,

Based on ur post http://scn.sap.com/thread/3257236

         U r right ,  Deep structure concept is not directly implemented in entity  . But based on my experience , we can implement deep structure concept indirectly  using $expand concept.... 

Regards ,

Jibin Joy

Answers (1)

Answers (1)

jibin_joy
Contributor
0 Kudos

Hi Jorge,

     I am little confused with above post.... can u be more specify above  ur problem u facing now.

Regards ,

Jibin Joy

jorgehuedo
Explorer
0 Kudos

Of course Jibin.

I have the action Hello that I want that returns the entity ActionReturn.

This action returns a return code and a table of messages.

The problem is I don't know how to define this deep structure of messages.

I want something like:

<actionReturn>

     <returnCode>4</returnCode>

     <messages>

          <message>error 1</message>

          <message>error 2</message>

     </messages>

</actionReturn>

Thanks.

Jorge