Type Casting in ABAP Class

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 called […]

Delete Duplicates in ABAP

DATA : lv_string TYPE string, lv_string2 TYPE string, lv_string_final TYPE string. TYPES: BEGIN OF ty_data, auth TYPE c, END OF ty_data. DATA: ls_user TYPE ty_data, ls_user2 TYPE ty_data, lt_user2 TYPE TABLE OF ty_data, lt_user TYPE TABLE OF ty_data. lv_string = ‘a,b,c,a’. lv_string2 = ‘d,b,c,a’. SPLIT lv_string AT ‘,’ INTO TABLE lt_user. SPLIT lv_string2 AT ‘,’ […]

ODATA in ABAP

ODATA Index What is ODATA? Why we need it? How to Create an ODATA Service? Exploring ODATA CRUD Operation via ODATA Calling CLASS, FM in ODATA Checking your Service: CRUD   Exploring ODATA Data Model Entity Types Association Entity Sets Vocabularies Service Implementation Runtime Artifacts Service Maintenance   What is ODATA ODATA stands for Open […]

Constructor Program in ABAP

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 ‘TEXT_CONVERT_XLS_TO_SAP’ […]

Casting in ABAP Program

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. ENDCLASS. […]

Editable ALV Program in ABAP

************************************************************************ * INTERNAL TABLES ************************************************************************ DATA: lt_mapping TYPE STANDARD TABLE OF zBarry_emp, lt_fieldcat TYPE lvc_t_fcat. ************************************************************************ * WORK AREAS ************************************************************************ DATA: ls_fieldcat TYPE lvc_s_fcat, ls_mapping TYPE zBarry_emp, lw_layout TYPE lvc_s_layo. ************************************************************************ * REFERENCE OBJECT ************************************************************************ DATA: r_container TYPE REF TO cl_gui_custom_container, r_grid TYPE REF TO cl_gui_alv_grid. ************************************************************************ * Field symbol ************************************************************************ FIELD-SYMBOLS: <ls_fieldcat> TYPE lvc_s_fcat. […]

Local Class Program in ABAP

CLASS class_test DEFINITION DEFERRED. PARAMETERS: p_empid TYPE char8. DATA: wa_emp TYPE zBarry_emp, wa_emp2 TYPE zBarry_sal. DATA: obj TYPE REF TO class_test. INTERFACE interface. METHODS: method2 IMPORTING imp2 TYPE char8 EXPORTING exp2 TYPE zBarry_sal. ENDINTERFACE. CLASS class_test DEFINITION. PUBLIC SECTION. EVENTS: event1. INTERFACES: interface. METHODS: method1 IMPORTING imp TYPE char8 EXPORTING exp TYPE zBarry_emp. METHODS: eventhandler […]

Lock Program in ABAP

DATA: varkey LIKE rstable-varkey. varkey = sy-mandt. CALL FUNCTION ‘ENQUEUE_E_TABLE’ EXPORTING * MODE_RSTABLE = ‘E’ tabname = ‘ZBarry_TEST’ varkey = varkey * X_TABNAME = ‘ ‘ * X_VARKEY = ‘ ‘ * _SCOPE = ‘2’ * _WAIT = ‘ ‘ * _COLLECT = ‘ ‘ EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. […]

Interactive Report Program in ABAP

TABLES zBarry_emp. TABLES zBarry_sal. PARAMETERS: ip type char20. DATA : it_emp1 TYPE TABLE OF zBarry_emp, it_emp2 TYPE TABLE OF zBarry_sal, wa_emp TYPE zBarry_emp, wa_emp2 TYPE zBarry_sal, it_emp3 TYPE TABLE OF zBarry_add, wa_emp3 TYPE zBarry_add, fnam TYPE char20, fval TYPE char8, fnam1 TYPE char20, fval1 TYPE char8.. set PF-STATUS ‘PFSTATUS’. SELECT-OPTIONS : p_empid FOR zBarry_emp-empid. AT […]

Create, Read, Update and Delete (CRUD) using ABAP Report

“Program for Reading , Updating , Inserting & Deleting data from a table TABLES: zBarry_emp. “Employee Table DATA: lt_itab TYPE TABLE OF zBarry_emp, “Internal table for employee basic details table lwa_emp TYPE zBarry_emp, “Workarea for employee basic details table lt_itab1 TYPE TABLE OF zBarry_add, “Internal table for employee address details table lwa_emp1 TYPE zBarry_add, “Workarea […]