Class ZCL_IBMC_SERVICE

public inheriting from zcl_ibmc_service_arch create public

Documentation

ABAP SDK for IBM Watson - Service Class

Types

Visibility and LevelNameDocumentation
publicbinary type xstring 
publicboolean type zif_ibmc_service_arch~boolean 
publicchar type zif_ibmc_service_arch~char 
publicdata_reference type ref to data 
publicdate type string 
publicdatetime (typing)DateTime type, format 2018-10-23T15:18:18.914xxxZ
publicdouble type f 
publicfieldname (typing) 
publicfile type xstring 
publicfloat type f 
publicinteger type i 
publicjsonobject type ref to data 
publiclong type int8 
publicmap type ref to data 
publicnumber type f 
publicshort type int2 
publictime type string 
publicts_file_with_metadata (structured type) 
publicts_form_part type zif_ibmc_service_arch~ts_form_part 
publicts_map_file (structured type) 
publictt_boolean type standard table of zif_ibmc_service_arch~boolean with non-unique default key 
publictt_char type standard table of zif_ibmc_service_arch~char with non-unique default key 
publictt_double type standard table of double with non-unique default key 
publictt_file type standard table of file with non-unique default key 
publictt_file_with_metadata type standard table of ts_file_with_metadata with non-unique default key 
publictt_float type standard table of float with non-unique default key 
publictt_form_part type zif_ibmc_service_arch~tt_form_part 
publictt_integer type standard table of integer with non-unique default key 
publictt_long type standard table of long with non-unique default key 
publictt_map_file type standard table of ts_map_file with non-unique default key 
publictt_number type standard table of number with non-unique default key 
publictt_short type standard table of short with non-unique default key 
publictt_string type zif_ibmc_service_arch~tt_string 

Constants

Visibility and LevelNameDocumentation
public staticc_blank type string value '&#!-#&__%$X' 
public staticc_boolean_false type boolean value space 
public staticc_boolean_true type boolean value 'X' 
public staticc_datatype (structured type)  
public staticc_default type string value 'DEFAULT' 
public staticc_f_zero type f value '-2147481.648' 
public staticc_i8_zero type int8 value -9223372036854775608 
public staticc_i_zero type i value -2147481648 
public staticc_msgid type sy-msgid value 'ZIBMC' 
public staticc_subrc_unknown type sy-subrc value 999999 
public staticc_tribool_false type boolean value '-' 

Attributes

Visibility and LevelNameDocumentation
public instancep_debug_mode type char value space 
public instancep_request_prop_default type ts_request_prop  
public instancep_version type string  

Methods

Visibility and LevelNameDocumentation
public static
abap_to_json
importingi_nametype string optional
i_valuetype any
i_dictionarytype any optional
i_required_fieldstype any optional
i_lower_casetype boolean default c_boolean_true
returningvalue(e_json)type string

Extracts a JSON string from an ABAP structure.

Parameters
i_name Name of component to be extracted.
i_value ABAP structure to be converted to JSON string.
i_dictionary Dictionary to be used for mapping ABAP identifiers to JSON keys.
i_required_fields Dictionary of required fields.
If a field is required, an initial value appears as initial value in JSON structure. Otherwise it is omitted in JSON string.
i_lower_case If set to C_BOOLEAN_TRUE all keys in JSON string will be lower case.
e_json JSON string.
public static
add_header_parameter
importingi_parametertype string
i_valuetype string
i_is_booleantype boolean default c_boolean_false
changingc_headerstype zif_ibmc_service_arch~ts_request_prop-headers

Method for internal use.

public static
add_query_parameter
importingi_parametertype string
i_valuetype string
i_is_booleantype boolean default c_boolean_false
changingc_urltype ts_url

Method for internal use.

public static
get_components
importingi_structuretype any
exportingvalue(e_components)type zif_ibmc_service_arch~tt_string

Returns component names of a given structure.

Parameters
i_structure Structure with components.
e_components Internal table of component names.
public static
get_datatype
importingi_fieldtype any
returningvalue(e_datatype)type zif_ibmc_service_arch~char

Returns data type of a given parameter.

Parameters
i_field Field of type that is supposed to be determined.
e_datatype Technical type (= base type) of I_FIELD.
public static
get_field_type
importingi_fieldtype any
exportinge_technical_typetype zif_ibmc_service_arch~char
e_relative_typetype string
e_lengthtype i

Returns field type and length of a given parameter.

Parameters
i_field Field of type that is supposed to be determined.
e_technical_type Technical type (= base type) of I_FIELD.
e_relative_type Relative type (= data type) of I_FIELD.
e_length Length of type of I_FIELD.
public static
get_file_extension
importingvalue(i_mime_type)type string
returningvalue(e_extension)type string

Returns the file extension for a mime type

, e.g. 'text/plain' -> 'txt'
Parameters
i_mime_type MIME type.
e_extension File extension (without leading dot).
public static
get_full_url
importingi_urltype ts_url
returningvalue(e_url)type string

