we have soap API in se37 FM - Z_VENDOR_GETDETAILS convert to REST API by Using ODATA.
Advantages :
Using REST endpoints offers simplicity and security.It simplifies API requests, making them quick and easy to manage.
Additionally, security benefits can be achieved through role access functions, allowing control over user access to specific services.
SE37 - SOAP API
Code snippet for SOAP API :
IF ip_lifnr IS NOT INITIAL AND ip_ebeln IS INITIAL.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = ip_lifnr
IMPORTING
output = ip_lifnr.
SELECT * FROM ekko INTO TABLE et_po_hdr WHERE lifnr = ip_lifnr.
IF et_po_hdr[] IS INITIAL.
ep_msg = 'No purchase order found'.
ENDIF.
ELSEIF ip_lifnr IS NOT INITIAL AND ip_ebeln IS NOT INITIAL.
SELECT * FROM ekpo INTO table et_po_item WHERE ebeln = ip_ebeln.
IF et_po_item[] IS INITIAL.
ep_msg = 'No purchase order found'.
ENDIF.
ENDIF.
We have to import SOAP API by using RFC/BOR interface in SEGW
Once you defined the all entity types make sure that artifacts must be generated.
Once your entities methods are getting generated based on your entities inside DPC_EXT Class so just provide the implementation /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY (redefine) method to perform the operation.
We have to call our main entity set and call our own method to read the data.
Code snippet for create_deep_entity method.
METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.
CLEAR er_deep_entity.
CASE iv_entity_set_name.
WHEN'VendorSet'.
er_deep_entity = _vendorgetdetails( io_data_provider ).
ENDCASE.
ENDMETHOD.
Create own method to perform the operation.
import and export parameters of _vendordetails method
To Define the structures and navigation names and calling soap API inside the method _vendorgetdetails
METHOD _vendorgetdetails.
**-- Data Declaration
DATA : BEGIN OF ls_entity.
INCLUDE TYPE zcl_zvendor_getdetail_mpc_ext=>ts_vendor.
DATA : vendorHeader TYPE zcl_zvendor_getdetail_mpc=>tt_vendorheader,
vendorItem TYPE zcl_zvendor_getdetail_mpc=>tt_vendoritem.
DATA : END OF ls_entity,
lo_message_container TYPE REF TO /iwbep/if_message_container.
**--constants
CONSTANTS: lc_type TYPE bapi_mtype VALUE 'E',
lc_id TYPE symsgid VALUE '01',
lc_number TYPE symsgno VALUE '02'.
**--intialize
io_data_provider->read_entry_data(
IMPORTING
es_data = ls_entity
).
**--Raising exception
IF ls_entity-ip_lifnr IS INITIAL.
lo_message_container = me->mo_context->get_message_container( ).
DATA(ls_return) = VALUE bapiret2( type = lc_id
number = lc_number
message = TEXT-010 ).
lo_message_container->add_message(
EXPORTING
iv_msg_type = ls_return-type " Message Type
iv_msg_id = ls_return-id " Message Class
iv_msg_number = ls_return-number " Message Number
iv_msg_text = ls_return-message " Message Text
).
RAISE EXCEPTION TYPE /iwbep/cx_mgw_busi_exception
EXPORTING
message_container = lo_message_container.
ENDIF.
**--Calling existing RFC
CALL FUNCTION 'ZVENDOR_GETDETAIL'
EXPORTING
ip_lifnr = ls_entity-ip_lifnr
ip_ebeln = ls_entity-ip_ebeln
IMPORTING
ep_msg = ls_entity-ep_msg
et_po_hdr = ls_entity-vendorheader
et_po_item = ls_entity-vendoritem.
copy_data_to_ref(
EXPORTING
is_data = ls_entity
CHANGING
cr_data = rx_deep_entity
).
ENDMETHOD.
Once you done with your implementation just maintain and activate your service in Gateway Builder.
Click on Register Button it will open new session there provide your package and click on Continue to activate the service.
Once your service Registered successfully select your service and click on SAP Gateway Client.
After Execute you will get vendor header and vendor item details in http response.
Conclusion:
this requirement basically helps in converting SOAP API to REST API to improving performance and web service based also we can use.
Hope I find it will we be helpful. If any queries please welcome on comment sections.
Regards,
Vishnu Teja.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 |