Skip to Content
Author's profile photo ARSHAD SHAIKH

Simple Step-by-Step SAP-Gateway Service Guide

Hi All,

Finally thought of writing blog  after struggling to create simple o-data service to perform basic operations including media and deep entities.

So I don’t want you all to struggle and waste your time…

This is for Beginners not for Experts 😉 ,

Create your simple gateway service by following provided steps.

Service is all about Employee Information System.

Tables Used.

   1. Employee Details table[Principle data]Or[Header Information]

EmployeeTable[Header].PNG

   2. Employee Contact details(Ph no on working days and on leave)[Line Item]

EmployeeContactDetails[Line]Sub.PNG

3.  Employee Photo Details.

EmployeePhoto[Sub].PNG

Structures Used

[But U can directly use Database tables to include structure to create Data types]

1. Employee Details.

EmployeeDetailsStructure.PNG

 

2.  Employee Address Info[Include structure in Emp Details table].

EmployeeDetailsAddressInclude.PNG


3.  Employee Contact details(Info like Contact no during working days and on leave).

EmployeeContactDetailsStructure.PNG

 

4. Employee Photo details.

EmployeePhotoStructure.PNG

Lets start rocket science 😆 ,

Here we go,

Create your simple gateway service, following provided steps.

using table and structure list below with Project Details.

     1. Log onto the SAP NetWeaver Gateway system.

     2. Open transaction SEGW.

     3. The SAP NetWeaver Gateway Service Builder opens.

     4. Create a new project.

    create.PNG

            5.  Enter project name and meaningful description.

               CreateProjectDetails.PNG

               Your project is created,


Entity Type

      6.  Right click on the Data Model folder and select  Import DDIC  Structure .

  1. DDIC.png

7. Following window will appear, In ABAP Structure field

          You can import the following DDIC structures

          into the Service Builder:

        • Views
        • Database tables
        • Structures

     8.  Press enter below window will appear,

     9.  Select at-least one key or more than one keys according to requirement

         in Usage column.

     10. You can directly create complex types by adding

         Deep structure (Structure within structure).

               /wp-content/uploads/2014/11/add_struc_577381.png

Entity Set

      11. Create Entity set for each Entity type.

Right click on Entity sets->select create

CreateEset.png


     12. Press F4 on Entity type field and select entity type,

                 Enter Entity Set name click okay,

          EntitySetCreate.PNG

     13.     Create Entity Sets for each entity type.

    

Association.

     14.     If you have Header Entity[Principal or Parent]

             and LineItem Entity[Dependent Information]

      Or

      If you want to create Relationship between 2 entities

          Ex: Purchase Order header and Line Items.

              Or

          Ex: Employee Details[Main] like id and name and Employee

              Contatct details[Dependent] many.

      15.      Right click on Association->create

          CreateAssoc.png

     16. Enter the Association name,

     17. Press F4 on Entity Type name and select Parent[Header Info]

         Entity type.

     18. Specify proper cardinality between entity types.

     19. Specify Navigation Property name[This will be used in URL to navigate from parent to child and child           to parent, In our case its only from parent to child] .

     AssociationWin.PNG

     20. Click next.

     21. Press F4 on Dependent property select the key field which is

         common among both.

     22. Click next.

  1. RelationShip.PNG

     23. Check Entries are proper.

     24. Click Finish,

          Next window.PNG

Once after creating Entity Types, Entity Sets, Associations, Navigation Properties.

Your Project View look like this.

    

Project Details


ProjectStructure.PNG

ProjectStucture2.PNG

     1. Click on Generate Runtime objects.

     GenerateRuntimeObject.PNG

     2. Expand Runtime artifacts.

     3. Right click on Class which ends with DPC_EXT and select Go to ABAP Workbench.

        Workbench.png

     4. Redefine the methods which mentioned below.

     5. Paste the code[Put break-point if u want to check behavior of methods called    based on URL].

     6. Expand Service maintenance.

     7. Right click on system in which you created these objects.

     8. Click on  Register and select proper System in RFC System alias.

     9. Right click again on Selected system and click maintain.

    10. Pop up will appear asking for redirection Click Yes.

    11. Click on Gateway Client.