Method for internal use.

public static
move_data_reference_to_abap
importingi_data_referencetype data_reference
exportingvalue(e_abap)type any
raisingzcx_ibmc_service_exception

Moves a referenced data structure to an ABAP structure.

Parameters
i_data_reference Reference to data object.
e_abap ABAP structure to be filled.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public static
normalize_url
changingc_urltype ts_url

Method for internal use.

public static
parse_json
importingi_jsontype string
i_dictionarytype any optional
changingvalue(c_abap)type any
zcx_ibmc_service_exception

Parses a JSON string into an ABAP structure.

Parameters
i_json JSON string.
i_dictionary Dictionary for mapping of identifier names.
c_abap ABAP structure to be filled
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public static
raise_exception
importingi_msgnotype sy-msgno optional
i_msgv1type string optional
i_msgv2type string optional
i_msgv3type string optional
i_msgv4type string optional
i_texttype string optional
i_subrctype sy-subrc default c_subrc_unknown
i_previoustype ref to cx_root optional
i_http_statustype ts_http_status optional
raisingzcx_ibmc_service_exception

Raises an exception.

Parameters
i_msgno Message number.
i_msgv1 Substitution for 1st placeholder in message.
i_msgv2 Substitution for 2nd placeholder in message.
i_msgv3 Substitution for 3rd placeholder in message.
i_msgv4 Substitution for 4th placeholder in message.
i_text Message text; specify if message number is not specified.
i_subrc Return code being returned.
i_previous Exception that has been captured before.
i_http_status HTTP status code if exception is triggered by HTTP error
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised.
public static
unescape_unicode
importingi_intype string
returningvalue(e_out)type string

Unescape unicode codepoints to characters in a string

, e.g. '\u0041 b \u0063' -> 'A b c'
Parameters
i_in String with unicode codepoints.
e_out Unescaped string.
public instance
check_http_response
importingi_responsetype to_rest_response optional
i_urltype ts_url optional
raisingzcx_ibmc_service_exception

Throws an exception, if HTTP response indicates an error.

Parameters
i_response HTTP response to be checked.
i_url URL that the request has been sent to.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
constructor
importingi_urltype string optional
i_hosttype string optional
i_proxy_hosttype string optional
i_proxy_porttype string optional
i_usernametype string optional
i_passwordtype string optional
i_apikeytype string optional
i_access_tokentype ts_access_token optional
i_ssl_idtype zif_ibmc_service_arch~ty_ssl_id optional
i_debug_modetype char default space

Class constructor.

Parameters
i_url URL of the service.
i_host Host of the service. I_URL and I_HOST can be used synonymously.
i_proxy_host Proxy server, not applicable on SAP Cloud Platform.
i_proxy_port Proxy server port, not applicable on SAP Cloud Platform.
i_username User name to authenticate on service.
i_password User password to authenticate on service.
i_apikey API key password to authenticate on service.
i_access_token Access token to authenticate on service.
i_ssl_id ID of PSE, not applicable on SAP Cloud Platform.
i_debug_mode not used.
public instance
get_access_token
importingi_request_proptype ts_request_prop optional
returningvalue(e_access_token)type ts_access_token
raisingzcx_ibmc_service_exception

Method for internal use.

public instance
get_appname
returningvalue(e_appname)type string

Returns the service name.

Parameters
e_appname Name of the service.
public instance
get_request_prop
importingi_auth_methodtype string default c_default
returningvalue(e_request_prop)type ts_request_prop

Method for internal use.

public instance
get_rest_client
importingi_request_proptype ts_request_prop
returningvalue(e_client)type ts_client
raisingzcx_ibmc_service_exception

Method for internal use.

public instance
http_delete
importingi_request_proptype ts_request_prop
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP DELETE request.

Parameters
i_request_prop Request properties.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
http_get
importingi_request_proptype ts_request_prop
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP GET request.

Parameters
i_request_prop Request properties.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
http_patch
importingi_request_proptype ts_request_prop
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP PATCH request.

Parameters
i_request_prop Request properties.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
http_post
importingi_request_proptype ts_request_prop
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP POST request.

Parameters
i_request_prop Request properties.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
http_post_multipart
importingi_request_proptype ts_request_prop
it_form_parttype tt_form_part
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP POST request with multipart body.

Parameters
i_request_prop Request properties.
it_form_part Internal table of form parts in request body.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
http_put
importingi_request_proptype ts_request_prop
returningvalue(e_response)type to_rest_response
raisingzcx_ibmc_service_exception

Sends a HTTP PUT request.

Parameters
i_request_prop Request properties.
e_response Response returned by service.
Class-based Exceptions
zcx_ibmc_service_exception Exception being raised in case of an error.
public instance
set_access_token
importingi_access_tokentype ts_access_token

Sets an access token explicitly.

Parameters
i_access_token Access token.