on 12-15-2014 3:57 AM
Hello Cao,
I would suggest to quickly go through the below blog and then you will be able to change the model as required and accomplish your use scenario.
Please refer this which has in-detail explanation ->
If you wan to delegate call to Get_Entity & Get_Entity_Set based on navigation keys, You need to add the referential constraints and then you can navigate from parent to child entities based on the navigation property define between them.
Regards,
Ashwin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Cao,
Great that you are already referring to that document.
You need to add the referential constraints to navigate from parent to child entities based on the navigation keys.
However Looking at your URL,
Have you implemented Get_Entity_Set method for the entity WKXCC_USER?
You need to implement this and then should read the keys and then pass that keys to your logic to get the data.
I think you need to go and check the logic/FM as well which is used to fetch the data.
Check if that is returning the records based on the keys which you send.
This can also be a reason for the response to have no data.
Regards,
Ashwin
Hello,
My method has implemented Get_Entity_Set for the entity "WKXCC_USER" and it runs well in the backend if I enter parameter in the " IT_KEY_TAB ",this is my codes of it, Can you help me with this problem?Thanks a lot ! ^_^
method /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET.
**TRY.
*CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET
** EXPORTING
** IV_ENTITY_NAME =
** IV_ENTITY_SET_NAME =
** IV_SOURCE_NAME =
** IT_FILTER_SELECT_OPTIONS =
** IT_ORDER =
** IS_PAGING =
** IT_NAVIGATION_PATH =
** IT_KEY_TAB =
** IV_FILTER_STRING =
** IV_SEARCH_STRING =
** IO_TECH_REQUEST_CONTEXT =
** IMPORTING
** ER_ENTITYSET =
** ES_RESPONSE_CONTEXT =
* .
** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION .
** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION .
**ENDTRY.
DATA:
ls_wkxcc_user TYPE z_cl_model_provider=>wkxcc_user,
l_costcenter TYPE KOSTL,
ll_costcenter TYPE KOSTL,
l_LT_USER_LIST TYPE STANDARD TABLE OF ZIT_CC_USER,
wa_LT_USER_LIST LIKE LINE OF l_LT_USER_LIST ,
lt_temp TYPE STANDARD TABLE OF z_cl_model_provider=>wkxcc_user,
lt_wkxcc_users TYPE STANDARD TABLE OF z_cl_model_provider=>wkxcc_user,
ls_filter_user TYPE /iwbep/s_mgw_select_option.
DATA: ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
lv_costcenter TYPE KOSTL.
FIELD-SYMBOLS:
<wkxcc_user> type z_cl_model_provider=>wkxcc_user,
<key> type /iwbep/s_mgw_name_value_pair,
* <so_user> TYPE /iwbep/s_mgw_select_option,
<fs_wkxcc_users> type z_cl_model_provider=>wkxcc_users_t.
CREATE DATA er_entityset TYPE z_cl_model_provider=>wkxcc_users_t.
ASSIGN er_entityset->* to <fs_wkxcc_users>.
ls_wkxcc_user-userid = sy-uname.
* read table it_key_tab assigning <key> index 1.
* l_costcenter = <key>-value.
READ TABLE it_key_tab WITH KEY NAME = 'COSTCENTER' INTO ls_key_tab.
lv_costcenter = ls_key_tab-value.
l_costcenter = lv_costcenter.
call FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = l_costcenter
IMPORTING
OUTPUT = ll_costcenter.
call FUNCTION 'Z_GETCOSTCENTER_USERLIST'
EXPORTING
USERID = 'I004218'
COSTCENTERNOIN = ll_costcenter
TABLES
ZZ_ZIT_CC_USER = l_LT_USER_LIST.
loop at l_LT_USER_LIST into wa_LT_USER_LIST.
ls_wkxcc_user-userid = sy-uname.
ls_wkxcc_user-userout = sy-uname.
ls_wkxcc_user-costcenternoin = l_costcenter.
ls_wkxcc_user-costcenternoout = l_costcenter.
ls_wkxcc_user-id = wa_LT_USER_LIST-id.
ls_wkxcc_user-costcenter = wa_LT_USER_LIST-costcenterno.
ls_wkxcc_user-sapid = wa_LT_USER_LIST-sapid.
ls_wkxcc_user-USERNAME = wa_LT_USER_LIST-USERNAME .
APPEND ls_wkxcc_user to lt_wkxcc_users.
ENDLOOP.
if it_navigation_path is INITIAL.
loop at lt_wkxcc_users assigning <wkxcc_user>.
append <wkxcc_user> to lt_temp.
endloop.
ELSE.
* READ TABLE IT_FILTER_SELECT_OPTIONS ASSIGNING <so_user> WITH KEY property = 'CcUserDetailinfo'.
loop at lt_wkxcc_users INTO ls_wkxcc_user .
APPEND ls_wkxcc_user to lt_temp.
ENDLOOP.
endif.
loop at lt_temp ASSIGNING <wkxcc_user>.
append <wkxcc_user> to <fs_wkxcc_users>.
ENDLOOP.
endmethod.
Hello Cao,
I see that the response is not sent back correctly.
Just use the Copy_Data_To_Ref method to send back the response and issue should get resolved.
copy_data_to_ref(
EXPORTING
is_data = lt_wkxcc_users
CHANGING
cr_data = er_entityset
).
Please use the below code and check.
DATA:
ls_wkxcc_user TYPE z_cl_model_provider=>wkxcc_user,
l_costcenter TYPE KOSTL,
ll_costcenter TYPE KOSTL,
l_LT_USER_LIST TYPE STANDARD TABLE OF ZIT_CC_USER,
wa_LT_USER_LIST LIKE LINE OF l_LT_USER_LIST ,
lt_temp TYPE STANDARD TABLE OF z_cl_model_provider=>wkxcc_user,
lt_wkxcc_users TYPE STANDARD TABLE OF z_cl_model_provider=>wkxcc_user,
ls_filter_user TYPE /iwbep/s_mgw_select_option.
DATA: ls_key_tab TYPE /iwbep/s_mgw_name_value_pair,
lv_costcenter TYPE KOSTL.
FIELD-SYMBOLS:
<wkxcc_user> type z_cl_model_provider=>wkxcc_user,
<key> type /iwbep/s_mgw_name_value_pair,
* <so_user> TYPE /iwbep/s_mgw_select_option,
<fs_wkxcc_users> type z_cl_model_provider=>wkxcc_users_t.
CREATE DATA er_entityset TYPE z_cl_model_provider=>wkxcc_users_t.
ASSIGN er_entityset->* to <fs_wkxcc_users>.
ls_wkxcc_user-userid = sy-uname.
* read table it_key_tab assigning <key> index 1.
* l_costcenter = <key>-value.
READ TABLE it_key_tab WITH KEY NAME = 'COSTCENTER' INTO ls_key_tab.
lv_costcenter = ls_key_tab-value.
l_costcenter = lv_costcenter.
call FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = l_costcenter
IMPORTING
OUTPUT = ll_costcenter.
call FUNCTION 'Z_GETCOSTCENTER_USERLIST'
EXPORTING
USERID = 'I004218'
COSTCENTERNOIN = ll_costcenter
TABLES
ZZ_ZIT_CC_USER = l_LT_USER_LIST.
loop at l_LT_USER_LIST into wa_LT_USER_LIST.
ls_wkxcc_user-userid = sy-uname.
ls_wkxcc_user-userout = sy-uname.
ls_wkxcc_user-costcenternoin = l_costcenter.
ls_wkxcc_user-costcenternoout = l_costcenter.
ls_wkxcc_user-id = wa_LT_USER_LIST-id.
ls_wkxcc_user-costcenter = wa_LT_USER_LIST-costcenterno.
ls_wkxcc_user-sapid = wa_LT_USER_LIST-sapid.
ls_wkxcc_user-USERNAME = wa_LT_USER_LIST-USERNAME .
APPEND ls_wkxcc_user to lt_wkxcc_users.
ENDLOOP.
copy_data_to_ref(
EXPORTING
is_data = lt_wkxcc_users
CHANGING
cr_data = er_entityset
).
Please check.
Regards,
Ashwin
hello,
the problem is still exist.can you tell me where the "WKXCC_USERS" receive the parameter '0138040191' in WKXCC_COSTCENTERSET('0138040191')/CcUserDetailinfo?$format=json ?
I see there is a table called 'KEY_TAB' in " IT_NAVIGATION_PATH " and a table called 'IT_KEY_TAB'.
I use IT_KEY_TAB in my code.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.