Quantcast
Channel: SCN : All Content - SAP Gateway
Viewing all articles
Browse latest Browse all 2823

GET_EXPANDED_ENTITYSET problem

$
0
0

Hi, I am trying to follow along this tutorial:

Implementing  Expand Entity/Entity Set

 

 

And when I debug my WebService using:

 

ZHREC_CONTR_CH_GETDETAILS_SRV/HeaderSet?$filter=Formid eq '005056BA6B481ED5B1B3EBDD61A2D44C'&$expand=NavMainDetails

 

then I noticed that the parameter lt_filter_select_options is empty (and I didn't really get from the blog where it was populated in the first place) and in the Gateway Client I get this error:

Method 'MAINDETAILSSET_GET_ENTITY' not implemented in data provider class  (???)


Scenario

I have a header table Header and infotype tables MainDetails, OrgLocation and SalaryDetails. I want to get data from the three infotype tables with 1 webservice request based on the given filter parameter Formid. Each table has the property Formid which is a key field.


Associations


associations.PNG

Navigations


navigations.PNG


My Redefined /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET


METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset.
*----------------------------------------------------------------------*
*       Deep Structure
*----------------------------------------------------------------------*   DATA: BEGIN OF ls_contr_ch_form_details.           INCLUDE TYPE zcl_zhrec_contr_ch_get_mpc=>ts_header.   DATA: navmaindetails TYPE STANDARD TABLE OF zcl_zhrec_contr_ch_get_mpc=>ts_maindetails WITH DEFAULT KEY.   DATA: navorglocation TYPE STANDARD TABLE OF zcl_zhrec_contr_ch_get_mpc=>ts_orglocation WITH DEFAULT KEY.   DATA: navsalarydetails TYPE STANDARD TABLE OF zcl_zhrec_contr_ch_get_mpc=>ts_salarydetails WITH DEFAULT KEY,         END OF ls_contr_ch_form_details,         ls_maindetails_1 TYPE zcl_zhrec_contr_ch_get_mpc=>ts_maindetails,         ls_orglocation_1 TYPE zcl_zhrec_contr_ch_get_mpc=>ts_orglocation,         ls_salarydetails_1 TYPE zcl_zhrec_contr_ch_get_mpc=>ts_salarydetails.
*----------------------------------------------------------------------*
*       Data Declaration
*----------------------------------------------------------------------*   DATA: ls_maindetails TYPE zcl_zhrec_contr_ch_get_mpc_ext=>ts_maindetails,         lt_maindetails TYPE TABLE OF zcl_zhrec_contr_ch_get_mpc_ext=>ts_maindetails,         ls_orglocation TYPE zcl_zhrec_contr_ch_get_mpc_ext=>ts_orglocation,         ts_orglocation TYPE TABLE OF zcl_zhrec_contr_ch_get_mpc_ext=>ts_orglocation,         ls_header TYPE zcl_zhrec_contr_ch_get_mpc_ext=>ts_header,         ltheader TYPE STANDARD TABLE OF zhrec_header,         lsheader TYPE zhrec_header,         lsmaindetails TYPE zhrec_contr_ch,         ltmaindetails TYPE STANDARD TABLE OF zhrec_contr_ch,         lsorglocation TYPE zhrec_it0001_wtexts,         ltorglocation TYPE STANDARD TABLE OF zhrec_it0001_wtexts,         lssalarydetails TYPE zhrec_it0008_wtexts,         ltsalarydetails TYPE STANDARD TABLE OF zhrec_it0008_wtexts,         lv_filter_str TYPE string,         lt_filter_select_options TYPE /iwbep/t_mgw_select_option,         ls_filter TYPE /iwbep/s_mgw_select_option,         ls_filter_range TYPE /iwbep/s_cod_select_option,         ls_expanded_clause1 LIKE LINE OF et_expanded_tech_clauses,         ls_expanded_clause2 LIKE LINE OF et_expanded_tech_clauses,         ls_expanded_clause3 LIKE LINE OF et_expanded_tech_clauses,         lv_formid TYPE zhrec_form_id,         lt_contr_ch_form_details LIKE TABLE OF ls_contr_ch_form_details.
*----------------------------------------------------------------------*
*       Entity Set - HeaderSet
*----------------------------------------------------------------------*   CASE iv_entity_set_name.     WHEN 'HeaderSet'.       LOOP AT lt_filter_select_options INTO ls_filter.         LOOP AT ls_filter-select_options INTO ls_filter_range.           TRANSLATE ls_filter-property TO UPPER CASE.           CASE ls_filter-property.             WHEN 'FORMID'.               lv_formid = ls_filter_range-low.             WHEN OTHERS.               " Log message in the application log               me->/iwbep/if_sb_dpc_comm_services~log_message(                 EXPORTING                   iv_msg_type   = 'E'                   iv_msg_id     =  '/IWBEP/MC_SB_DPC_ADM'                   iv_msg_number =  020                   iv_msg_v1     = ls_filter-property
*                  iv_msg_v2     =
*                  iv_msg_v3     =
*                  iv_msg_v4     =               ).               " Raise Exception               RAISE EXCEPTION TYPE /iwbep/cx_mgw_tech_exception                 EXPORTING                   textid = /iwbep/cx_mgw_tech_exception=>internal_error.           ENDCASE.         ENDLOOP.       ENDLOOP.
*----------------------------------------------------------------------*
*       Call Function - ZHREC_CONTR_CH_GETDETAIL
*----------------------------------------------------------------------*       DATA: wa_maindetails TYPE zhrec_contr_ch.       CALL FUNCTION 'ZHREC_CONTR_CH_GETDETAIL'         EXPORTING           iv_formid        = lv_formid         IMPORTING           et_maindetails   = lsmaindetails           et_orglocation   = ltorglocation           et_salarydetails = ltsalarydetails.
*----------------------------------------------------------------------*
*       Fill Header Values to Deep Structure
*----------------------------------------------------------------------*       ls_contr_ch_form_details-formid = lv_formid.
*----------------------------------------------------------------------*
*       Fill MainDetails Values to Deep Structure
*----------------------------------------------------------------------*
*      LOOP AT ltmaindetails INTO lsmaindetails.       CLEAR ls_maindetails_1.       ls_maindetails_1-formid = lsmaindetails-formid.       ls_maindetails_1-attachment = lsmaindetails-attachment.       ls_maindetails_1-ch_valid_from = lsmaindetails-ch_valid_from.       ls_maindetails_1-empforename = lsmaindetails-empforename.       ls_maindetails_1-emplastname = lsmaindetails-emplastname.       ls_maindetails_1-empno = lsmaindetails-empno.       ls_maindetails_1-hire_date = lsmaindetails-hire_date.       ls_maindetails_1-notes = lsmaindetails-notes.       ls_maindetails_1-reasontext = lsmaindetails-reasontext.       ls_maindetails_1-status = lsmaindetails-status.       APPEND ls_maindetails_1 TO ls_contr_ch_form_details-navmaindetails.
*      ENDLOOP.
*----------------------------------------------------------------------*
*       Fill OrgLocation Values to Deep Structure
*----------------------------------------------------------------------*       LOOP AT ltorglocation INTO lsorglocation.         CLEAR ls_orglocation_1.         ls_orglocation_1-formid = lsorglocation-formid.         ls_orglocation_1-company_code = lsorglocation-company_code.         ls_orglocation_1-company_code_t = lsorglocation-company_code_t.         ls_orglocation_1-cost_center = lsorglocation-cost_center.         ls_orglocation_1-cost_center_t = lsorglocation-cost_center_t.         ls_orglocation_1-employee_group = lsorglocation-employee_group.         ls_orglocation_1-employee_group_t = lsorglocation-employee_group_t.         ls_orglocation_1-employee_sgroup = lsorglocation-employee_sgroup.         ls_orglocation_1-employee_sgroup_t = lsorglocation-employee_sgroup_t.         ls_orglocation_1-orgunit = lsorglocation-orgunit.         ls_orglocation_1-payroll_area = lsorglocation-payroll_area.         ls_orglocation_1-payroll_area_t = lsorglocation-payroll_area_t.         ls_orglocation_1-personnel_sarea = lsorglocation-personnel_sarea.         ls_orglocation_1-personnel_sarea_t = lsorglocation-personnel_sarea_t.         ls_orglocation_1-peamine_ts = lsorglocation-peamine_ts.         ls_orglocation_1-position_id = lsorglocation-position_id.         ls_orglocation_1-position_id_t = lsorglocation-position_id_t.         ls_orglocation_1-position_weight = lsorglocation-position_weight.         APPEND ls_orglocation_1 TO ls_contr_ch_form_details-navorglocation.       ENDLOOP.
*----------------------------------------------------------------------*
*       Fill SalaryDetails Values to Deep Structure
*----------------------------------------------------------------------*       LOOP AT ltsalarydetails INTO lssalarydetails.         CLEAR ls_salarydetails_1.         ls_salarydetails_1-formid = lssalarydetails-formid.         ls_salarydetails_1-paysum = lssalarydetails-paysum.         ls_salarydetails_1-paytype = lssalarydetails-paytype.         ls_salarydetails_1-paytype_t = lssalarydetails-paytype_t.         ls_salarydetails_1-payvalidfrom = lssalarydetails-payvalidfrom.         ls_salarydetails_1-payvalidto = lssalarydetails-payvalidto.         APPEND ls_salarydetails_1 TO ls_contr_ch_form_details-navsalarydetails.       ENDLOOP.
*----------------------------------------------------------------------*
*       Assign the Navigation Properties name to Expand Tech clauses
*----------------------------------------------------------------------*       ls_expanded_clause1 = 'NAVMAINDETAILS'.       ls_expanded_clause2 = 'NAVORGLOCATION'.       ls_expanded_clause3 = 'NAVSALARYDETAILS'.       APPEND ls_expanded_clause1 TO et_expanded_tech_clauses.       APPEND ls_expanded_clause2 TO et_expanded_tech_clauses.       APPEND ls_expanded_clause3 TO et_expanded_tech_clauses.
*----------------------------------------------------------------------*
*       Append Deep Structure Values to Final Internal Table
*----------------------------------------------------------------------*       APPEND ls_contr_ch_form_details TO lt_contr_ch_form_details.
*----------------------------------------------------------------------*
*       Send back Response to Consumer
*----------------------------------------------------------------------*       copy_data_to_ref(         EXPORTING           is_data = lt_contr_ch_form_details         CHANGING           cr_data = er_entityset ).     WHEN OTHERS.   ENDCASE.
ENDMETHOD.

I believe the blog left out a few important details when the author thought they were self-explanatory.

 

Hopefully someone can point out what is missing or what is wrong with my modeling or code.

 

PS: If you need more info on anything, then plz let me know.


Viewing all articles
Browse latest Browse all 2823

Trending Articles