Architecture of the SAP HANA Database

June 14, 2024

Index Server: This is the most important one in the HANA database. It is used to process SQL commands. Index server contains several important components.

1. SQL Processor: This receives the SQL commands and runs them directly or passes the commands to the other components row store or column store or the engines.

2. Row Store / Column Store: All data is stored in row store or column store. Data is directly read from these stores.

3. Planning Engine / MDX Engine / Stored Procedure Processor: For complex queries or MDX (multi-dimensional expressions), processed via these engines. For database procedure handled by Stored Procedure Processor. These engines are optimized for data processing for special purposes.

Preprocessor Server: It is used by the index server to analyze text data.

Statistics Server: It is used to monitor SAP HANA database. This server collects various information from the HANA database such as consumption of resources,
status, performance of the database.

Name Server: It maintains the topology information about the SAP HANA database.

XS Engine: This is known as SAP HANA Extended Application Services. This lightweight application attached to the HANA database can be accessed directly via web browser or HTTP. Using JavaScript in server side and XS engine we can develop web based applications in SAP HANA and expose them using Odata (RESTful service).

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

MIME Repository in SAP

June 12, 2024

MIME Repository used to store various MIME objects in SAP. MIME objects are icons, excel sheets, graphics and so on. We can create MIME objects in SE80.

We can create a folder and within the folder we can import required MIME objects.

To create MIME repository follow below steps -

1. Go to SE80 then click on MIME repository.
2. Click on the PUBLIC folder. Then click a folder within the PUBLIC folder.
3. Then import your MIME objects into that newly created folder.

Then after that we can access that MIME objects through below programs

Code:

DATA: xlsurl TYPE string VALUE '/SAP/PUBLIC/ZMIME/Sample.xls'.

  DATA: o_mr_api TYPE REF TO if_mr_api.

  DATA: l_xls_xstr TYPE xstring,
        l_xls_conv TYPE i,
        l_xls_offs TYPE i,
        l_xls_size TYPE i.

  REFRESH xls_table.

  IF o_mr_api IS INITIAL.
    o_mr_api = cl_mime_repository_api=>if_mr_api~get_api( ).
  ENDIF.

  CALL METHOD o_mr_api->get
    EXPORTING
      i_url              = xlsurl
    IMPORTING
      e_content          = l_xls_xstr
    EXCEPTIONS
      parameter_missing  = 1
      error_occured      = 2
      not_found          = 3
      permission_failure = 4
      OTHERS             = 5.

  l_xls_size = xstrlen( l_xls_xstr ).

  CHECK l_xls_size > 0.

  l_xls_conv = l_xls_size.
  l_xls_offs = 0.

  WHILE l_xls_conv > 255.
    xls_table-line = l_xls_xstr+l_xls_offs(255).
    APPEND xls_table.
    l_xls_offs = l_xls_offs + 255.
    l_xls_conv = l_xls_conv - 255.
  ENDWHILE.

  xls_table-line = l_xls_xstr+l_xls_offs(l_xls_conv).
  APPEND xls_table.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.

  DATA: mydocuments     TYPE string.

  MOVE 'C:\' TO mydocuments.

  CALL METHOD cl_gui_frontend_services=>registry_get_value
    EXPORTING
      root      = 1   " HKEY_CURRENT_USER
      key       = 'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
      value     = 'Personal'
    IMPORTING
      reg_value = mydocuments.


  DATA: l_fname         TYPE string,
        mytemplate(255) TYPE   c,
        filesize        TYPE   i,
        mymimeurl(255)      TYPE   c,
        mysave(120)     TYPE   c,
        fname(60)       VALUE 'Sample.xls'. "'multiple_linking_format.xls'.

  DATA spreadsheetintf     TYPE REF TO  i_oi_spreadsheet.
  DATA documentintf        TYPE REF TO i_oi_document_proxy.

  CONCATENATE mydocuments '\' fname INTO mytemplate.

  MOVE mytemplate TO l_fname.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filetype   = 'BIN'
      filename   = l_fname
    IMPORTING
      filelength = filesize
    TABLES
      data_tab   = xls_table.

  IF sy-subrc <> 0.
*    message e999 with 'XLS Download failed'.
  ENDIF.

  CONCATENATE 'file://' mytemplate INTO mymimeurl.


  CALL FUNCTION 'ZJNC_START_EXCEL'
    EXPORTING
      document_url    = mymimeurl
    IMPORTING
      spreadsheetintf = spreadsheetintf
      documentintf    = documentintf.

  IF documentintf    IS INITIAL OR spreadsheetintf IS INITIAL.