Redirected.PNG

    12. Click Execute to test.

    13. Status 200 shows service is created correctly.

    14. Paste URL in Requested URI field and Click Execute. Check respective methods by keeping breakpoints               as given below.

GatewayClient.PNG

     15. Click Execute to test.

     Status 200 shows service is created correctly.

     16.Paste URL in Requested URI field and Click Execute.

     17.Check respective methods by keeping breakpoints as given below.

 

READ.

             

URL :

To get single record.

——————————/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet(EMP_ID=’1′)

METHOD empdetailsset_get_entity.
DATA: ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
ls_emp_tab
TYPE zxx_emp_det.

READ TABLE it_key_tab INTO ls_key_tab WITH KEY name = ‘EMP_ID’.
SELECT SINGLE * FROM zxx_emp_det INTO ls_emp_tab WHERE emp_id = ls_key_tabvalue.
IF sysubrc = 0.
MOVE-CORRESPONDING ls_emp_tab TO er_entity.
MOVE-CORRESPONDING ls_emp_tab TO er_entitydetails.
ENDIF.
ENDMETHOD.

SUCCESS CODE : 200

URL:

To get all records from table respect to EntitySet.

——————————-/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet

To get records based on where condition.

——————————/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet?$filter=EMP_ID eq ‘1’

We can add more conditions using & Operator in between fields.

METHOD empdetailsset_get_entityset.

DATA: lt_emp_tab    TYPE TABLE OF zxx_emp_det,
ls_emp_tab   
TYPE          zxx_emp_det,
es_entityset 
TYPE          zcl_zemployee_info_mpc=>ts_empdetails.

SELECT * FROM zxx_emp_det INTO TABLE lt_emp_tab WHERE (iv_filter_string).
IF sysubrc = 0.
LOOP AT lt_emp_tab INTO ls_emp_tab.
MOVE-CORRESPONDING  ls_emp_tab    TO es_entityset.
MOVE-CORRESPONDING  ls_emp_tab    TO es_entitysetdetails.
APPEND              es_entityset  TO et_entityset.
CLEAR ls_emp_tab.
ENDLOOP.
ENDIF.
ENDMETHOD.

SUCCESS CODE : 200




CREATE


Steps :

  1. 1.Get any record from GET_ENTITY ..
  2. 2.After getting click on Use as request.
  3. 3.Change details what you want to create in left window.
  4. 4.Check POST method of HTTP.
  5. 5.Use URL..

—————————/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet

method ZEMPDETSTRSET_CREATE_ENTITY.
DATA: ls_emp_details TYPE zxx_emp_det.
“Get the created entity here
io_data_provider
->read_entry_data( IMPORTING es_data = er_entity ).
MOVE-CORRESPONDING er_entity TO ls_emp_details.
MOVE-CORRESPONDING er_entitydetails TO ls_emp_details.
INSERT zxx_emp_det FROM ls_emp_details
endmethod.

SUCCESS CODE : 201



UPDATE

To Update the Record.

Follow same steps as for CREATE_ENTITY.

Just Change URL and Check HTTP  PUT Method.

  1. URL.

—————————/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet(EMP_ID=’1′)

But on response   body nothing will be displayed..

For that we need to call get entity internally.

method EMPDETAILSSET_UPDATE_ENTITY.
DATA: ls_emp_details TYPE zxx_emp_det.

“Get the created entity here
io_data_provider
->read_entry_data( IMPORTING es_data = er_entity ).
MOVE-CORRESPONDING er_entity TO ls_emp_details.
MOVE-CORRESPONDING er_entitydetails TO ls_emp_details.
MODIFY zxx_emp_det FROM ls_emp_details.

endmethod.

SUCCESS CODE : 204



DELETE


To delete record Follow same steps for create.

Check http method DELETE.

URL .

——————–/sap/ZEMPLOYEE_INFO_SRV/EmpDetailsSet(EMP_ID=’1′)

method EMPDETAILSSET_DELETE_ENTITY.
DATA: ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
ls_emp_details
TYPE zxx_emp_det.

