Function Imports in SAP OData

3 DATA: ls_parameter TYPE /iwbep/s_mgw_name_value_pair, lv_custid TYPE kunnr, lv_flag TYPE char1, lt_custinfo TYPE TABLE OF ztest_gw_srv, ls_custinfo TYPE ztest_gw_srv, ls_entity TYPE zcl_ztest_gw_srv_mpc=>ts_msg_return. IF iv_action_name = ‘demoFuncImport’. ” Check what action is being requested IF it_parameter IS NOT INITIAL. * Read Function import parameter value READ TABLE it_parameter INTO ls_parameter WITH KEY name = ‘CustId’. IF […]

Convert JSON to ABAP Internal Table

2 TYPES: BEGIN OF t_entry, access_token TYPE string, token_type TYPE string, expires_in TYPE n LENGTH 8, scope TYPE string, jti TYPE string, END OF t_entry . TYPES: t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token. DATA: m_entries TYPE t_entry. DATA: lr_instance TYPE REF TO /ui5/cl_json_parser. CREATE OBJECT lr_instance. CALL METHOD me->get_token. IF gv_token […]

Create Object History in SAP Blockchain

3 In this article we will learn how to create a block in Blockchain at SAP Cloud Platform. METHOD create_object_history. DATA: lo_http_client TYPE REF TO if_http_client. DATA: response TYPE string, lv_url TYPE string, lv_auth TYPE string. CONSTANTS : lv_initial_url TYPE string VALUE ‘<Your_Service>’. IF iv_object_id IS NOT INITIAL. *** Getting Token TYPES: BEGIN OF t_entry, […]

Get Token from SAP Cloud Platform Service

3 In this step we will call the service to get the token and store that token in a global variable for later use. METHOD get_token. DATA: lo_http_client TYPE REF TO if_http_client. DATA: response TYPE string, lv_url TYPE string. CONSTANTS: lv_initial_url TYPE string VALUE ‘<Blockchain Service Link>’, lv_auth TYPE string VALUE ‘Basic <your login credentials>’. […]

Calculate a hash in ABAP

3 In ABAP we can perform the following: calculate_hash_for_raw METHOD calculate_hash_for_raw. TRY. cl_abap_message_digest=>calculate_hash_for_raw( EXPORTING if_algorithm = ‘SHA256’ if_data = iv_data IMPORTING ef_hashstring = ev_sha256 ). CATCH cx_root. ” Eh, what’re you gonna do? ENDTRY. ENDMETHOD. calculate_hash_for_string METHOD calculate_hash_for_string. TRY. cl_abap_message_digest=>calculate_hash_for_char( EXPORTING if_algorithm = ‘SHA256’ if_data = iv_data IMPORTING ef_hashstring = ev_sha256 ). CATCH cx_root. ” […]

Type Casting in ABAP Class

588 Type Casting in ABAP Class Note: If you are searching for basic type casting/conversion of ABAP variable in Reports/Program, click here. Prerequisite: 1. You must have a basic Idea of local class and instance/reference of class. 2. Inheritance and Polymorphism concept Note: Parent Class is also called base class and Child class is also […]

Delete Duplicates in ABAP

508 To delete duplicates in ABAP either from a string or an internal table, we need to use ABAP statement “DELETE ADJACENT DUPLICATES FROM”. In this article, we have taken an example, which implements deletion of duplicate data when two strings are merged. This process also involves internal table. Introduction DELETE ADJACENT DUPLICATES FROM <Internal […]

Constructor Program in ABAP

67 TYPE-POOLS truxs. PARAMETERS p_file TYPE rlgrap-filename. TYPES : BEGIN OF t_tab, workstream TYPE char50, task TYPE zci_task, task_type TYPE char50, END OF t_tab. DATA : t_upload1 TYPE STANDARD TABLE OF ZDEMO_TEST2, wa_upload1 TYPE ZDEMO_TEST2. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. CALL FUNCTION ‘F4_FILENAME’ EXPORTING field_name = ‘P_FILE’ IMPORTING file_name = p_file. START-OF-SELECTION. CALL FUNCTION […]

Casting in ABAP Program

90 CLASS a1 DEFINITION. PUBLIC SECTION. DATA: num1 TYPE i VALUE 100. METHODS:m1. ENDCLASS. CLASS a1 IMPLEMENTATION. METHOD m1. WRITE: ‘a1:’,num1. ENDMETHOD. ENDCLASS. CLASS b1 DEFINITION INHERITING FROM a1. PUBLIC SECTION. METHODS:m2, m1 REDEFINITION. ENDCLASS. CLASS b1 IMPLEMENTATION. METHOD m1. num1 = num1 . WRITE: ‘b1:’,num1. ENDMETHOD. METHOD m2. WRITE: ‘M2 in class b1’. ENDMETHOD. […]

Translate »