*    message e999 with 'NULL document/spreadsheet interfaces'.
  ENDIF.


  CALL FUNCTION 'POPUP_TO_INFORM'
    EXPORTING
      titel = sy-repid
      txt2  = ''
      txt1  = 'Save file first '.

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.

STMS Process in SAP

June 11, 2024

STMS

STMS known as Transport Management System. We do STMS to transport TR from development server to quality server / production server.

Before STMS makes sure that TR has been released from the development server.

To do STMS follow the below steps-

1. Go to Tcode STMS -> Import Overview.

2. Double click on System GWQ, after that you will see lists of TR requests.

3. Then click on the Refresh button on the top left corner.

4. After refreshing your released objects will come at the bottom of the page with a green square box in the status.

5. Click on the Request number and click on Import Request car icon / Ctrl + F11.

6. Then screen will come, put the Target Client and click on Options tab

uncheck the Leave Transport Request in Queue for Later Import
check the Overwrite Originals.
check the Overwrite Objects in Unconfirmed Repairs.

Then click Continue.

7. Then a message box will come like 'The import is executed with the following' click Yes and then ask for login details where you want to transport the TR.

8. After a few seconds the object will transport to the destination server and in the top left corner there is a Refresh button, click on that.

9. Then you will see object status has a green tick mark, it means objects successfully transported, if it's red then there must be a problem with the TR.

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

Internal Table in SAP

June 11, 2024

Internal Table is basically a temporary table in SAP, it contains line items or data records in program runtime. It doesn't store any actual data.

In SAP there are 3 internal concepts:
1. Standard Table
2. Sorted Table
3. Hashed Table

1. Standard Table: This table can contain unique and duplicate records. This table can be accessed using INDEX. Standard table should fill the records
using APPEND and read, modify, delete entries using the INDEX option. Access time of data records in standard table increases with linear relationship with
the number of records in a table.
Syntax: DATA: it TYPE STANDARD TABLE OF ty_str.

2. Sorted Table: Sorted table can contain unique and duplicate both records. Using INSERT we can fill the data to the table.
Syntax for non-unique: DATA: it TYPE SORTED TABLE OF ty_str WITH NON-UNIQUE KEY id.
Syntax for unique: DATA: it TYPE SORTED TABLE OF ty_str WITH UNIQUE KEY id.

3. Hashed Table: Hashed tables always contain unique records. We can not do INDEX access in the Hashed table. Only KEY access is allowed.
Syntax: DATA: it TYPE SORTED TABLE OF ty_str WITH NON-UNIQUE KEY id.

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

Parallel Cursor in SAP

June 07, 2024

Parallel Cursor is an optimized method to increase the performance of the SAP ABAP program when there are nested loops for a particular condition.

Algorithm for Parallel Cursor
STEP 1: Table1 and Table2 must be sorted.
STEP 2: Loop at Table1 and within the loop and read the Table2 with matching key of Table1 and Table2.
STEP 3: If read successfully then take the sy-tabix into a variable.
STEP 4: After that loop at Table2 with that sy-tabix variable.
STEP 5: Then within the loop if Table1 and Table2 primary keys are not matched then exit from the program.

Sample Code:
SORT: table1, table2.
LOOP AT table1 INTO wa_table1.
READ TABLE table2 INTO wa_table2 WITH KEY eid = wa_table1-eid BINARY SEARCH.
IF SY-SUBRC = 0.
DATA(lv_index) = SY-TABIX.
LOOP AT table2 INTO wa_table2 FROM lv_index.
IF wa_table1-eid <> wa_table2-eid.
EXIT.
ENDIF.
Write: wa_table1-eid, wa_table2-month, wa_table2-amount.
ENDLOOP.
ENDLOOP.

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

BDC Session Transaction in SAP

June 06, 2024

Batch data communication is a popular old method to move legacy data to the SAP system. In BDC SAP uses a screen to update the data.
In BDC there are two types of data update methods. Call transaction and session method, here I will discuss BDC session transaction.

In the BDC method we have to record the screen with demo data through SHDB Tcode.

In session transaction 3 function module used:
BDC_OPEN_GROUP - Here we have to pass client, user, group, keep.
BDC_INSERT - Here we have to pass TCODE and bdcdata structure.
BDC_CLOSE_GROUP

In session transactions you can track errors / exceptions in SE37.

it_bdcdata will contain the structure of BDCDATA which has the following fields:
PROGRAM - It will hold the running program name.
DYNPRO - It will hold the screen number.
DYNBEGIN - It will hold the start screen number.
FNAM - It will hold a field name.
FVAL - It will hold field value.

This structure is used in Batch input.

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

