GET_CURRENT_YEAR in SAP ABAP

July 10, 2024

GET_CURRENT_YEAR is a SAP's standard function module used in ABAP program to get current year.

Code:
DATA: lv_year TYPE bkpf-gjahr.

CALL FUNCTION 'GET_CURRENT_YEAR'
 EXPORTING
   bukrs         = '1000' "company code
   date          = sy-datum
 IMPORTING
*   CURRM         =
   curry         = lv_year
*   PREVM         =
*   PREVY         = .
WRITE: lv_year.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

SQL Server (MSSQLSERVER) not running in services

July 03, 2024

Today I have faced some serious issues with SQL Server running status. When I tried to connect my SQL database through SQL Server Management studio, the database was not connecting at all, so I checked SQL Server Configuration Manager there and I saw that SQL Server wasn't running at all. After spending a lot of time in the system and blogs on the internet I have checked Windows Logs in Event Viewer and track down the actual error I was getting.

Error code I have found in the Event Viewer
SQL error 9003

After that I got a solution that works perfectly.

Solution:
Go to C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Binn\Templates

Copy and paste model.mdf and modellog.ldf file to below path

C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA

After that I have tried to start the SQL Server service and it's started and the database has connected perfectly.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to put the Routine Number in condition value in sap?

June 29, 2024

Step1 - First we need to go to VOFM tcode.
Step2 - Then go to Formulas then click on Condition Value.
Step3 - Put the following

Routine number (Require Access Key)
Description
Application Type.

To get access key
1. Login to SAP Marketplace https://me.sap.com/app/sscr
2. Then go to objects -> Register

Then put following -
Basis Release
Program ID
Type
Object Name
Select Installation(s) No (copy installation number from SAP Access key message box)

3. After putting all the details, SAP Marketplace will give you an Access Key. Put the Access Key and you will be able to put your Routine Number and logic into it.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Check table and value table in SAP

June 26, 2024

Value table
It is maintained at the Domain level and value table used to provide f4 help. Value table provides only suggested values. we can put the suggested value and other values also.

Check Table
It is maintained at the Table level. Check table provides a list of possible entries. we can not provide any value other than value other than possible entries.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Append Structure and Include Structure in SAP

June 26, 2024

Append structure
Append structure is used to append to another structure or database table.
Append structure assigned to only one structure or table.
Append structure only appended to transparent tables.

Include structure
Include structure is used to include the structure to the SAP's custom table.
It can include multiple structures or database tables.
CI_ for customers and SI_ for partner namespace used in SAP.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

ME Keyword in OOABAP

June 26, 2024

It refers to the current object in execution. It is just an alias name for the current object.

Demo Program
CLASS cl_main DEFINITION.
  PUBLIC SECTION.
    DATA: num  TYPE i.
    METHODS: setdata,
             display.
ENDCLASS.

CLASS cl_main IMPLEMENTATION.

  METHOD setdata.
    me->num = 20.
  ENDMETHOD.

  METHOD display.
    WRITE:/ num.
  ENDMETHOD.

ENDCLASS.

DATA: ob TYPE REF TO cl_main.

START-OF-SELECTION.
  CREATE OBJECT ob.
  CALL METHOD ob->setdata.
  CALL METHOD ob->display.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

How to consume the IM data in ABAP layer?

June 25, 2024

If the system version is below SAP NetWeaver 7.4 SP2 then we have to use ADBC (ABAP Database Connectivity) technique to consume IM data into the ABAP layer.

If the system version is above SAP NetWeaver 7.4 SP2 then we can use the View proxies technique to consume IM data into the ABAP layer.

If the system version is above SAP NetWeaver 7.4 SP6 then we use the CDS View technique to consume IM data into the ABAP layer.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Dispatcher in SAP R/3 architecture

June 25, 2024

In SAP R/3 architecture dispatchers have a very essential role. Dispatcher resides in the application server. When request coming from presentation layer then dispatcher takes the request and assigns the request to the freely available work process, then the work process executes the request. After execution of the request result will be sent back and then the work process becomes free and ready to take another request for execution.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Work process in SAP

June 25, 2024

Work processes execute the individual request of ABAP application programs. Work processes are the components of application servers. Each work can executes different types of request.

Dialog Work process (DIA): Execute dialog programs.

