Simple Try Catch program in SAP ABAP

July 17, 2024

Code:

DATA: res TYPE char10.
PARAMETERS: p1 TYPE char10,
            p2 TYPE char10.

TRY.
    res = p1 / p2.
    WRITE:/ res.
  CATCH cx_sy_zerodivide.
    WRITE: 'cannot divide by zero'.
ENDTRY.

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 pass internal table data to range table in SAP ABAP

July 16, 2024

Code: 
TYPES: BEGIN OF ty_str,
         id   TYPE int4,
         name TYPE name1,
         site TYPE werks_d,
       END OF ty_str.

DATA: it TYPE STANDARD TABLE OF ty_str,
      wa TYPE ty_str.

DATA: r_site TYPE RANGE OF werks_d.

it = VALUE #( ( id = '1' name = 'AAA' site = 'H021' )
              ( id = '2' name = 'BBB' site = 'H067' )
              ( id = '3' name = 'CCC' site = 'H022' )
              ( id = '4' name = 'DDD' site = 'H055' )
              ( id = '5' name = 'EEE' site = 'H033' )
              ( id = '6' name = 'FFF' site = 'H064' ) ).

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = 'I'
                      option = 'EQ'
                      low = <fs_it>-site ) ).

cl_demo_output=>display( r_site ).

You can also use below code section -

r_site = VALUE #( FOR <fs_it> IN it
                    ( sign = if_fsbp_const_range=>sign_include
                      option = if_fsbp_const_range=>option_equal
                      low = <fs_it>-site ) ).

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.

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.