READ TABLE it_key_tab INTO ls_key_tab WITH KEY name = ‘EMP_ID’.
IF sysubrc = 0.
ls_emp_details
emp_id   = ls_key_tabvalue.
DELETE zxx_emp_det FROM ls_emp_details.
ENDIF.
endmethod.

SUCCESS CODE : 204

 

DEEP READ


To get data of dependent with parent entity[Header with Line Items]

  1. URL.

—————————–ZEMPLOYEE_INFO_SRV/EmpDetailsSet(EMP_ID=’1′)/?$expand=EmpContDetailsNavig

METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entity.
DATA:   ls_key_tab        TYPE /iwbep/s_mgw_name_value_pair,
ls_emp_tab       
TYPE zxx_emp_det,
ls_empadd_tab    
TYPE zot_cont_det,
ls_empadd        
TYPE zot_cont_det.

DATA: ls_expand_tech_clauses LIKE LINE OF et_expanded_tech_clauses.

DATA: BEGIN OF ls_expand.
INCLUDE TYPE zcl_zemployee_info_mpc=>ts_empdetails.
DATA: empcontdetailsnavig TYPE STANDARD TABLE OF zcl_zemployee_info_mpc=>ts_empcontactdetails WITH DEFAULT KEY.
DATA: END OF ls_expand.

READ TABLE it_key_tab INTO ls_key_tab WITH KEY name = ‘EMP_ID’.

SELECT SINGLE * FROM zxx_emp_det INTO ls_emp_tab WHERE emp_id = ls_key_tabvalue.

SELECT SINGLE * FROM zot_cont_det INTO ls_empadd_tab WHERE emp_id = ls_key_tabvalue.

MOVE-CORRESPONDING ls_emp_tab TO ls_expand.
MOVE-CORRESPONDING ls_empadd_tab TO ls_empadd.
APPEND ls_empadd TO ls_expandempcontdetailsnavig.

“Assign the navigation properties
ls_expand_tech_clauses
= ’empcontdetailsnavig’.
APPEND ls_expand_tech_clauses TO et_expanded_tech_clauses.

copy_data_to_ref(
EXPORTING
is_data
= ls_expand
CHANGING
cr_data
= er_entity ).

ENDMETHOD.

SUCCESS CODE : 200




DEEP INSERT


To create deep entity.[Parent data with child][Header with Line Items]

Steps :

  1. 1.Read data from GET_EXPANDED_ENTITY
  2. 2.Made HTTP method as POST.
  3. 3.Click User as Request and Edit values You want to Insert.
  4. 4.url

———————–ZEMPLOYEE_INFO_SRV/EmpDetailsSet

  1. 5.Execute.

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY.

TYPES : ty_t_empadd TYPE STANDARD TABLE OF ZCL_ZEMPLOYEE_INFO_MPC=>TS_EMPCONTACTDETAILS WITH DEFAULT KEY.
TYPES: BEGIN OF ty_expand.
INCLUDE TYPE ZCL_ZEMPLOYEE_INFO_MPC=>TS_EMPDETAILS.
TYPES  :       EmpContDetailsNavig TYPE ty_t_empadd,
END OF ty_expand.
DATA :
*&——-> Local structures.
ls_deep_emp_details
TYPE  ty_expand,
ls_emp_cont_det    
TYPE  ZOT_CONT_DET,
ls_emp_details     
TYPE  zxx_emp_det,
*&——-> Local Itabs.
lt_emp_cont_det    
TYPE TABLE OF ZOT_CONT_DET.

io_data_provider->read_entry_data( IMPORTING es_data = ls_deep_emp_details ).

copy_data_to_ref( EXPORTING  is_data = ls_deep_emp_details
CHANGING   cr_data = er_deep_entity ).

MOVE-CORRESPONDING ls_deep_emp_details TO ls_emp_details.
MOVE-CORRESPONDING ls_deep_emp_detailsdetails TO ls_emp_details.

INSERT INTO zxx_emp_det VALUES ls_emp_details.

LOOP AT ls_deep_emp_detailsempcontdetailsnavig INTO ls_emp_cont_det.
APPEND ls_emp_cont_det TO lt_emp_cont_det.
ENDLOOP.
MODIFY zot_cont_det FROM TABLE lt_emp_cont_det.

