Odata-pilot-order Creation.docx

  • Uploaded by: gvrahul
  • 0
  • 0
  • March 2021
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Odata-pilot-order Creation.docx as PDF for free.

More details

  • Words: 1,327
  • Pages: 19
Loading documents preview...
METHOD /iwbep/if_mgw_appl_srv_runtime~get_expanded_entityset. **TRY. *CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_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_EXPAND =

** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ER_ENTITYSET = ** ET_EXPANDED_CLAUSES = ** ET_EXPANDED_TECH_CLAUSES = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. TYPES: BEGIN OF ty_user, addrnumber TYPE ad_addrnum, persnumber TYPE ad_persnum, smtp_addr TYPE ad_smtpadr, END OF ty_user. DATA : BEGIN OF ty_expand_sp, i_location_email TYPE c LENGTH 50, ship_to_number TYPE c LENGTH 10, ship_to_name TYPE c LENGTH 50, sold_to_number TYPE c LENGTH 10, sold_to_name TYPE c LENGTH 50, bill_to_number TYPE c LENGTH 10, payer_numebr TYPE c LENGTH 10, rignumber TYPE c LENGTH 40, lease_name TYPE c LENGTH 40, wellidentifier TYPE c LENGTH 40, operator TYPE c LENGTH 40, csc_email TYPE c LENGTH 50, csc_phone TYPE c LENGTH 50, email_address TYPE c LENGTH 50, driver_direction TYPE string, county TYPE c LENGTH 25. DATA : zet_shipto_detail_custreqset TYPE zcl_zos_order_02_mpc_ext=>tt_zet_shipto_detail_custreq, zet_shipto_detail_prodmapset TYPE zcl_zos_order_02_mpc_ext=>tt_zet_shipto_detail_product_m, END OF ty_expand_sp. DATA : it_expand LIKE TABLE OF ty_expand_sp, ls_expand LIKE ty_expand_sp, ls_item TYPE zcl_zos_order_02_mpc_ext=>ts_zet_shipto_detail_custreq, ls_prodmap TYPE zcl_zos_order_02_mpc_ext=>ts_zet_shipto_detail_product_m. DATA : ls_expanded_clause1 LIKE LINE OF et_expanded_tech_clauses, ls_expanded_clause2 LIKE LINE OF et_expanded_tech_clauses. DATA : it_header wa_header

TYPE TABLE OF zssd_shipto_detail, TYPE zssd_shipto_detail,

it_item wa_item

TYPE TABLE OF zssd_cust_req, LIKE LINE OF it_item,

it_prodmap TYPE TABLE OF zssd_product_map, wa_prodmap LIKE LINE OF it_prodmap. DATA DATA DATA DATA

: : : :

rfc_dest TYPE zde_ca_value. lv_emailid TYPE char50. ls_user TYPE ty_user. lv_string1 TYPE string, lv_string2 TYPE string, lv_string3 TYPE string, lv_string4 TYPE string.

lv_emailid = io_tech_request_context->get_filter( )->get_filter_string( ). SPLIT lv_emailid AT `'` INTO lv_string1 lv_string2. SPLIT lv_string2 AT `'` INTO lv_string3 lv_string4. IF lv_string3 IS NOT INITIAL. lv_emailid = lv_string3. ELSE. SELECT SINGLE a~addrnumber a~persnumber b~smtp_addr FROM usr21 AS a INNER JOIN adr6 AS b ON a~persnumber = b~persnumber INTO ls_user WHERE bname = sy-uname. lv_emailid = ls_user-smtp_addr. ENDIF. SELECT SINGLE value FROM zzca_xref_prtl INTO rfc_dest WHERE 'RFC' AND attr_name = 'CONNECTION' AND counter = '1'. ls_expanded_clause1 = 'ZET_SHIPTO_DETAIL_CUSTREQSET'. ls_expanded_clause2 = 'ZET_SHIPTO_DETAIL_PRODMAPSET'. APPEND ls_expanded_clause1 TO APPEND ls_expanded_clause2 TO

et_expanded_tech_clauses. et_expanded_tech_clauses.

CALL FUNCTION 'ZSD_GET_LINKED_SHIPTO' DESTINATION rfc_dest EXPORTING i_location_email = lv_emailid IMPORTING e_shipto_details = it_header e_requirment_list = it_item e_product_map = it_prodmap. LOOP AT

it_header INTO wa_header.

