Scenario: SAP Script uses Text Object and Text Ids concept to store some information in the standard table ‘STXH’ and ‘STXL’. Also these Text Object
Author: coderobbot
Creating Application Log Object , Sub object & its Uses
Step1. Create the below table which stores the Employee records. Step2. Create the below message class in Trax- SE91 with below messages. Step3. Go to
RFC Connection Type -G and Using it in program with CL_HTTP_CLIENT to read an xml file from the Web
DATA : lr_request TYPE REF TO if_http_request, lr_client TYPE REF TO if_http_client, lv_code TYPE i, lv_xdata TYPE xstring. * Create a link to the source xml by the RFC destination CALL METHOD cl_http_client=>create_by_destination EXPORTING destination = ‘ZW3SCHOOL’ ” Logical destination (specified in function call) IMPORTING client = lr_client ” HTTP Client Abstraction EXCEPTIONS argument_not_found = 1 destination_not_found = 2 destination_no_authority = 3 plugin_not_active = 4 internal_error = 5 OTHERS = 6. IF sy–subrc <> 0. MESSAGE ID sy–msgid TYPE sy–msgty NUMBER sy–msgno WITH sy–msgv1 sy–msgv2 sy–msgv3 sy–msgv4. ENDIF. * Set the method type as Set CALL METHOD lr_client->request->set_method EXPORTING
Creating XML Tree structure
DATA : lr_ixml TYPE REF TO if_ixml, lr_doc TYPE REF TO if_ixml_document, lr_root_elem TYPE REF TO if_ixml_element, lr_node1_elem TYPE REF TO if_ixml_element, lr_stream TYPE REF TO if_ixml_stream_factory, lr_ostream TYPE REF TO if_ixml_ostream, lr_render TYPE REF TO if_ixml_renderer, xml_string TYPE string. lr_ixml = cl_ixml=>create( 0 ). * Get reference of the document lr_doc = lr_ixml->create_document( ). * get reference of the root lr_root_elem = lr_doc->create_simple_element_ns( prefix = ‘asx’ name = ‘test’ parent = lr_doc ). * Add root element attributes lr_root_elem->set_attribute_ns( name = ‘asx’ prefix = ‘xmlns’ value = ‘http://www.sap.com/testxml’ ). lr_root_elem->set_attribute_ns( name = ‘version’ value = ‘1.0’ ). * Get reference of the first node of teh root lr_node1_elem = lr_doc->create_simple_element_ns( prefix = ‘asx’ name = ‘names’ parent = lr_root_elem ).
Encode and Decode String for security reason in SAP UTF8 Format
PARAMETERS : p_string TYPE string. DATA : lv_encode_str TYPE xstring, lv_decode_str TYPE string. WRITE ‘Plain String :’, p_string. CALL METHOD cl_http_utility=>if_http_utility~encode_utf8 EXPORTING unencoded = p_string RECEIVING encoded = lv_encode_str. WRITE
‘Encoded String:’, lv_encode_str COLOR 5. CALL METHOD cl_http_utility=>if_http_utility~decode_utf8 EXPORTING encoded = lv_encode_str RECEIVING unencoded = lv_decode_str. WRITE
‘Decoded Sing:’, lv_decode_str COLOR 3.
Encode and Decode String for security reason in SAP
SAP provides standard Utility class CL_HTTP_UTILITY which provides methods that can be used to encode and decode string for security reasons. PARAMETERS : p_string TYPE string. DATA : lv_encode_str TYPE string,