IF sysubrc EQ 4.
ENDIF.
endmethod.

SUCCESS CODE : 201




CREATE MEDIA


  1. 1.Redefine the DEFINE METHOD OF MPC_EXT CLASS
  2. 2.Paste code.
  3. 3.We need to get key values in SLUG Parameter Of http.
  4. URL.

——————————-ZEMP_PRO_SRV/EmpDetailsSet(‘1’)/EmpPhotoNavig

  1. 4.Click on add file select image.
  2. 5.Check Post method of HTTP.
  3. 5.Execute.

method DEFINE.
super
->DEFINE( ).
DATA:
lo_entity  
type REF TO /IWBEP/IF_MGW_ODATA_ENTITY_TYP,
lo_property
type REF TO /IWBEP/IF_MGW_ODATA_PROPERTY.
lo_entity
= model->GET_ENTITY_TYPE( IV_ENTITY_NAME = ‘EmpPhoto’ ).

IF lo_entity is BOUND.
lo_property
= lo_entity->GET_PROPERTY( IV_PROPERTY_NAME = ‘MIMETYPE’ ).
lo_property
->SET_AS_CONTENT_TYPE( ).
ENDIF.
endmethod.

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM.

   DATA: ls_key_tab                   TYPE /iwbep/s_mgw_name_value_pair,

         lt_key_tab                   TYPE /iwbep/t_mgw_name_value_pair,

         ls_photo                     TYPE zemp_photos,

         lv_email                     TYPE char100.

   CASE iv_entity_name.

     WHEN ‘EmpPhoto’.

       READ TABLE it_key_tab WITH KEY name = ‘EMP_ID’ INTO ls_key_tab.

       IF SYSUBRC EQ 0.

         ls_photoemp_id = ls_key_tabvalue.

       ENDIF.

       ls_photomimetype = is_media_resourcemime_type.

       ls_photofilename = iv_slug.

       ls_photocontent = is_media_resourcevalue.

       DELETE FROM zemp_photos WHERE emp_id = ls_photoemp_id.

       INSERT INTO zemp_photos VALUES ls_photo.

       empphotoset_get_entity(

         EXPORTING

           iv_entity_name     = iv_entity_name

           iv_entity_set_name = iv_entity_set_name

           iv_source_name     = iv_source_name

           it_key_tab         = it_key_tab

           it_navigation_path = it_navigation_path

         IMPORTING

           er_entity          = ls_photo ).

       copy_data_to_ref( EXPORTING is_data = ls_photo

                         CHANGING  cr_data = er_entity ).

   ENDCASE.

endmethod.

 

READ MEDIA


Steps:

URL:

———————/ZEMPLOYEE_INFO_SRV/EmpPhotoSet(‘1’)/$value

  1. 1.Redefine GET_STREAM Method Paste code.
  2. 2.Select GET Method of HTTP.
  3. 3.Execute.

method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM.

    DATA: ls_key      TYPE /iwbep/s_mgw_name_value_pair,
lv_email   
TYPE char100,
ls_photo   
TYPE ZEMP_PHOTOS,
ls_lheader 
TYPE ihttpnvp,
ls_stream  
TYPE ty_s_media_resource,
lv_filename
TYPE w3conttype.

CASE iv_entity_name.
WHEN ‘EmpPhoto’.

READ TABLE it_key_tab WITH KEY name = ‘EMP_ID’ INTO ls_key.
lv_email
= ls_keyvalue.

SELECT SINGLE * FROM ZEMP_PHOTOS INTO CORRESPONDING FIELDS OF ls_photo WHERE EMP_ID = lv_email.
ls_stream
value = ls_photocontent.
ls_stream
mime_type = ls_photomimetype.

lv_filename = ls_photofilename.
*        lv_filename = escape( val = lv_filename
*                              format = cl_abap_format=>e_url ).
*        ls_lheader-name = ‘Content-Disposition’.
*        ls_lheader-value = |inline; filename=”{ lv_filename }”|.
*        set_header( is_header = ls_lheader ).