application =

MOVE-CORRESPONDING wa_header TO ls_expand. LOOP AT it_item INTO wa_item WHERE ship_to_number = wa_headership_to_number. MOVE-CORRESPONDING wa_item TO ls_item. APPEND ls_item TO ls_expand-zet_shipto_detail_custreqset. CLEAR ls_item. ENDLOOP. LOOP AT it_prodmap INTO wa_prodmap WHERE ship_to_number = wa_headership_to_number. . MOVE-CORRESPONDING wa_prodmap TO ls_prodmap. APPEND ls_prodmap TO ls_expand-zet_shipto_detail_prodmapset. CLEAR ls_prodmap. ENDLOOP. APPEND ls_expand TO it_expand. CLEAR ls_expand. ENDLOOP. copy_data_to_ref( EXPORTING is_data = it_expand CHANGING cr_data = er_entityset ). ENDMETHOD.

method ZET_CUSTOMER_REQ_GET_ENTITYSET. **TRY. *CALL METHOD SUPER->ZET_CUSTOMER_REQ_GET_ENTITYSET * EXPORTING * IV_ENTITY_NAME =

* IV_ENTITY_SET_NAME = * IV_SOURCE_NAME = * IT_FILTER_SELECT_OPTIONS = * IS_PAGING = * IT_KEY_TAB = * IT_NAVIGATION_PATH = * IT_ORDER = * IV_FILTER_STRING = * IV_SEARCH_STRING = ** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ET_ENTITYSET = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. DATA : ES_ENTITY TYPE ZCL_ZOS_ORDER_02_MPC=>Ts_ZET_CUSTOMER_REQ. Es_ENTITY-REQ_NAME = ES_ENTITY-REQ_NAME. Es_ENTITY-REQ_VALUE = ES_ENTITY-REQ_VALUE. APPEND es_entity to et_entityset.

endmethod.

METHOD zet_get_next_del_get_entityset. **TRY. *CALL METHOD SUPER->ZET_GET_NEXT_DEL_GET_ENTITYSET * EXPORTING

* IV_ENTITY_NAME = * IV_ENTITY_SET_NAME = * IV_SOURCE_NAME = * IT_FILTER_SELECT_OPTIONS = * IS_PAGING = * IT_KEY_TAB = * IT_NAVIGATION_PATH = * IT_ORDER = * IV_FILTER_STRING = * IV_SEARCH_STRING = ** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ET_ENTITYSET = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. DATA : lv_shipto_number TYPE char10, lv_delivery_date TYPE d, lv_var TYPE char50, it_delivery_schedule TYPE zt_sd_delv_sch, ls_filter TYPE /iwbep/s_mgw_select_option, ls_select_options TYPE /iwbep/s_cod_select_option. DATA : rfc_dest TYPE zde_ca_value.

lv_var = io_tech_request_context->get_filter( )->get_filter_string( ). READ TABLE it_filter_select_options INTO ls_filter WITH KEY property = 'IShiptoNumber'. IF sy-subrc = 0. LOOP AT ls_filter-select_options INTO ls_select_options. lv_shipto_number = ls_select_options-low. ENDLOOP. ENDIF. READ TABLE it_filter_select_options INTO ls_filter WITH KEY property = 'IDeliveryDate'. IF sy-subrc = 0. LOOP AT ls_filter-select_options INTO ls_select_options. lv_delivery_date ENDLOOP. ENDIF.

= ls_select_options-low.

SELECT SINGLE value FROM zzca_xref_prtl INTO rfc_dest WHERE 'RFC' AND attr_name = 'CONNECTION' AND counter = '1'.

application =

CALL FUNCTION 'ZSD_GET_NEXT_DELIVERY_TIME' DESTINATION rfc_dest EXPORTING i_shipto_number = lv_shipto_number i_delivery_date = lv_delivery_date IMPORTING e_delivery_schedule = it_delivery_schedule. IF sy-subrc = 0. MOVE-CORRESPONDING ENDIF.

it_delivery_schedule TO et_entityset.

ENDMETHOD.

METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity. **TRY. *CALL METHOD SUPER->/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY * EXPORTING ** IV_ENTITY_NAME = ** IV_ENTITY_SET_NAME = ** IV_SOURCE_NAME = * IO_DATA_PROVIDER = ** IT_KEY_TAB = ** IT_NAVIGATION_PATH = * IO_EXPAND = ** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ER_DEEP_ENTITY = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. "Data declarations DATA : wa_header TYPE zssd_order_header, wa_item TYPE zssd_order_item, it_item TYPE zt_sd_order_item, wa_customer TYPE zssd_cust_req_order, it_customer TYPE zt_sd_cust_req_order, wa_message TYPE zssd_message, it_message TYPE zt_sd_message. DATA : lo_message TYPE REF TO /iwbep/if_message_container, lx_bus_ex TYPE REF TO /iwbep/cx_mgw_busi_exception. DATA : lr_deep_entity TYPE zcl_zos_order_02_mpc_ext=>ts_deep_entity. DATA : lv_ordernum TYPE char10. DATA : lvv_ordernum TYPE symsgv. DATA : rfc_dest TYPE zde_ca_value. "Reading the data io_data_provider->read_entry_data( IMPORTING es_data = lr_deep_entity ).

wa_header-order_type = lr_deep_entity-order_type. wa_header-sold_to = lr_deep_entity-sold_to. wa_header-ship_to = lr_deep_entity-ship_to. wa_header-bill_to = lr_deep_entity-bill_to. wa_header-req_del_date = lr_deep_entity-req_del_date. wa_header-req_del_time = lr_deep_entity-req_del_time. wa_header-ship_to_contact_firstname = lr_deep_entityship_to_contact_firstname. wa_header-ship_to_contact_lastname = lr_deep_entityship_to_contact_lastname. wa_header-ship_to_contact_phone = lr_deep_entity-ship_to_contact_phone. wa_header-ship_to_contact_alt_phone = lr_deep_entityship_to_contact_alt_phone. wa_header-ship_to_contact_email = lr_deep_entity-ship_to_contact_email. wa_header-ship_to_contact_alt_email = lr_deep_entityship_to_contact_alt_email. wa_header-order_source = lr_deep_entity-order_source. wa_header-driver_direction = lr_deep_entity-driver_direction. wa_header-special_delivery_note = lr_deep_entity-special_delivery_note. wa_header-alt_delivery_note = lr_deep_entity-alt_delivery_note. wa_header-created_by = lr_deep_entity-created_by. wa_header-rignumber = lr_deep_entity-rignumber. wa_header-addtive_flag = lr_deep_entity-addtive_flag. LOOP AT lr_deep_entity-zet_order_itemset INTO wa_item. APPEND wa_item TO it_item. ENDLOOP. LOOP AT lr_deep_entity-zet_customer_reqset INTO wa_customer. APPEND wa_customer TO it_customer. ENDLOOP. SELECT SINGLE value FROM zzca_xref_prtl INTO rfc_dest WHERE 'RFC' AND attr_name = 'CONNECTION' AND counter = '1'.

application =

"Calling RFC function module

* *

CALL FUNCTION 'ZSD_SALESORDER_CREATE_PORTAL' DESTINATION rfc_dest EXPORTING I_V_NEWSHIPTO = CHANGING c_v_order_num = lv_ordernum c_s_header = wa_header c_t_item = it_item c_t_customer_req = it_customer c_t_messages = it_message.

lvv_ordernum = lv_ordernum. lr_deep_entity-c_v_order_num = lvv_ordernum. "Handling Success and Error Messages

lo_message = mo_context->get_message_container( ). CALL METHOD me->/iwbep/if_mgw_conv_srv_runtime~get_message_container RECEIVING ro_message_container = lo_message.

IF it_message IS NOT INITIAL . LOOP AT it_message INTO wa_message. IF wa_message-type = 'E'. CALL METHOD lo_message->add_message EXPORTING iv_msg_type = wa_message-type iv_msg_text = wa_message-message iv_msg_id = wa_message-id iv_msg_number = wa_message-mnumber iv_add_to_response_header = abap_true. RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception EXPORTING message_container = lo_message. ELSE. IF wa_message-mnumber = '311'. CALL METHOD lo_message->add_message EXPORTING iv_msg_type = wa_message-type iv_msg_text = wa_message-message iv_msg_id = wa_message-id iv_msg_number = wa_message-mnumber iv_msg_v1 = lvv_ordernum iv_add_to_response_header = abap_true. ENDIF. * copy_data_to_ref( EXPORTING is_data = lr_deep_entity CHANGING cr_data = er_deep_entity ). ENDIF. ENDLOOP. ENDIF. *

ENDMETHOD.