Background Work process (BTC): For background programs.

Spool Work Process (SPO): For print related tasks.

Enqueue Work Process: For locking system.

Update Work process: It handles high and low priority updates to the database.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Parameter ID in SAP

June 25, 2024

Parameter Id holds the memory for the particular field of a selection screen. If we want to pass the field value from one screen (100) to another screen (200) then we use parameter Id.

To set the parameter id
SET PARAMETER ID ‘pid’ FIELD dobj.

To get the parameter id
GET PARAMETER ID ‘pid’ FIELD dobj.

Parameter id will be available in the table TPARA.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Types of Information Model in SAP HANA

June 24, 2024

Information Model also known as HANA View or Data Model. There are 3 types of information models in HANA.

Attribute View: Attribute View used to expose the master data. This view is deprecated from HANA 2.0 onwards. No new features or development will happen in this view. If you use this view and if you have any standard issue then you will not get any support from SAP site.

Analytic View: Analytic View used when we want analytical requirements. Here aggregation function is used. This view is used by the OLAP engine in HANA.
This type of view is also deprecated from HANA 2.0 onwards.

Calculation View: This view is used to perform complex calculations. It can be built on top of one or more attribute views or analytic views.

If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Constructor in OOABAP

June 24, 2024

Constructor is a method used to initialize the attributes of the class.

Key Point:
1. It will be called automatically whenever an object is created.
2. Constructor always declared in the public section of the class.
3. Constructor doesn't return any value.

There are 2 types of constructor
Static Constructor:
It is declared using the 'class_constructor' keyword.
It cannot contain any parameters and exceptions.

Instance Constructor:
It is declared using 'constructor' keyword.
They can contain only importing parameters and exceptions.

Instance Constructor demo program:
CLASS cl_main DEFINITION.
  PUBLIC SECTION.
    DATA: empnum TYPE i,
          empname TYPE char10.

    METHODS: constructor, "instance constructor
             display.

ENDCLASS.

CLASS cl_main IMPLEMENTATION.

  METHOD constructor.
    empnum = '10'.
    empname = 'Amit'.
  ENDMETHOD.

  METHOD display.
    WRITE:/ empnum, empname.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
  DATA ob TYPE REF TO cl_main.
  CREATE OBJECT ob.

  CALL METHOD ob->display.

Static Constructor Demo Program:
CLASS cl_main DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA: empnum  TYPE i,
                empname TYPE char10.

    CLASS-METHODS: class_constructor,
                   display.
ENDCLASS.

CLASS cl_main IMPLEMENTATION.

  METHOD class_constructor.
    empnum = '10'.
    empname = 'Amit'.
  ENDMETHOD.

  METHOD display.
    WRITE:/ empnum, empname.
  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
  CALL METHOD cl_main=>display.

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.

Visibility section in class

June 24, 2024

There are 3 types of visibility sections in the class.

Public Section
In the public section of the class access available inside the class and outside the class.

Protected Section
In protected section access available inside the class and its child class and accessible outside the class is not possible.

Private Section
In private section access available inside the class and its child class and outside the class is not possible.

Sample Code:
CLASS lcl_sample DEFINITION.
  PUBLIC SECTION.
    METHODS: public_method.

  PROTECTED SECTION.
    DATA: protected_attr TYPE string.
    METHODS: protected_method.

  PRIVATE SECTION.
    DATA: private_attr TYPE string.
    METHODS: private_method.
ENDCLASS.

CLASS lcl_sample IMPLEMENTATION.
  METHOD public_method.
    " Public method implementation
  ENDMETHOD.

  METHOD protected_method.
    " Protected method implementation
  ENDMETHOD.

  METHOD private_method.
    " Private method implementation
  ENDMETHOD.
ENDCLASS.

DATA: lo_sample TYPE REF TO lcl_sample.

CREATE OBJECT lo_sample.

" Accessing public method
lo_sample->public_method( ).

" Accessing protected attribute (Allowed within the class and any subclass)
lo_sample->protected_attr = 'Protected attribute value'.

" Accessing private attribute (Not allowed outside the class)
" lo_sample->private_attr = 'Private attribute value'. " This would raise a syntax error

IDE Used To Test This Code : SAP ABAP Editor.

Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us. We will reply you as soon as possible.