cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass BAPI return internal table through POST method

Former Member
0 Kudos

We have below requirement, please help me know how to proceed with this:

Input Structure ZABC:

Field1

Field2

Field3

Field4...

Take the values from Input structure ZABC and create a document in SAP Backend through some BAPI.

Output:

Once the Document is created, pass the BAPI return ITAB values along with ZABC as output through Odata Service.

Thanks a lot in advance for your help.

Accepted Solutions (1)

Accepted Solutions (1)

AshwinDutt
Active Contributor
0 Kudos

Hello Madhu,

You can proceed as below as there is not direct way to send back your resultant output table along with input :


In SEGW, create model with 2 Entities say InPut and OutPut

Create association between InPut & OutPut with cardinality 1 to N

Create navigation between InPut & OutPut say Result

Generate Run-time Objects.

Now inside DPC_EXT class implement Create_Deep_Entity method.

Define a Deep Structure which will hold your input which you sent and also the resultant output table after the document creation.

Read the payload having your input data inside this method and perform create operation.

Map back the resultant table to the deep structure which is created above and finally send as GW response.

This way you will receive both input and also the response table as part of GW response.

Sample input Payload in JSON format :

{

"Field1":"01",

"Field2":"Ashwin",

"Field3":"Dutt",

"Result":[{}]

}

Where Result is the Navigation Property defined in the Model.

Please have a look at the below for technical details.

Regards,

Ashwin

Former Member
0 Kudos

Thanks a lot Ashwin

Answers (1)

Answers (1)

JyotiD
Active Participant
0 Kudos

Hi ,

You can create Properties under you entity having fileds similar to BAPI return ITAB.

Once you BAPI creates document, you can do read over ITAB and pass the required values in you ER_ENTITY structure.

Btw in case of success HTTP response header will show status as 201, and in case of failure you can handle exception which will display you error message, not sure on your use case of displaying return table in output.

Regards,

Tarun