METHOD zet_order_header_get_entity. **TRY. *CALL METHOD SUPER->ZET_ORDER_HEADER_GET_ENTITY * EXPORTING * IV_ENTITY_NAME = * IV_ENTITY_SET_NAME = * IV_SOURCE_NAME = * IT_KEY_TAB = ** IO_REQUEST_OBJECT = ** IO_TECH_REQUEST_CONTEXT = * IT_NAVIGATION_PATH = ** IMPORTING ** ER_ENTITY = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. DATA : lv_vbeln TYPE char10, ls_sales_details TYPE zcl_zos_order_02_mpc=>ts_zet_order_header. er_entity-order_type = ls_sales_details-order_type. er_entity-sold_to = ls_sales_details-sold_to. er_entity-bill_to = ls_sales_details-bill_to. er_entity-alt_delivery_note = ls_sales_details-alt_delivery_note. er_entity-created_by = ls_sales_details-created_by. er_entity-driver_direction = ls_sales_details-driver_direction. er_entity-i_v_newshipto = ls_sales_details-i_v_newshipto. er_entity-order_source = ls_sales_details-order_source. er_entity-order_type = ls_sales_details-order_type. er_entity-req_del_date = ls_sales_details-req_del_date.

er_entity-req_del_time = ls_sales_details-req_del_time. er_entity-ship_to = ls_sales_details-ship_to. er_entity-ship_to_contact_alt_email = ls_sales_detailsship_to_contact_alt_email. er_entity-ship_to_contact_alt_phone = ls_sales_detailsship_to_contact_alt_phone. er_entity-ship_to_contact_email = ls_sales_detailsship_to_contact_email. er_entity-ship_to_contact_firstname = ls_sales_detailsship_to_contact_firstname. er_entity-ship_to_contact_lastname = ls_sales_detailsship_to_contact_firstname. er_entity-ship_to_contact_phone = ls_sales_detailsship_to_contact_phone. er_entity-sold_to = ls_sales_details-sold_to.

ENDMETHOD.

METHOD zet_order_header_get_entityset. **TRY. *CALL METHOD SUPER->ZET_ORDER_HEADER_GET_ENTITYSET * EXPORTING * IV_ENTITY_NAME = * IV_ENTITY_SET_NAME = * IV_SOURCE_NAME = * IT_FILTER_SELECT_OPTIONS = * IS_PAGING = * IT_KEY_TAB = * IT_NAVIGATION_PATH = * IT_ORDER =

* IV_FILTER_STRING = * IV_SEARCH_STRING = ** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ET_ENTITYSET = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY. DATA : lv_vbeln TYPE char10, ls_sales_details TYPE zcl_zos_order_02_mpc=>ts_zet_order_header.

ls_sales_details-order_type ls_sales_details-sold_to ls_sales_details-bill_to

= ls_sales_details-order_type. = ls_sales_details-sold_to. = ls_sales_details-bill_to.

ls_sales_details-ship_to

= ls_sales_details-ship_to.

ls_sales_details-addtive_flag = ls_sales_details-addtive_flag. APPEND ls_sales_details TO et_entityset.

ENDMETHOD.

method ZET_ORDER_ITEMSE_GET_ENTITYSET. **TRY. *CALL METHOD SUPER->ZET_ORDER_ITEMSE_GET_ENTITYSET * EXPORTING * IV_ENTITY_NAME = * IV_ENTITY_SET_NAME = * IV_SOURCE_NAME = * IT_FILTER_SELECT_OPTIONS = * IS_PAGING = * IT_KEY_TAB = * IT_NAVIGATION_PATH = * IT_ORDER = * IV_FILTER_STRING = * IV_SEARCH_STRING = ** IO_TECH_REQUEST_CONTEXT = ** IMPORTING ** ET_ENTITYSET = ** ES_RESPONSE_CONTEXT = * . ** CATCH /IWBEP/CX_MGW_BUSI_EXCEPTION . ** CATCH /IWBEP/CX_MGW_TECH_EXCEPTION . **ENDTRY.

DATA : ES_ENTITY TYPE

ZCL_ZOS_ORDER_02_MPC=>TS_ZET_ORDER_ITEM.

Es_ENTITY-MATERIAL = ES_ENTITY-MATERIAL. Es_ENTITY-Quantity = ES_ENTITY-Quantity. APPEND es_entity to et_entityset. endmethod.

More Documents from "gvrahul"