cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Reading Deep Structure using RAP(Unmanaged )

Jaman
Participant
0 Likes
4,727

Hello Experts,

We have an existing Odata Service(API) created through SEGW.

Data from Freestyle UI5 application comes as an deep structure to S4H system using this API and we use /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY to read it and further post the data using BAPI.

Now we are migrating from SEGW to RAP OData services and using an unmanaged scenario to post the data.

So how do we read the data from deep structure using RAP?

My payload looks like as shown below,

{

"Field1": "Value1",

"Field2": "Value2",

"Field3": "Value3",

"Field4": "Value4",

"Field5": "Value5",

"Item" : [ {

"Field1": "Value1",

"Field6": "Value6",

"Field7": "Value7",

"Field8": "Value8",

"Field9": "Value9",

"Field10": "Value10",

}],

"Note" : [{

"Field1": "Value1",

"Field11": "Value11",

"Field12": "Value12"

},

{

"Field1": "Value1",

"Field11": "Value111",

"Field12": "Value112"

} ],

"Attach" : [ {

"Field1": "Value1",

"Field13": "Value13",

"Field14": "Value14",

"Field15": "Value15"

} ]

}

I have created CDS entity for the above structure and in the behavior implementation, the methods looks like below.

METHODS cba_Item FOR MODIFY

METHODS cba_Note FOR MODIFY

METHODS cba_Item FOR MODIFY

When these methods are triggered from Fiori Elements Application, it does not contain the complete payload but only either (Header + Item) or (Header + Note) or (Header + Attach).

So is it possible get the Complete payload as in the above structure using RAP?

Thanks,

Ahamed

Accepted Solutions (1)

Accepted Solutions (1)

j_pavan_kumar
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi makjaman,

You cannot get the entire payload in RAP just like create deep of old SEGW approach. Since you are planning to go for unmanaged scenario, during the interaction phase i.e. create or create by association on the entities keep the payload data in your own buffer tables by using CID and CID_REF of the framework provided identifiers then during your early or late save phase process these buffered tables and call your legacy logic to post data.

Thanks,

Pavan

Jaman
Participant
0 Likes

Hi Pavan,

Thanks for your reply.

May I know what exactly do you mean by buffer tables here? like a database table?

Regards,

Jaman

j_pavan_kumar
Product and Topic Expert
Product and Topic Expert

Hi Ahamed,

Try to create a singleton class and set the member tables (i.e. basically a static internal table) for each of the entities payload you receive in the interaction phase and there by you can access these table in the save sequence.

Thanks,

Pavan

Jaman
Participant
0 Likes

Hi Pavan,

Thanks for the Suggestion. Sure, I will try this out.

Do you think "Draft" functionality would be relevant here?

Thanks,

Jaman

Answers (2)

Answers (2)

Former Member

Hi makjaman,

Directly not possible in RAP but I've a workaround solution for this.

  1. Create a root custom entity with header fields
  2. Create a custom entity for line items (Any n number of custom entities can be created for different line items)
  3. Make a composition and association between header and line items as usual
  4. Create Behavior Definition for all line items by adding association between line items entity
  5. In Behavior Implementation class, create buffer class and declare static attributes for each header and line items. Implement header CREATE method and each CBA_<line_item> method and assign buffer static attributes. At the end you can use SAVE method and re-use those static attributes and call your respective process or else at the end of line items CBA_<line_item> method re-use all previously stored static attributes and call your respective process.
  6. Create Service Binding as Web API
  7. Call API from Fiori side or Gateway client by passing our deep payload as usual.
  8. During the process, header CREATE method will trigger first then CBA_<line_items> methods will trigger subsequently as given sequence in payload.

Thanks & Regards,

Bhaskar Nagula

Jaman
Participant
0 Likes

Hi Bhaskar,

Thanks for your reply.

I achieved this using "Managed Implementation with unmanaged save". Below is the code for the same for anyone interested on this.

Behavior Definition:

managed implementation in class zbp_*_header unique;

strict;

define behavior for ZI_*_HEADER alias InvHeader

with unmanaged save

lock master

authorization master ( instance )

{

create;

update;

delete;

association _item { create; }

association _note { create; }

association _return { create; }

association _attach { create; }

}

Behaviour Implementation:

CLASS lsc_zi_*_header DEFINITION INHERITING FROM cl_abap_behavior_saver.

PROTECTED SECTION.

METHODS save_modified REDEFINITION.

ENDCLASS.

CLASS lsc_zi_*_header IMPLEMENTATION.

METHOD save_modified.

**This method has parameters like create, update and delete.

**from create parameter, i was able to read the data from header, item, note entities etc.

lt_header = CORRESPONDING #( create-invheader MAPPING FROM ENTITY ).

lt_item = CORRESPONDING #( create-invitem MAPPING FROM ENTITY ).

lt_note = CORRESPONDING #( create-invnote MAPPING FROM ENTITY ).

ENDMETHOD.

ENDCLASS.

Thanks,

Ahamed