ls_streamvalue = ls_photocontent.
ls_stream
mime_type = lv_filename.

copy_data_to_ref( EXPORTING is_data = ls_stream
CHANGING  cr_data = er_stream ).

*        copy_data_to_ref( EXPORTING is_data = ls_stream
*                          CHANGING  cr_data = er_stream ).
ENDCASE.

 

***** SOME DUMMY REFERENCE CODE FOR SAME METHOD [CAN BE USEFUL]  ****


**TRY.
*CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM
*  EXPORTING
*    IV_ENTITY_NAME          =
*    IV_ENTITY_SET_NAME      =
*    IV_SOURCE_NAME          =
*    IT_KEY_TAB              =
*    IT_NAVIGATION_PATH      =
**    io_tech_request_context =
**  IMPORTING
**    er_stream               =
*    .
** CATCH /iwbep/cx_mgw_busi_exception .
** CATCH /iwbep/cx_mgw_tech_exception .
**ENDTRY.

*DATA: ls_stream    TYPE         ty_s_media_resource
*      ,lo_api    TYPE REF TO  if_mr_api
*      ,lv_entity_name TYPE  /IWBEP/MGW_TECH_NAME
*      ,er_entity type REF TO DATA
*      ,lr_entity TYPE REF TO DATA
*      ,empphotoset_get_entity TYPE ZCL_ZEMP_PRO_MPC=>TS_EMPPHOTO
*      ,ls_content type table of TBL1024 initial size 0
*      ,ls_xstring type xstring
*      ,lt_messg type table of BAPIRET2 initial SIZE 0
*      ,lv_pernr(8) TYPE n
*      ,t_photo type table of TBL1024
*      ,l_photo type XSTRING
*      ,l_line type string
*      ,l_photo1 type string
*      ,ls_ret type BAPIRET2
*      ,ls_photo type ZEMP_PHOTOS
*      ,t_msg type table of BAPIRET2.
*
*lv_entity_name = io_tech_request_context->GET_ENTITY_TYPE_NAME( ).
*
*CASE lv_entity_name.
*
*      WHEN ‘ZsempDet’.
*      WHEN ‘EmpPhoto’.
*
*     empphotoset_get_entity(
*           EXPORTING iv_entity_name     = iv_entity_name
*                     iv_entity_set_name = iv_entity_set_name
*                     iv_source_name     = iv_source_name
*                     it_key_tab         = it_key_tab
*                     it_navigation_path = it_navigation_path
*                     io_tech_request_context = io_tech_request_context
*           IMPORTING er_entity          = empphotoset_get_entity
*                                 ).
*
*           IF empphotoset_get_entity IS NOT INITIAL.
**     Send specific entity data to the caller interface
*           copy_data_to_ref(
*                     EXPORTING
*                     is_data = empphotoset_get_entity
*                     CHANGING
*                     cr_data = er_entity
*                          ).
*           ELSE.
**         In case of initial values – unbind the entity reference
*           er_entity = lr_entity.
*           ENDIF.
*
*           lv_pernr = empphotoset_get_entity-emp_id.
*
*           CALL FUNCTION ‘PAD_PHOTO_UPDATE_GET_DETAIL’
*           EXPORTING
*                IV_EMPLOYEE_NUMBER         = lv_pernr
*
*           TABLES
*                T_PHOTO_ARCHIVE_OUT        = t_photo
*                T_MESSAGES_OUT             = t_msg
*                .
*
**           LOOP AT t_photo into  ls_photo.
**                l_line = ls_photo-line.
**                concatenate l_photo1 l_line into l_photo1.
**           ENDLOOP.
*
*               ls_stream-value = l_photo = l_photo1.
*               ls_stream-mime_type = ‘image/jpeg’.
*
*               copy_data_to_ref( EXPORTING is_data = ls_stream
*                                 CHANGING  cr_data = er_stream ).
*
*      WHEN OTHERS.

*ENDCASE.

endmethod.

Entity Types.

https://help.sap.com/saphelp_nw74/helpdata/en/bb/dc22512c312314e10000000a44176d/content.htm

Entity Sets.

