Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
sreeramg
Explorer
0 Kudos
Hi All,

Actually all of you knows the Error handling Messages in OData

But I am going to show you the Header messages at the success Status-200.

Some one knows this in other way but max number of developers don't know this scenario

 

I am going to tell you the simple way to display the Customized Header

messages at the HTTP Response.

 

Follow the below steps to create project as usual :

  1. Go to T-code SEGW.


2. Create the project and give properties.

3. Create the get entity and get entity set.

4. Give the properties and Generate Service

5. Redefine the Get entity set method.

6. Write the logic.



Code:

METHOD purchaseset_get_entityset.

***Extracting the data

SELECT * FROM ekko INTO TABLE et_entityset  UP TO 1 ROWS.

IF et_entity set IS NOT INITIAL.

**Display the header message

DATA : ls_message TYPE ihttpnvp ,

lt_message TYPE TABLE OF ihttpnvp .

ls_message-name = 'Message1'.

ls_message-value = 'SUCCESSFULY UPDATED'.

** Moving to internal table

APPEND ls_message TO lt_message.

CLEAR ls_message.

** Moving to internal table

ls_message-name = 'Message2'.

ls_message-value = 'Sucessfully Updated'.

APPEND ls_message TO lt_message.

 

**For display header message

LOOP AT lt_message INTO ls_message.

/iwbep/if_mgw_conv_srv_runtime~set_header( ls_message ).

CLEAR ls_message.

ENDLOOP.

ENDIF.

 

OUT PUT :

In this scenario I have given 2 messages with Capital and small letters and will be

displayed as Message1 and Message2.

After executing the scenario the messages will be displayed at the Success header

level status 200 at the  HTTP Response.

 


 

Thank you.

 

Some Important Articles :

https://blogs.sap.com/2021/06/10/calling-the-submit-report-program-through-the-odata-service/

https://blogs.sap.com/2019/05/17/display-the-bsp-application-without-asking-the-login-page/

https://blogs.sap.com/2017/12/06/display-countfilterorderbyinlinecounttop-and-skip-operations-using-...
Labels in this area