BDC Call Transaction in SAP

June 05, 2024

Batch data communication is a popular old method to move legacy data to the SAP system. In BDC SAP uses a screen to update the data.
In BDC there are two types of data update methods. Call transaction and session method, here I will discuss BDC call transaction.

In the BDC method we have to record the screen with demo data through SHDB Tcode.

In call transaction we have to map the custom structure field with bdc_field then after mapping all the important fields we have
to write CALL TRANSACTION 'TCODE NAME' USING it_bdcdata MODE 'N' UPDATE 'S'.

In call transactions there are 3 modes:
A - To show all the screen.
N - No screen will show.
E - If any error occurs then the screen will show.

In call transaction there have 2 update modes:
Synchronous
Asynchronous

In call transaction if you want to handle error / exception then we can do this using bdcmsgcoll.

it_bdcdata will contain the structure of BDCDATA which has the following fields:
PROGRAM - It will hold the running program name.
DYNPRO - It will hold the screen number.
DYNBEGIN - It will hold the start screen number.
FNAM - It will hold a field name.
FVAL - It will hold field value.

This structure is used in Batch input.

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

How to find all Plants in SAP using Function Module

June 04, 2024

Below I have used K_WERKS_OF_BUKRS_FIND function module to fetch all the plants in particular company code.

Code: 
REPORT zfind_all_plants.
DATAitab TYPE STANDARD TABLE OF t001w.
CALL FUNCTION 'K_WERKS_OF_BUKRS_FIND'
  EXPORTING
    bukrs                   '1000'
  TABLES
*   ITAB_001K               =
    itab_001w               itab
 EXCEPTIONS
   no_entry_in_t001k       1
   no_entry_in_t001w       2
   OTHERS                  3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
cl_demo_output=>displayitab ).

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.

Alternate of TEXT_CONVERT_XLS_TO_SAP function module in SAP

May 29, 2024

In the ABAP report program we have frequently used the TEXT_CONVERT_XLS_TO_SAP function module to convert excel file data to an internal table. Sometimes we face issues with this function module in case of background jobs. This function module works fine in foreground execution of a report but in background it will not work. so we need an alternate solution that will help for foreground as well as background execution.

ALSM_EXCEL_TO_INTERNAL_TABLE is a SAP's standard function module that will work in background and foreground also.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
      filename                = p_file "file name
      i_begin_col             = '0001'
      i_begin_row             = '0002'
      i_end_col               = '0007'
      i_end_row               = '9999'
    TABLES
      intern                  = it_excel "internal table name
    EXCEPTIONS
      inconsistent_parameters = 1
      upload_ole              = 2
      OTHERS                  = 3.
  IF sy-subrc <> 0.
  ENDIF.

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.

WRITE format options in SAP ABAP

May 28, 2024

SAP has provided different options of text alignment.

-----------------------------------
For Left alignment text -

Code:
DATA: text TYPE char50.
WRITE 'Hello World - Left' TO text LEFT-JUSTIFIED.
cl_demo_output=>write( text ).
cl_demo_output=>display( ).
-----------------------------------
For Right alignment text -

Code:
DATA: text TYPE char50.
WRITE 'Hello World - Right'  TO text RIGHT-JUSTIFIED.
cl_demo_output=>write( text ).
cl_demo_output=>display( ).
-----------------------------------
For Center alignment text -

Code:
DATA: text TYPE char50.
WRITE 'Hello World - Center' TO text CENTERED.
cl_demo_output=>write( text ).
cl_demo_output=>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.

Table Buffering in SAP

May 28, 2024

We use table buffers to improve data access performance in the table. Table buffers reside in the application server. When we activate buffers in tables then data will be directly accessed from buffers, this facility minimizes data access time of database tables.

There are 3 types of buffer type -

1. Single Record Buffed
2. Generic Area Buffered
3. Fully Buffered

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

What is Data Class in SAP

May 25, 2024

In SAP when we create a custom database table then we have to provide a data class. It is under technical settings in table general properties.

Data Class is basically the physical area of the database table (the custom database table that we are creating or already created) inside the database (oracle) layer.

Different types of data class are -

APPL0
APPL1
APPL2
DDIM
DFACT
DODS
USER
USER1

According to our table contents we can choose the data class types.

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

What is Delivery Class in SAP

May 24, 2024

When we can create a custom table in SAP, we can select the Delivery class. Delivery class defines which type of data will be stored in the table. It is also used for extended table maintenance.

A - Application table (used for transactional and master data).
C - Customizing table (by customer).
L - Used to store temporary data.
G - Customizing table.
E - Control table.
S - System table (used by SAP).
W - System table.

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