https://help.sap.com/saphelp_nw74/helpdata/en/b6/dc22512c312314e10000000a44176d/content.htm

  1. Associations.

https://help.sap.com/saphelp_nw74/helpdata/en/07/dc22512c312314e10000000a44176d/content.htm

Navigation Properties.

http://help.sap.com/saphelp_nw74/helpdata/en/3f/dd22512c312314e10000000a44176d/content.htm



—————————————————————————————–

—————————————————————————————–

Guys,


If you observe here we are processing only one entity at a time,But in real time scenario we may have to process multiple entities in an instance. 

so for multiple entity processing we need batch processing, Please refer this blog Simple steps to perform Batch Operations in SAP Gateway Services.

—————————————————————————————–

—————————————————————————————–


Thanks,


Arshad Shaikh — 🙂 .

Assigned Tags

      51 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      nice one arshad

      Author's profile photo Amarnath Prasad
      Amarnath Prasad

      Nice blog....but no need of structure, you  can use same table for importing DDIC Structure.

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Yeah, We can..But I included address details structures to achieve Complex type concept,

      If we don't want some fields then we can eliminate at the time of adding Entity Type.

      Author's profile photo Former Member
      Former Member

      Very helpful document!!!Thanks

      Author's profile photo Irfan Gokak
      Irfan Gokak

      Hi Arshad,

       

           Very helpful info.. thankssss

      Author's profile photo Former Member
      Former Member

      awesome blog.

      Author's profile photo Ganesh Rangopanth
      Ganesh Rangopanth

      Nice blog,

      It helped me a lot  .

      Author's profile photo Former Member
      Former Member

      good resource very helpful.

      Author's profile photo Former Member
      Former Member

      Its really great blog for beginners, thanks for sharing..I was finding blog to start development on oData. this is very nice.

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Thank you, Adhimoolam...

      Author's profile photo Rama Sudhakar
      Rama Sudhakar

      Hi Arshad,

       

      Nice work it was really help full document, thank for sharing the doc..

      Please keep on posting any need full documents

       

      Regards

      Sudhakar

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Thank you for your support,

      I'll keep posting.

      Author's profile photo Former Member
      Former Member

      Wonderful work Arshad, really very useful

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Thank you

      Author's profile photo Former Member
      Former Member

      I am unable to see the employee table structure i mean there is no such employee table should i create it by myself or am i doing something wrong.

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Hi Sibtain,

       

      In Tables Used. first table is

       

      1. Employee Details table[Principle data]Or[Header Information]

      Yes, U need to create custom table,U can find fields and details in above Image.

       

       

      Regards,

      Arshad Shaikh.

      Author's profile photo abhijeet kankani
      abhijeet kankani

      Keep sharing your knowledge!!!

      Author's profile photo Nandish m
      Nandish m

      Nice blog... for beginners ..

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Thank You Nandish

      Author's profile photo Christian Weiß
      Christian Weiß

      Hi Arshad,

       

      very helpful, thank you for sharing...

       

      Regards

        Christian

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Thank You Christian

      Author's profile photo Siva prasad Ramani
      Siva prasad Ramani

      Hi Arshad thanks for sharing valuable info..

       

      Moderator comments:

      Comments trimmed.

      Author's profile photo Krishna Kishor Kammaje
      Krishna Kishor Kammaje

      Shiva, Make use of forums for asking questions.

      Author's profile photo Former Member
      Former Member

      @ Krishna Kishore .. Agree

      Author's profile photo Former Member
      Former Member

      Thank you Siva prasad Ramani..

       

      Please let me know if you have any questions regarding this blog..

       

      Regards,

      Arshad

      Author's profile photo Siva prasad Ramani
      Siva prasad Ramani

      Hi Arshad,

      Thank you for sharing valuable info..

       

      I'm struggling when create file in service.

      Please check it once.

      This is my Entity type and Entity set in my service.

       

      /wp-content/uploads/2015/02/q1_639670.png

      This is my DEFINE method.

      /wp-content/uploads/2015/02/q2_639671.png

      And here is my create_stream method.

      /wp-content/uploads/2015/02/q3_639672.png

      So when i add selected service I'm getting this warning.

      /wp-content/uploads/2015/02/q4_639673.png

      And when click on EntitySets, displays this information message.

      /wp-content/uploads/2015/02/q5_639674.png

      If i use Define method getting warning "Service was created but meta data could not be loaded" when add service.

      Problem there is in DEFINE method i guess.

      How can i resolve it.?

       

      Thanks,

      Siva R.

      Author's profile photo Former Member
      Former Member

      Hi Shiva,

       

      Problem is with your metadata and I can see only one attribute in your Entity Type but To fetch data from Request side of Gateway client.Entity should contain type of rawstring .. as for i see there is no raw string in your entity.. check the structure which i used for Media Entity Type.


      you can check..

      Service 'ZABC' was created but metadata could not be loaded

       

      Thanks,

      Arshad

      Author's profile photo Siva prasad Ramani
      Siva prasad Ramani

      Hi Arshad.

      I have a urgent requirement on this scenario.

      I have taken Entity as you said above.Again I'm facing same issue.

      Check here is my screen shorts.

      /wp-content/uploads/2015/02/a_1_639757.png

      Taken Entity as a media type.

      /wp-content/uploads/2015/02/a_2_639758.png

      Imported Dictionary structure.

      /wp-content/uploads/2015/02/a_3_639759.png

      Still getting same warning when add service.

      /wp-content/uploads/2015/02/again_iss_639760.png

      Regards,

      Siva R.

      Author's profile photo Kedar Tingikar
      Kedar Tingikar

      Awesome blog Arshad. I like the lucid explanation for every step.

       

      Got more clarity on the Association part.

       

      Regards,

      Kedar

      Author's profile photo Former Member
      Former Member

      Hi Kedar,

      Thank you.

      Author's profile photo Nandakumar S Nair
      Nandakumar S Nair

      Hi Arshad,

       

      Thanks for sharing. Very good document for beginners.

       

      Keep posting.

       

      Thanks & regards,

      Nandakumar S

      Author's profile photo Former Member
      Former Member

      Hi Nandakumar,

       

      Thank you .

      Let me know if you have any questions..

      Author's profile photo Former Member
      Former Member

      Hi Arshad,

       

      First,.. Thanks for Sharing, this is very helpful for beginners like me.

       

      Actually im faceing a Problem by implementing it like this. When i try to send an picture via Post i always get an Error. (415 : Unsupported Media Type)

       

      this is my Request:

      1.JPG

       

      and this is the Response:

      2.JPG

       

      what i have to do to make it work?

       

      Regards!

      Sascha

      Author's profile photo ARSHAD SHAIKH
      ARSHAD SHAIKH
      Blog Post Author

      Hi Sascha,

       

      Problem is in your request,You may entered wrong URI,request body or request header.

      check once.

       

      FYI check Code 415: Unsupported media type

       

      Thanks,

      Arshad

      Author's profile photo Vishnu Pankajakshan
      Vishnu Pankajakshan

      Hi Arshad,

       

      Thanks for sharing this wonderful document,i wud like to try all these operations from UI5.

       

      Regards,

      Vishnu

      Author's profile photo Tasnim Ara
      Tasnim Ara

      Hi Arshad,

       

      Nice Blog Arshad !!!!!!!!!!!!!!!!!! Keep Updating New Operation  in Gateway !!!!!!!!!!!!!!!!!!!!!!!

      Author's profile photo Prabhu Pole
      Prabhu Pole

      Arshad,

       

      It's really helpful for beginners .... thanks alot 

      Author's profile photo Suresh Kalimahanthi
      Suresh Kalimahanthi

      Thank you ..very helpful

      Author's profile photo Timothy Muchena
      Timothy Muchena

      You are officially a Rock-Star!

       

      Thank you

      Author's profile photo Timothy Muchena
      Timothy Muchena

      Is it possible to have Details structure as a table type to cater for scenarios where you have more than one detail records for an employee?

      Author's profile photo UMAKANT PATIL
      UMAKANT PATIL

      Hello sir ,

      while uploading media you are passing navigation name  , but  you have not created  navigation,  

      ZEMP_PRO_SRV/EmpDetailsSet('1')/EmpPhotoNavig

      i tried by creating navigation but still its not redirecting  to to create stream method

      please suggest how i can  do that.......

       


      Author's profile photo Amarnath Prasad
      Amarnath Prasad

      No need to create navigation for uploading document.Create Entity(Check Media Type) and redefine the method define(mpc_ext).

      Use following URL for uploading  document from gateway client(/iwfnd/gw_client):-

      '/sap/opu....../ServiceName/EntitySet'  and select method as post.

       

      Step for Redefining 'Define' method:-

      Click On Runtime Artifacts->zcl_service_name.._mpc_ext->Right Click->Go to ABAP ->Workbench ->Redefine 'Define' method having code below-

      super->define( ).

       

         DATA:

           lo_entity   TYPE REF TO /iwbep/if_mgw_odata_entity_typ,

           lo_property TYPE REF TO /iwbep/if_mgw_odata_property.

       

         "Attachment is your media type entity name

         lo_entity = model->get_entity_type( iv_entity_name = 'Attachment' ).

        "MimeType  is a property of Attachment Entity

         IF lo_entity IS BOUND.

           lo_property = lo_entity->get_property( iv_property_name = 'MimeType' ).

           lo_property->set_as_content_type( ).

         ENDIF.

      Author's profile photo Gaurav Kashinath Pednekar
      Gaurav Kashinath Pednekar

      is there anything to Deep Update? Like we are changing item level data for Sales order or Purchase Order and then we are saving it . How to go about it ?

      Author's profile photo Gaurav Kashinath Pednekar
      Gaurav Kashinath Pednekar

      Please need your help on this

      Author's profile photo Former Member
      Former Member

      Hi Arshad,

       

      You are so kind to share such a helpful tutorial. There is saying that sharing is caring.

       

      You did a fantastic job!!  I will go though your instruction in details.

       

      Thanks for your efforts.

      Author's profile photo HIMANSHU GUPTA
      HIMANSHU GUPTA

      Hi Arshad,

      Very Nice document to share.

      Many thanks / Himanshu Gupta

       

      Author's profile photo Adam Krawczyk
      Adam Krawczyk

      Nice blog with core features described.

      Few additional hints to solutions:

      • When using generic methods like create_deep_entity we should check what is context entity name (io_tech_request_context->get_entity_type_name).
      • By doing this we can support creation of many complex types etc. It will work without it if we use only one complex entity type for creation, but as a good practice it is worth to do check.
      • get_expanded_entity can be redefined for performance reasons if we want to control single logic for loading many expanded entities.
      • For simple purpose we can just redefine method get_entity_set of all subsequent entities (EmpContactDetails in your example), check what is the parent (io_request->get_soruce_entity_type_name) and get keys for selection (io_request->get_converted_soruce_keys). If parent is empty it means that direct filter search is used on entity without expand.

      Regards,

      Adam

      Author's profile photo David Raven
      David Raven

      Hi,

      Can I use the media part that you describe to download PDF or DOCX?

      Thanks.

      Author's profile photo Stephen Kangethe
      Stephen Kangethe

      Hi,

       

      When I Implement the DELETE_STREAM redefinition, I am getting an error message: The requested service is not supported by entity ~<MY Table Name>

       

      The Get and Create Stream are working well but DELETE is a problem. Secondly, I noticed that using an external breakpoint the method is not getting triggered at all. Any ideas?

      Author's profile photo K Suresh
      K Suresh

      Hi Arshad,

      nice document, very helpful.

      is there a way that I can call this GetEntitySet from my Z Program

       

      Author's profile photo Dongxiao ZHANG
      Dongxiao ZHANG

      hi Arshad,

      very nice document, thanks a lot.

      I have a question about that what's the meaning of ZCL_ZEMPLOYEE_INFO_MPC=>TS_EMPCONTACTDETAILS and ZCL_ZEMPLOYEE_INFO_MPC=>TS_EMPDETAILS in deep insert.

      Actually I don't find the same static method in my own scanerio.

      I will appreciate that if you can give a little explaination.

       

      thanks in advance.