SAP & Oracle partner and support companies

Loading

Archives 2025

SAP

How to Show the ALV Output and the Selection Screen on the Same Screen?

How to Show the ALV Output and the Selection Screen on the same Screen? Typically the ALV yield is shown in another screen. Not on a similar screen where you have the choice boundaries and select choices. In any case, at times client need to see what they input in the screen and what they get yield in the ALV in a similar screen. It simply assists them with performing better, report better and break down better. This prerequisite and situation isn’t new. We have answer for it from in those days in 2008.

On the off chance that the arrangement is as of now there, why again another article?

 The previous arrangement gave utilizes SALV class “CL_SALV_TABLE”. We will utilize “CL_GUI_ALV_GRID” class because of its upgraded highlights.

Expectations (How to Show the ALV Output and the Selection Screen on the same Screen)

  1. Choice Screen and ALV on A similar Screen.
  2. Add a Button on the ALV Toolbar.
  3. Handle Client Order.

For additional data on the use and working of the class CL_GUI_ALV_GRID, you can allude to the demo programs gave by SAP the name like “BCALV_GRID* “.

Sample programs provided by SAP on the usage of CL_GUI_ALV_GRID.

Output (How to Show the ALV Output and the Selection Screen on the same Screen)

Simple Selection Screen with one Select-Options S_CARRID of type SFLIGHT-CARRID

Below is the Final Output which the Client is Expecting.

Selection screen and ALV on same screen

Let’s Design

High Level Programming Paradigm:

All in all, pseudo code for this necessity.

  1. The docking holder should be made in the introduction occasion.
  2. ALV should be made on that docking holder.
  3. Trade the Chose Result Table Information to ABAP Memory (this part we could do without. Yet, till we track down an improved arrangement, we should utilize it).
  4. Import information from ABAP Memory and Produce the Result.

Global Data Declarations

CLASS lcl_report DEFINITION DEFERRED.
DATA: lo_report TYPE REF TO lcl_report. "Reference object of the local class
DATA: alv_container TYPE REF TO cl_gui_docking_container, "ALV Container
      alv_grid      TYPE REF TO cl_gui_alv_grid,          "ALV Grid
      layout        TYPE lvc_s_layo.                      "Layout Options               
DATA gv_carrid TYPE sflight-carrid. "Variable for Select-options declaration.

Selection Screen Declarations

SELECTION-SCREEN: BEGIN OF BLOCK block_1 WITH FRAME TITLE text-001.
SELECT-OPTIONS: s_carrid FOR gv_carrid.
SELECTION-SCREEN: END   OF BLOCK block_1.

Local Class Definition

CLASS lcl_report DEFINITION .

  PUBLIC SECTION.
    DATA: gt_data TYPE STANDARD TABLE OF sflight.
    METHODS :
      get_data,
      generate_output,
      toolbar      FOR EVENT toolbar OF cl_gui_alv_grid
        IMPORTING e_object, "To add some buttons on the ALV toolbar
      user_command FOR EVENT user_command OF cl_gui_alv_grid
        IMPORTING e_ucomm.

ENDCLASS.

Local Class Implementation

  • Method: GET_DATA
CLASS lcl_report IMPLEMENTATION.
  "Method Get Data
  METHOD get_data.
*   data selection
    SELECT * FROM sflight
           INTO  TABLE me->gt_data
           WHERE carrid IN s_carrid.
    IF sy-dbcnt IS INITIAL.
      MESSAGE s398(00) WITH 'No data selected'.
    ENDIF.
*
*   Export to memory
    EXPORT data = me->gt_data TO MEMORY ID sy-cprog.
  ENDMETHOD.
  • Method: GENERATE_OUTPUT
"Method generate_output
  METHOD generate_output.
*   Local data
    DATA: variant TYPE  disvariant.
    DATA: repid   TYPE sy-repid.

*   Import output table from the memory and free afterwards
    IMPORT data = me->gt_data FROM MEMORY ID sy-cprog.
    FREE MEMORY ID sy-cprog.
*
*   Only if there is some data
    CHECK me->gt_data IS NOT INITIAL.

    repid = sy-repid.
    variant-report = sy-repid.
    variant-username = sy-uname.
    layout-zebra = 'X'.

    CHECK alv_container IS INITIAL.
    CREATE OBJECT alv_container
      EXPORTING
        repid     = repid
        dynnr     = sy-dynnr
        side      = alv_container->dock_at_bottom
        extension = 200.
    CREATE OBJECT alv_grid
      EXPORTING
        i_parent = alv_container.
*  ALV Specific. Data selection.
    SET HANDLER : lo_report->toolbar      FOR alv_grid.
    SET HANDLER : lo_report->user_command FOR alv_grid.
    CALL METHOD alv_grid->set_table_for_first_display
      EXPORTING
        is_layout        = layout
        is_variant       = variant
        i_save           = 'U'
        i_structure_name = 'SFLIGHT'
      CHANGING
        it_outtab        = me->gt_data.

  ENDMETHOD.
  • Method: TOOLBAR

In this technique, we will make one press button (similarly as an illustration of no usefulness), for instance, to save a record, on the off chance that we had made this ALV as editable.

"Method Tool-bar
  METHOD toolbar.
    DATA: lv_toolbar TYPE stb_button.

* Push Button "For Example SAVE
    CLEAR lv_toolbar.
    MOVE 'FC_SAVE' TO lv_toolbar-function. "Function Code
    lv_toolbar-icon = icon_system_save.    "Save Icon
    MOVE 'Save'(100) TO lv_toolbar-text.   "Push button Text
    MOVE 'Save'(100) TO lv_toolbar-quickinfo. "Push button Quick-Info
    MOVE space TO lv_toolbar-disabled. "Push button enabled
    APPEND lv_toolbar TO e_object->mt_toolbar.
  ENDMETHOD. 
  • Method: USER_COMMAND

This strategy will be utilized to deal with every one of the orders given by the client, for instance assuming client push on the Save button we made above, and so on. I have kept this segment as clear, you can add the rationale as required.

"Method User_command
  METHOD user_command.
    IF e_ucomm = ' '.

    ENDIF.
  ENDMETHOD.                    "USER_COMMAND

ENDCLASS.                    "lcl_report IMPLEMENTATION

In the event that you set the breakpoint at the above strategy and press the Save button on the ALV, the execution will stop. Kindly check the underneath screen capture:

User Command captured when clicked on “Save” button.

Finally, the Events of the program execution

INITIALIZATION.
* object for the report
  CREATE OBJECT lo_report.
* generate output
  lo_report->generate_output( ).

START-OF-SELECTION.
* Get data
  lo_report->get_data( ).

Conclusion

In this blog entry we took in the nuts and bolts of making an ALV on the determination screen with the utilization of CL_GUI_ALV_GRID class.

On the off chance that you simply duplicate the above code scraps and glue it to your SE38 supervisor and actuate it. Very much like one of our sluggish editors. You will find the result like underneath. Indeed!! It is a functioning code. What’s more, you don’t have to configure any screen components.

For what reason did we have to utilize ABAP Memory when all information is there in the program and we are showing them in a similar program?

At the point when the program control arrives at the introduction occasion, all memory is invigorated and worldwide information is made FREE. After all everything ought to be instated in the introduction occasion. That is the occupation of the introduction occasion. Thusly, we must have the ALV information someplace to pull it back when we are in Instatement occasion. Presently you know why we had to take help of the ABAP Memory. 

YOU MAY BE INTERESTED IN

Call instance method from workflow using class

Using ABAP Classes in Workflow

Best Practices for SAP Cloud Platform Development: A Comprehensive Guide

Leveraging SAP HANA for Advanced Analytics

SAP ABAP Training Institute in Pune, SAP ABAP Courses Online

SAP

Selective Handling of the Buttons in ALV Grid Toolbar

By and large, on the off chance that the necessity is to eliminate the entire ALV framework toolbar, it’s quite simple as it requires setting one field (no_toolbar) in format as ‘X’. Let’s dive into the Selective Handling of the Buttons in ALV Grid Toolbar.

ALV Toolbars

Setting the no_toolbar would give the result as beneath. Kindly check, there is NO Toolbar in the ALV Result.

No Toolbar in ALV Report

We can pass this design as bringing in boundary for strategy ‘set_table_for_first_display’.

Be that as it may, in the event of Article Arranged ALV, debilitating a few fastens and empowering some can get bit precarious.

The objective of this article is to give a comprehensive picture with regards to meeting this prerequisite and sort of make it a solitary complete perspective for all engineers who need some assistance on this point.

As displayed above, in design, there is a field to eliminate the entire toolbar and we have no simple method for handicapping only a couple of buttons from the toolbar list. Selective Handling of the Buttons in ALV Grid Toolbar.

However, every time it isn’t 1 or 0 100% of the time. Here and there, we really want a center way.

Handicapping of a portion of the buttons is a greater amount of the genuine prerequisite you will get in execution projects as ALV network toolbar is an exceptionally useful asset to use it for capabilities like arranging, sifting, trading information to yield and so on.

Yet, how to accomplish it?

OK!!! So the response to this is Occasion Controllers. That’s it!!! Presently on the off chance that you are a novice to Drain Improvement, the occasion overseer is finished in ALV report advancements. In this article, we will attempt to make sense of the ideas and subtleties of occasion overseers however much as could be expected so that regardless of whether you are a fresher, you ought to have the option to figure out it and effectively execute it.

On a significant level, this execution can be isolated into underneath steps:

Making of ALV Framework, Compartment (This item will be alluded from standard kinds given by SAP) and Occasion overseer protests (This article will allude to nearby class).

Meaning of Occasion Overseer class with the technique to deal with toolbar.

Execution of the strategy.

Setting of the occasion controller and its setting off components.

The primary arrangement is there in sync four so we will cover that at the last. Just to ensure you read the total article and figure out the general picture.

Presently prior to going any additionally we should initially get our ideas clear about occasions overseers.

Occasion overseers are strategies which get called once their separate occasions are set off.

This setting off should be possible by means of programming utilizing “raise_event” strategy for the network.

In the first place, we will make matrix variable concerning cl_gui_alv_grid. We would likewise require a compartment to consume this framework.

You can also read for: ABAP for SAP HANA. ALV Report On SAP HANA – Opportunities And Challenges

DATA :  gref_alvgrid TYPE REF TO cl_gui_alv_grid ,              
gref_ccontainer TYPE REF TO cl_gui_custom_container .

Once this is done we need to do the object creation.

*----Creating custom container instance
    CREATE OBJECT gref_ccontainer 
      EXPORTING
        container_name              = con_custom_control_name
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        OTHERS                      = 6.
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
*   checking instance existence, creating instance, setting for first display and refreshing
*----Creating ALV Grid instance
    CREATE OBJECT gref_alvgrid
      EXPORTING
        i_parent          = gref_ccontainer
      EXCEPTIONS
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        OTHERS            = 5.
    IF sy-subrc <> 0
*--Exception handling
    ENDIF.

Now for event handling, we will create a local class lcl_event_handler in the program.

DATA gref_event_handler TYPE REF TO lcl_event_handler .

In the beneath neighborhood class we can make a technique that will deal with our toolbar handling. We acquainted two additional techniques purposefully with further explain our idea about occasion controllers.

Event Handler Class

Presently prior to going for execution, we will likewise perceive how we can set overseers for this strategy.

Set Event Handler
ucomm in sap

As referenced, to raise an occasion, we will set off occasions utilizing ‘raise_event’ strategy which will call handle_user_command from our neighborhood controller class. Further handling should be possible in this technique execution utilizing ‘ucomm’ boundary.

Aside from bringing the occasion up in our program with above strategy, a few unexpected occasions are remembered for standard SAP class CL_GUI_ALV_GRID.

Class CL_GUI_ALV_GRID will set off an occasion for toolbar inside through technique ‘SET_TABLE_FOR_FIRST_DISPLAY’ and we will deal with that brought occasion up in our nearby class strategy execution.

To show records in ALV we use strategy ‘SET_TABLE_FOR_FIRST_DISPLAY’ which calls technique ‘REFRESH_TABLE_DISPLAY’ which thusly calls strategy ‘SOFT_REFRESH_TABLE_DISPLAY’ that further calls strategy ‘SET_TOOLBAR’. This SET_TOOLBAR raises the occasion for toolbar taking care of.

We will deal with this occasion through our custom strategy.

Handle_toolbar strategy as e_object as bringing in boundary. Network toolbar data gets put away in table ‘e_object->mt_toolbar’. This data incorporates Capability, Symbol, Data, Kind of button, Cripple Banner and so on.

To handicap the button it is expected to alter this table ‘e_object->mt_toolbar’ with Cripple Banner with ‘X’. Comparatively to empower button which is crippled by Framework, this banner should be reset.

In beneath technique, we are handicapping not many buttons as well as empowering one button which was debilitating as a matter of course in the framework. Sections of this table will seem to be this.

disable toolbar buttons

Every one of the buttons with their data get put away in table ‘e_object->mt_toolbar’ as displayed underneath.

The end-product will look something like this.

In the event that you are a novice, underneath is the bit by bit process for you.

  1. Create a program in t-code SE38.

Go to t-code SE80 and create a Screen. (Selective Handling of the Buttons in ALV Grid Toolbar)

create a Screen

Give the screen number.

Give a description and hit the Layout.

Click on the Custom Control and drag it across to the layout. (Selective Handling of the Buttons in ALV Grid Toolbar)

how to create custom control in ALV

Give the Custom Control some name. We give it the name as CC_ALV. This name would be utilized in the program.

how to create custom control in ALV

In the program, we have given similar name to customs control.

This finishes the screen and customs control plan. Presently we want to compose our program to deal with it.

Use the below program (at the bottom of this article) and activate your code.

Let’s test it.

OOPs.. we get no output.

What did we miss?

Since your ALV Custom Holder showed nothing. Let us take a quick trip and see the PBO PAI screen.

Uncomment the PBO and PAI modules and retest.

OOPs, again no output.

What did we miss now?

On the off chance that you take a gander at the program intently, the MODULE Show has not yet been characterized in that frame of mind on the screen.

Go to the screen and add the Presentation module in PBO.

Presently test it one final time. At last, you can see the ALV yield.

If you have any desire to analyze, when Occasion Overseers, you would see the underneath distinction.

Trust this article was adequately clear to explain how to utilize custom regulators and compartments. You currently know how to utilize the occasion controllers. Likewise, it ought to have given you enough knowledge to deal with the device bar fastens unequivocally.

Complete Code Snippet.

*&---------------------------------------------------------------------*
*& Program to show ALV Grid Display with Some Toolbar buttons disabled *
*&---------------------------------------------------------------------*
REPORT ztest_alv_grid_test NO STANDARD PAGE HEADING
                  LINE-SIZE  132
                  LINE-COUNT 65.
*--------------------------------------------------------------------*
* Tables
*--------------------------------------------------------------------*
TABLES : mara.
*--------------------------------------------------------------------*
* Types
*--------------------------------------------------------------------*
TYPES : BEGIN OF tty_mara,
          matnr TYPE matnr,
          ernam TYPE ernam,
          mtart TYPE mtart,
          matkl TYPE matkl,
        END OF tty_mara.
*--------------------------------------------------------------------*
* Data
*--------------------------------------------------------------------*
DATA : g_tab_mara TYPE STANDARD TABLE OF tty_mara.
*--- Object for ALV grid
DATA gref_alvgrid TYPE REF TO cl_gui_alv_grid .
*--- Object for Custom container
DATA gref_ccontainer TYPE REF TO cl_gui_custom_container .
*--- Name of the custom control added on the screen
CONSTANTS con_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
*--- Field catalog
DATA g_tab_fieldcat TYPE lvc_t_fcat .
*--- Field catalog structure
DATA g_wa_fieldcat TYPE lvc_s_fcat .
*----Layout
DATA g_str_layout TYPE lvc_s_layo.
*--- Event handler class
CLASS lcl_event_handler DEFINITION DEFERRED.
*--- Object for Event Handler
DATA gref_event_handler TYPE REF TO lcl_event_handler .
*--------------------------------------------------------------------*
* Local Class Definition for Event Handler
*--------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION .
  PUBLIC SECTION .
    CLASS-DATA alv_err TYPE subrc.
    METHODS
*     Event handler for toolbar in alvgrid.
      handle_toolbar
                    FOR EVENT toolbar OF cl_gui_alv_grid
        IMPORTING e_object.
ENDCLASS.
*--------------------------------------------------------------------*
* Local Class Implementation for Event Handler
*--------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION .
* Method for toolbar handling
  METHOD handle_toolbar.

    DATA : l_wa_toolbar TYPE stb_button.

*   Disabling some Buttons
    MOVE 'X' TO l_wa_toolbar-disabled.
*   This sets the data
    MODIFY e_object->mt_toolbar FROM l_wa_toolbar TRANSPORTING disabled
    WHERE function = '&DETAIL' OR function = '&MB_SUM' OR function = '&MB_VIEW'
    OR function = '&MB_SUBTOT' OR function = '&PRINT_BACK' OR function = '&COL0'
    OR function = '&GRAPH' OR function = '&INFO' OR function = '&REFRESH'
    OR function = '&LOCAL&CUT' OR function = '&LOCAL&COPY' OR function = '&LOCAL&PASTE'
    OR function = '&LOCAL&UNDO' OR function = '&LOCAL&APPEND' OR function = '&LOCAL&INSERT_ROW'
    OR function = '&LOCAL&DELETE_ROW' OR function = '&LOCAL&COPY_ROW' .

*   Enabling some Buttons
    MOVE ' ' TO l_wa_toolbar-disabled.
*   This sets the data
    MODIFY e_object->mt_toolbar FROM l_wa_toolbar TRANSPORTING disabled
    WHERE function = '&FIND_MORE'.

  ENDMETHOD.                    "handle_toolbar
ENDCLASS .

*--------------------------------------------------------------------*
* Selection Screen
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK bm WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR mara-matnr.
SELECTION-SCREEN END OF BLOCK bm.

*--------------------------------------------------------------------*
* Start of Selection
*--------------------------------------------------------------------*
START-OF-SELECTION.
* Fetch data
  PERFORM get_testdatafordisplay.

*--------------------------------------------------------------------*
* End of Selection
*--------------------------------------------------------------------*
END-OF-SELECTION.
* Field Catalog
  PERFORM create_fieldcat CHANGING g_tab_fieldcat.
* Layout
  PERFORM create_layout CHANGING g_str_layout.
* Display Report
  PERFORM display_report.

*&---------------------------------------------------------------------*
*&      Form  GET_TESTDATAFORDISPLAY
*&---------------------------------------------------------------------*
FORM get_testdatafordisplay .
  SELECT matnr ernam mtart matkl
    FROM mara
  INTO CORRESPONDING FIELDS OF TABLE g_tab_mara
  WHERE matnr IN s_matnr  .
ENDFORM.                    " GET_TESTDATAFORDISPLAY
*&---------------------------------------------------------------------*
*&      Form  CREATE_FIELDCAT
*&---------------------------------------------------------------------*
FORM create_fieldcat CHANGING c_tab_fieldcat TYPE lvc_t_fcat.
  DATA : ls_fcat TYPE lvc_s_fcat.
  ls_fcat-col_pos = 0.
  ls_fcat-fieldname = 'MATNR'.
  ls_fcat-coltext = 'Material Number'.
  ls_fcat-seltext = 'Material Number'.
  ls_fcat-col_opt = 'X'.
  APPEND ls_fcat TO c_tab_fieldcat.
  ls_fcat-col_pos = 1.
  ls_fcat-fieldname = 'ERNAM'.
  ls_fcat-coltext = 'Created By'.
  ls_fcat-seltext = 'Created By'.
  ls_fcat-col_opt = 'X'.
  APPEND ls_fcat TO c_tab_fieldcat.
  ls_fcat-col_pos = 2.
  ls_fcat-fieldname = 'MTART'.
  ls_fcat-coltext = 'Material Type'.
  ls_fcat-seltext = 'Material Type'.
  ls_fcat-col_opt = 'X'.
  APPEND ls_fcat TO c_tab_fieldcat.
  ls_fcat-col_pos = 3.
  ls_fcat-fieldname = 'MATKL'.
  ls_fcat-coltext = 'Material Group'.
  ls_fcat-seltext = 'Material Group'.
  ls_fcat-col_opt = 'X'.
  APPEND ls_fcat TO c_tab_fieldcat.
ENDFORM.                    " CREATE_FIELDCAT
*&---------------------------------------------------------------------*
*&      Form  CREATE_LAYOUT
*&---------------------------------------------------------------------*
FORM create_layout CHANGING c_str_layout TYPE lvc_s_layo..
*  c_str_layout-no_toolbar = 'X'.
ENDFORM.                    " CREATE_LAYOUT

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_REPORT
*&---------------------------------------------------------------------*
FORM display_report .
  CALL SCREEN 100.
ENDFORM.                    " DISPLAY_REPORT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  DATA: l_var_valid      TYPE c,
        l_selected_cells TYPE STANDARD TABLE OF lvc_s_cell.

  CALL METHOD gref_alvgrid->check_changed_data
    IMPORTING
      e_valid = l_var_valid.

  CALL METHOD gref_alvgrid->get_selected_cells
    IMPORTING
      et_cell = l_selected_cells.

  CASE sy-ucomm.
    WHEN 'EXIT' OR 'ENDE' or 'ECAN'.
      LEAVE PROGRAM.
    WHEN 'BACK' OR 'E'.
      LEAVE TO SCREEN 0.
    WHEN 'INS'.
      CALL METHOD gref_alvgrid->raise_event
        EXPORTING
          i_ucomm = 'INS'.
    WHEN 'DELETE'.

    WHEN OTHERS.
  ENDCASE.

ENDMODULE.                 " DISPLAY  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  DISPLAY  OUTPUT
*&---------------------------------------------------------------------*
MODULE display OUTPUT.
  PERFORM display_test_alv.
ENDMODULE.                 " DISPLAY  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  DISPLAY_TEST_ALV
*&---------------------------------------------------------------------*
FORM display_test_alv .
  IF gref_alvgrid IS INITIAL .
*----Creating custom container instance
    CREATE OBJECT gref_ccontainer
      EXPORTING
        container_name              = con_custom_control_name
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        OTHERS                      = 6.
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
*   checking instance existence, creating instance, setting for first display and refreshing
*----Creating ALV Grid instance
    CREATE OBJECT gref_alvgrid
      EXPORTING
        i_parent          = gref_ccontainer
      EXCEPTIONS
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        OTHERS            = 5.
    IF sy-subrc <> 0.
*--Exception handling
    ENDIF.
*--Creating an instance for the event handler
    CREATE OBJECT gref_event_handler.
    SET HANDLER gref_event_handler->handle_toolbar FOR gref_alvgrid .

    CALL METHOD gref_alvgrid->set_table_for_first_display
      EXPORTING
        is_layout                     = g_str_layout
      CHANGING
        it_outtab                     = g_tab_mara
        it_fieldcatalog               = g_tab_fieldcat
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
  ENDIF.
ENDFORM.                    " DISPLAY_TEST_ALV

YOU MAY LIKE THIS

What Companies Use SAP Software in India

AI and Machine Learning in SAP: A Practical Guide

Top SAP ABAP Reports Interview Questions: Be Prepared

Courses For Sap ABAP On HANA Training

SAP

ABAP for SAP HANA. ALV Report On SAP HANA – Opportunities And Challenges

ALV Report On SAP HANA

Let’s dive into the ALV Report On SAP HANA – Opportunities And Challenges. The HANA Tempest has been clearing everybody away. As of September 2017, SAP report guaranteed there were in excess of 1000 Clients currently live on S/4HANA. So tomorrow while possibly not today, all Professionals chipping away at SAP would need to swim through the HANA waters. Reducing the SAP Professionals to ABAPer, who program ALV Reports each and every other week. Have you thought about how fortunate or unfortunate it tends to be to plan an ALV in SAP with HANA as Suite as well as Data set? In this article, we would attempt to introduce stories from the two times, preceding HANA and in HANA.ALV Report On SAP HANA – Opportunities And Challenges!

ALV Reports are the Cockroaches of SAP world, which would survive every evolution.

Roots or Establishment or the Beginning point in ALV is same in HANA World as it was before in conventional data set, for example Choice SCREEN. Tragically, we will quite often make a few determinations when we see this. The screen needs to have checkboxes, radio buttons, choice screen blocks and so forth. This is miserable on the grounds that toward one side we see Fiori Platforms have dynamic and beautiful screens with applications upgrading Client Experience (UX) utilizing SAP UI5 and at the opposite end the customary ALV.

Rather cribbing about it, we want to recall that clients (actually) request ALV reports like standard T-Code yield for example ME2N (citing on the grounds that that was the prerequisite I got). Afterall everything isn’t about client experience. Complex business needs likewise get some weight.

Regardless, whether you are attempting to learn Fiori or SAPUI5, ALV reports can’t be supplanted. In this way, likewise begin investigating the new way you can make the ALVs.

How might we make our (ABAPers) lives merry and fascinating? Add HANA in with the general mish-mash and what you get is simpler to code (well not really) and all the more critically more prominent improvement in the exhibition.

The improvement in execution is exclusively credited to one thing that is the idea called “Code Push Down” or “Code to Information (Data set) Worldview”. Heard it anyplace? Try not to say No. We are at the twentieth part in our HANA ABAP Series.

What is Code Push Down? (ALV Report On SAP HANA – Opportunities And Challenges)

Here we have a tipping point. One can go for the strategy for utilizing Discs View alongside AMDP (if vital) or go with IDA. Utilizing IDA is much more straightforward than AMDP, yet possibly one can’t be a swap for the other. They play their own parts to play. In the following article, I will cover the distinctions and benefits of IDA against Albums.

Prior to looking down it would be smart to discover somewhat more about AMDP (ABAP Oversaw Data set System) and IDA (Coordinated Information Access).

So for ALV in HANA, we have the accompanying:

  1. Selection Screen
  2. Data is ready in CDS +/- AMDP

What next? Just connect them.

3. Applying selection screen criteria into CDS view entries.

The third step is a piece precarious. We again have various open doors here.

3.1 Either pass all the determination screen channels into AMDP ( NOT Compact discs View as a result of the way that Cds Perspectives are defined and can’t take more than one incentive for a solitary field and choice screen of the ALV report has select choices which are in range tables)

OR

3.2 Get every one of the passages from Compact discs View into your Application Layer and afterward continue with regular coding practice.

At this point, experienced ABAPers would agree that that first methodology (AMDP) would do every one of the positive qualities regarding execution.

Now we have narrowed down to:

  1. Choice Screen
  2. Information is prepared in Discs +/ – AMDP
  3. Applying choice screen measures into Discs view sections utilizing AMDP and bringing just required passages into AS layer and continuing with regular SALV manufacturing plant class utilizing Oh no.

You can also read for:- OOPs Report Using Splitter and ALV Tree Combination

Technical Points:

  1. Conversion of SELECT-OPTIONS into Dynamic “WHERE CLAUSE”: When the standard determination screen is constructed, the main obstacle is incorporate the select choices into AMDP. To accomplish that we have the accompanying code piece:
DATA(lv_where) = cl_shdb_seltab=>combine_seltabs(
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
) ).

Trust you can grasp the above code. Else, the beneath elective for a similar activity can assist you with bettering.

cl_shdb_seltab=>combine_seltabs(
EXPORTING
it_named_seltabs = VALUE #(
( name = 'MATNR' dref = REF #( so_matnr[] ) )
( name = 'EBELN' dref = REF #( so_ebeln[] ) )
)
RECEIVING
rv_where = DATA(lv_where) ).

2. Using Dynamic where clause in AMDP: The following test is to utilize the where condition. There is an element in SAP AS 7.40 and higher of “APPLY Channel”. The lv_where statement worked above is passed to AMDP technique boundary ip_filters.

Conclusion: ALV Report On SAP HANA – Opportunities And Challenges

Making the most of HANA DB and HANA instruments like HANA Studio we enjoy following benefits ( opportunity ):

  1. Further developed Execution since there is Code Push Down and larger part of the Information bringing is finished at HANA DB alongside collections/total/midpoints.
  2. On the Fly powerful custom naming of the Result Fields in ALV [can be finished utilizing CDS].
  3. Dynamic SELECT questions in AMDP in light of the information given by Client and content put away in the DB [e.g. Assuming that in DB we have fields City and Country, we can utilize the CASE articulation to finish up assuming that input city given by the client is the capital or not].
  4. Dispose of FOR ALL Sections. [Use Internal Joins instead]. Did we simply get into another sticky situation?
  5. Can be extremely powerful for External Participate in situations where we really want to skirt the field esteems that are available in one table however NOT in other.

The opposite side of the story, challenges:

  • At the point when we go with Discs Perspectives to extricate information into AS layer, then, at that point, there might be still some presentation issues (despite the fact that Cds relics would in any case give great exhibitions, still some unacceptable utilization of Cds can blow up).

Kindly trust that the following article will get a brief look at the genuine code to exhibit all the abovementioned and IDA. Along these lines, if it’s not too much trouble, remain tuned and get yourself HANA-tized.

Now we want to hear from you.

Kindly leave your input, stories and speedy remarks beneath.

YOU MAY LIKE THIS

Auto Refresh ALV Using CL_GUI_TIMER

Courses For Sap ABAP On HANA Training

Oracle cloud for manufacturing

SAP ABAP Interview Questions Real time Expectations

SAP

Extensive Tips and Tricks for Interactive SAP ALV

Tips and Tricks for Interactive SAP ALV

In the wake of chipping away at various activities and utilizing intuitive ALV Uh oh ideas broadly, I considered drafting one record with some valuable data, which will assist each engineer with defeating the vast majority of the plan prerequisites in any intuitive ALV Report.

Do you be aware, you can Really take a look at the Consistency of an ALV with simply SHIFT + 2 RIGHT Snaps? Let’s dive into the Tips and Tricks for Interactive SAP ALV!

Allow us to begin our The present subject.

1. Create a Container in the screen, say ‘ALV_CONT’.

2. Create Reference Object for the Container:

CREATE OBJECT container_r
        EXPORTING
          container_name              = 'ALV_CONT'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.

3. Create Reference Object for the ALV Grid as below:

CREATE OBJECT grid_r
          EXPORTING
            i_parent = container_r.

4. Define the ALV Layout as below:

gw_layout-cwidth_opt = abap_true.
gw_layout-zebra = abap_true.
gw_layout-sel_mode = ‘D’.

5. Populate the Field Catalog data for display as below:

lv_pos = lv_pos + 1.              “Position number
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'BUKRS'.  "Company Code
wa_fieldcat-col_pos = lv_pos.
wa_fieldcat-ref_table = 'T001'.
APPEND wa_fieldcat TO gt_fieldcat.

5.1. For Field Editable:

wa_fieldcat-edit = abap_true.

Also read:- Introduction to ALV with an Editable Row

5.2. For field No Display in output:

wa_fieldcat-no_out = abap_true.   “Check for field display

5.3. For field display as a Checkbox:

wa_fieldcat-checkbox = abap_true.

5.4. For the field where customized F4-Help is required:

wa_fieldcat-f4availabl  = abap_true.

5.5. For the field where the Summation is required:

wa_fieldcat-do_sum = abap_true.

Moreover, the field in light of which summation will show up should be characterized as below(eg. ANLKL):

CLEAR li_sort.

lst_sort-fieldname = 'ANLKL'.

lst_sort-subtot = abap_true.

APPEND lst_sort TO li_sort

6. To Restrict Functions from ALV display:

lw_exclude = cl_gui_alv_grid=>mc_fc_check.
APPEND lw_exclude TO gt_exclude.
lw_exclude = cl_gui_alv_grid=>mc_fc_refresh.
APPEND lw_exclude TO gt_exclude.
lw_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND lw_exclude TO gt_exclude.
lw_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND lw_exclude TO gt_exclude.
lw_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND lw_exclude TO gt_exclude.
lw_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND lw_exclude TO gt_exclude.

7. Populate the Data in table GT_DATA.

8. Call the method set_table_for_first_display for Display of data.

CALL METHOD grid_r->set_table_for_first_display
EXPORTING
i_structure_name     = 'ZFI_S_PIS'  “Structure
is_layout            = gw_layout
it_toolbar_excluding = gt_exclude
i_save               = gc_save_a   "A
i_default            = abap_true
CHANGING
it_outtab            = gt_data[]     “Table with ALV data

It_sort              = li_sort
it_fieldcatalog      = gt_fieldcat[].
CALL METHOD cl_gui_control=>set_focus
EXPORTING
control = grid_r.

Data declaration for Reference:

Data:

container_r TYPE REF TO cl_gui_custom_container,      "Container for ALV PIS data

grid_r TYPE REF TO cl_gui_alv_grid,                                "Grid for ALV PIS data

gt_exclude TYPE ui_functions,                                            "Exclude functions from ALV

gt_fieldcat TYPE lvc_t_fcat,                                                "Field catalog for ALV PIS data

ref_aplic TYPE REF TO lcl_application_alv,

gw_layout   TYPE lvc_s_layo.                                              "Layout for PIS

9. If the Data just needs to be Refreshed:

CALL METHOD grid_r->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS   = 2.

10. To make fields Editable, call the below method while calling ALV for display:

CALL METHOD grid_r->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.  " enter.  "MC_EVT_MODIFIED

11. Now to Validate the Data Changed in the grid we need to do the following:

11.1. Define a class (lcl_application_alv) definition and implementation and define event (handle_data_changed) for event data_changed of class cl_gui_alv_grid in it.

CLASS lcl_application_alv DEFINITION.
PUBLIC SECTION.
METHODS:
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed e_onf4_after.
ENDCLASS.                    "lcl_application_alv DEFINITION

11.2. In method handle_data_changed call methods get_cell_value and modify_cell to get and modify cell values like below –

LOOP AT er_data_changed->mt_good_cells INTO lw_good.

WHEN 'KUNNR'.
CALL METHOD er_data_changed->get_cell_value
EXPORTING
i_row_id    = lw_good-row_id
i_fieldname = lw_good-fieldname
IMPORTING
e_value     = gv_kunnr.
*     Get name1 for the kunnr
SELECT SINGLE name1 FROM kna1
INTO lw_pis-name1
WHERE kunnr = gv_kunnr .
IF sy-subrc = 0.
*              update name1 in table
CALL METHOD er_data_changed->modify_cell
EXPORTING
i_row_id    = lw_good-row_id
i_fieldname = 'NAME1'
i_value     = lv_name1.
ELSE.
MESSAGE i000 WITH 'Invalid Customer number in row'(027)
lw_good-row_id.
ENDIF.

12. Now before calling method set_table_for_first_display, write the below code:

CREATE OBJECT ref_aplic.
SET HANDLER ref_aplic->handle_data_changed FOR grid_r.

13. Assuming that the Field Inventory is expected to change when various activities are executed for the ALV lattice information show, call strategy set_frontend_fieldcatalog subsequent to populating the field index information to revive the field list settings.

CALL METHOD grid_r->set_frontend_fieldcatalog
EXPORTING
it_fieldcatalog = gt_fieldcat[].

14. In the event that Contingent F4 Help is expected to be populated in the ALV, express in view of one information in ALV, another field F4-Help information should be populated then do the accompanying:

14.1. Prior to calling strategy set_table_for_first_display, we need to Enlist the fields we need to have the tweaked F4-help like beneath:

lw_f4-fieldname  = 'ZFI_BRN_LOC'.    "IFSC code
lw_f4-register   = abap_true.
lw_f4-getbefore  = space.
lw_f4-chngeafter = abap_true.
INSERT lw_f4 INTO TABLE lt_f4.

CLEAR lw_f4.
lw_f4-fieldname  = 'STGRD'.  "Reason for Reversal
lw_f4-register   = abap_true.
lw_f4-getbefore  = space.
INSERT lw_f4 INTO  TABLE lt_f4.

CALL METHOD grid_r->register_f4_for_fields
EXPORTING
it_f4 = lt_f4.

14.2. In class lcl_application_alvdefine the method and then implement it.

METHODS:
handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.

14.3. In class lcl_application_alv implementation, implement the method handle_on_f4.

*-------------------------------------------------------------
* Add the custom F4 values for IFSC code
*-------------------------------------------------------------
IF e_fieldname = 'ZFI_BRN_LOC'.
IF gv_flag_inst_type = abap_true.  "For chq only
*        IF gt_data[] IS INITIAL.
CLEAR lt_knbk.
CLEAR gt_data.
READ TABLE gt_pis INTO lw_pis INDEX es_row_no-row_id.
IF sy-subrc = 0.
SELECT bankl bkref FROM knbk
INTO TABLE lt_knbk WHERE kunnr = lw_pis-kunnr.  "gv_kunnr.
IF sy-subrc = 0.
LOOP AT lt_knbk INTO lw_knbk.
lw_data-zfi_brn_loc = lw_knbk-bankl.
lw_data-zfi_bnk_code = lw_knbk-bkref.
APPEND lw_data TO gt_data.
CLEAR lw_data.
ENDLOOP.
ENDIF.
ENDIF.
*        ENDIF.
*Call the function module to display the custom F4 values
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield        = 'ZFI_BRN_LOC'
window_title    = 'List of IFSC entries'(026)
value_org       = gc_val_org
TABLES
value_tab       = gt_data[]
return_tab      = lt_ret[]
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS          = 3.
*    (note: gt_ret[] contains the row id selected by the user from the list of f4 values)
IF sy-subrc = 0.
READ TABLE lt_ret INTO lw_sel INDEX 1.
ASSIGN er_event_data->m_data->* TO <itab>.
READ TABLE gt_pis INDEX es_row_no-row_id
INTO lw_pis.
lw_modi-row_id   = es_row_no-row_id.
lw_modi-fieldname = 'ZFI_BRN_LOC'.
lw_modi-value     = lw_sel-fieldval.
APPEND lw_modi TO <itab>.

READ TABLE gt_data INTO lw_data
WITH KEY zfi_brn_loc = lw_modi-value+0(11).
IF sy-subrc = 0.
lw_modi-row_id   = es_row_no-row_id.
lw_modi-fieldname = 'ZFI_BNK_CODE'.
lw_modi-value     = lw_data-zfi_bnk_code.
APPEND lw_modi TO <itab>.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*-------------------------------------------------------------
* Add the custom F4 values for Reversal Reason
*-------------------------------------------------------------
IF e_fieldname = 'STGRD'.
CLEAR: lt_t041ct, lt_return.
IF gv_uname = gc_depo_userid.    "BTDEPO
SELECT stgrd txt40 FROM t041ct
INTO TABLE lt_t041ct
WHERE spras = sy-langu
AND stgrd = gc_stgrd_06.
IF sy-subrc = 0.
*    do nothing
ENDIF.
ELSE.
SELECT stgrd txt40 FROM t041ct
INTO TABLE lt_t041ct
WHERE spras = sy-langu
AND stgrd IN (gc_stgrd_06,
gc_stgrd_08,
gc_stgrd_09,
gc_stgrd_10).
IF sy-subrc = 0.
*    do nothing
ENDIF.
ENDIF.

IF sy-subrc = 0.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield        = 'STGRD'
window_title    = 'List of Rev reason entries'(025)
value_org       = gc_val_org
TABLES
value_tab       = lt_t041ct
return_tab      = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS          = 3.
IF sy-subrc = 0.
READ TABLE lt_return INTO lw_sel INDEX 1.
ASSIGN er_event_data->m_data->* TO <itab>.
READ TABLE gt_pis INDEX es_row_no-row_id
INTO lw_pis.
lw_modi-row_id   = es_row_no-row_id.
lw_modi-fieldname = 'STGRD'.
lw_modi-value     = lw_sel-fieldval.
APPEND lw_modi TO <itab>.
ENDIF.
ENDIF.
ENDIF.
er_event_data->m_event_handled = abap_true. "(to inform grid that f4 was handled manually)

14.4. Now after Register_F4_for_Fields is called, add below code:

SET HANDLER ref_aplic->handle_on_f4 FOR grid_r.

15. When the Back button is pressed, clear and refresh as below:

CALL METHOD grid_r->refresh_table_display.
CALL METHOD grid_r->free.
CALL METHOD container_r->free.
CALL METHOD cl_gui_cfw=>flush.

16. To make an ALV invisible add below code:

CALL METHOD inv_grid_r->set_visible( EXPORTING visible = '0' ).

17. To make Row Selection through code: Pass the row ids into lt_lvc_s_roid-

lw_lvc_s_roid-row_id = sy-tabix.
APPEND lw_lvc_s_roid TO lt_lvc_s_roid.

CALL METHOD grid_r->set_selected_rows
EXPORTING
it_row_no = lt_lvc_s_roid.

18. To Reset Scroll Bar Position after selecting rows through code, add the below code:

CALL METHOD grid_r->get_scroll_info_via_id
IMPORTING
es_row_no   = lw_row_no
es_row_info = lw_row_info
es_col_info = lw_col_info.

CALL METHOD grid_r->set_selected_rows
EXPORTING
it_row_no = lt_lvc_s_roid.

CALL METHOD grid_r->set_scroll_info_via_id(
EXPORTING
is_row_no   = lw_row_no
is_row_info = lw_row_info
is_col_info = lw_col_info
).

19. Display Top-of-Page data:

19.1. To show To-of-page subtleties first the primary holder should be parted into equal parts – one will be alloted to the Network and the other for populating the top header subtleties as underneath:

* Create TOP-Document

CREATE OBJECT g_dyndoc_id

EXPORTING

style = 'ALV_GRID'.

* Create Splitter for custom_container

CREATE OBJECT g_splitter

EXPORTING

parent  = g_custom_container

rows    = 2

columns = 1.
CALL METHOD g_splitter->get_container

EXPORTING

row       = 1

column    = 1

RECEIVING

container = g_parent_top.
CALL METHOD g_splitter->get_container

EXPORTING

row       = 2

column    = 1

RECEIVING

container = g_parent_grid.
* Set height for g_parent_html

CALL METHOD g_splitter->set_row_height

EXPORTING

id     = 1

height = 20.

CREATE OBJECT g_grid

EXPORTING

i_parent          = g_parent_grid

EXCEPTIONS

error_cntl_create = 1

error_cntl_init   = 2

error_cntl_link   = 3

error_dp_create   = 4

OTHERS            = 5.

19.2. Now in the local class, define method handle_top_of_page as below:

METHODS:

*Define method to handle Toolbar

handle_top_of_page FOR EVENT top_of_page

OF cl_gui_alv_grid

IMPORTING e_dyndoc_id.

19.3. In the class implementation, define the method details:

METHOD handle_top_of_page.

PERFORM f_event_top_of_page USING g_dyndoc_id.

ENDMETHOD. "EVENT_HANDLER

19.4. Logic in the Subroutine:

FORM f_event_top_of_page USING   dg_dyndoc_id TYPE REF TO cl_dd_document.
DATA: lv_name    TYPE lvc_fname,  "Name

li_t093b   TYPE STANDARD TABLE OF ty_t093b

INITIAL SIZE 0,  "T093B temp table

lst_t093b  TYPE ty_t093b,  "T093b wa

lv_reptext TYPE reptext,  "report Text

lv_text    TYPE sdydo_text_element. "Final text
* Header1

lv_name = c_header1.

PERFORM f_read_text USING lv_name

CHANGING lv_reptext.

lv_text = lv_reptext.

CALL METHOD dg_dyndoc_id->add_text

EXPORTING

text         = lv_text

sap_style    = cl_dd_area=>heading

sap_fontsize = cl_dd_area=>large

sap_color    = cl_dd_area=>list_heading_int. 

* Add new-line

CALL METHOD dg_dyndoc_id->new_line.
* Header2

WRITE s_budat-low TO g_fdate.

WRITE s_budat-high TO g_tdate.

lv_name = c_header2.

PERFORM f_read_text USING lv_name

CHANGING lv_reptext.

REPLACE '&G_FDATE&' INTO lv_reptext WITH g_fdate.

REPLACE '&G_TDATE&' INTO lv_reptext WITH g_tdate.

lv_text = lv_reptext.

CALL METHOD dg_dyndoc_id->add_gap.

CALL METHOD g_dyndoc_id->add_text

EXPORTING

text         = lv_text

sap_emphasis = cl_dd_area=>heading.

* Add new-line

CALL METHOD dg_dyndoc_id->new_line.
* Header3

lv_name = c_header3.

PERFORM f_read_text USING lv_name

CHANGING lv_reptext.

lv_text = lv_reptext.

CALL METHOD dg_dyndoc_id->add_gap.

CALL METHOD g_dyndoc_id->add_text

EXPORTING

text         = lv_text

sap_emphasis = cl_dd_area=>heading.

* Add new-line

CALL METHOD dg_dyndoc_id->new_line.

* Header4

lv_name = c_header4.

PERFORM f_read_text USING lv_name

CHANGING lv_reptext.

lv_text = lv_reptext.

li_t093b[] = i_t093b[].

SORT li_t093b BY waers.

DELETE ADJACENT DUPLICATES FROM li_t093b COMPARING waers.

LOOP AT li_t093b INTO lst_t093b.

CONCATENATE lv_text lst_t093b-waers INTO lv_text

SEPARATED BY space.

ENDLOOP.

CALL METHOD dg_dyndoc_id->add_gap.

CALL METHOD g_dyndoc_id->add_text

EXPORTING

text         = lv_text

sap_emphasis = cl_dd_area=>heading.
* Display output

PERFORM f_display.

ENDFORM.                    " EVENT_TOP_OF_PAGE
*&---------------------------------------------------------------------*

*&      Subroutine F_DISPLAY

*&---------------------------------------------------------------------*

*       Display data

*----------------------------------------------------------------------*

FORM f_display.

* Creating html control

IF g_html_cntrl IS INITIAL.

CREATE OBJECT g_html_cntrl

EXPORTING

parent = g_parent_top.

ENDIF.

CALL METHOD g_dyndoc_id->merge_document.

g_dyndoc_id->html_control = g_html_cntrl.

* Display document

CALL METHOD g_dyndoc_id->display_document

EXPORTING

reuse_control      = abap_true

parent             = g_parent_top

EXCEPTIONS

html_display_error = 1.

IF sy-subrc NE 0.

*    Error in displaying top-of-page

MESSAGE i023.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM.                    " display

19.5. Before method set_table_for_first_display is called write the below code:

SET HANDLER ref_aplic->handle_top_of_page FOR grid_r.

CALL METHOD g_dyndoc_id->initialize_document

EXPORTING

background_color = cl_dd_area=>col_textarea.

* Processing events

CALL METHOD g_grid->list_processing_events

EXPORTING

i_event_name = 'TOP_OF_PAGE'

i_dyndoc_id  = g_dyndoc_id.

Some data declaration help:

g_dyndoc_id        TYPE REF TO cl_dd_document,   "Object ref for document header

g_splitter         TYPE REF TO cl_gui_splitter_container, "Object ref for splitter

g_parent_grid      TYPE REF TO cl_gui_container,   "Object ref for grid container

g_parent_top       TYPE REF TO cl_gui_container,   "Object ref for top container

g_html_cntrl       TYPE REF TO cl_gui_html_viewer, "Object ref for html control

g_custom_container TYPE REF TO cl_gui_custom_container, "Object ref for custom container

i_fcat             TYPE lvc_t_fcat.         "Field catalog

YOU MAY LIKE THIS

ABAP Applications for the Cloud: Modernizing for the Future

Top SAP ABAP Reports Interview Questions: Be Prepared

What are the ERP modules

SAP ABAP on HANA

SAP

Introduction to ALV with an Editable Row

Introduction to ALV with an Editable Row

Practically we all are very mindful of ALVs with an editable section. Assuming got some information about an editable line, we could see bewildered faces. Albeit the idea has been talked about in various discussions often previously, no whole code was found to carry out that in a hurry. The accompanying conversation will make sense of all through making an ALV with an Editable Row. Additionally, find the whole working code toward the end which can be downloaded and yet again utilized.

Requirement of ALV with an Editable Row

We should expect the necessity is to show buy orders given as a contribution to the choice screen. Buy requests will be shown with all thing numbers and material numbers. In our result screen, we need Buy Request Number, Plant, Stockpiling, Organization Code, Archive Type, Thing No and Material. Moreover, we ought to have an area of interest empower field on Buy request number after tapping on which framework ought to explore to the ME21N screen. At the point when tapped on back from ‘ME21N’ exchange every one of the lines of that specific buy request ought to become editable.

You can also read for:- Why are developers so fond of ‘REUSE_ALV_GRID_DISPLAY’?

Program Construct

  1. Types and Structure Declarations
  2. Work Areas and Internal Tables
  3. Declare Local Class For Event Handling
  4. Class Implementation
  5. Selection Screen Design
  6. Start Of Selection
  7. Call Screen
  8. PBO
  9. Module DISPLAY_ALV
  10. PAI

1. Types and Structure Declarations

OOPS ALV Reports in ABAP

Note – Aside from the expected sorts, in our last kinds structure we utilized ‘fstyl’ of type lvc_t_styl to control the editable settings. This assumes the real part to make the last ALV yield table lines editable or show as it were.

OOPs Report

2. Workspaces and Interior Tables Note-LS_STYLEROW and LT_STYLEROW are utilized for holding the style data we will make later in this article.

3. Declare Local Class for Event Handling

Hot Spot in ALV

For area of interest occasion, we have made this class-technique.

4. Class Implementation

ALV Report to make Row Editable

This part will deal with the significant errands expected in our program. Above all else, we want to have the area of interest route usefulness. This has been accomplished with ‘Consider Exchange’ explanation in the wake of perusing the row_id and comparing PO number for that. Additionally note, for that specific PO number, we have gathered all the details into the GT_FINAL table which we will make editable.

Presently we ought to deal with the column altering rationale.

SAP ALV report

Make note of the utilization of this segment (cl_gui_alv_grid=>mc_style_enabled). This really makes a specific field of your ALV editable. For this necessity, I utilized every one of the fields. On the other hand, in the event that you have a necessity to create 2 fields of a specific column editable you can basically pass just those two field names and you will see those as editable.

You need to make fields editable as well as need to deal with making those handicapped on the off chance that the altering condition isn’t met.

Editable Field in ALV

Presently you ought to be great with the editable line usefulness. We should continue on toward the fundamental body of our program.

5. Selection Screen Design

*&-------------------------------------------------------------------*
*&     S E L E C T I O N    S C R E E N
*&-------------------------------------------------------------------*
selection-screen: begin of block B1 with frame title text-001.
select-options: s_ebeln for ekko-ebeln.
selection-screen: end of block B1.

6. Start Of Selection

*&-------------------------------------------------------------------*
*&     S T A R T   O F   S E L E C T I O N
*&-------------------------------------------------------------------*
start-of-selection.
perform fetch_data.
call screen 0100.

Make a subroutine for bringing the fundamental information for framework show. The stream rationale for the custom screen made will look like underneath.

custom screen in SAP

6.a. Refer the full code.

6.b. Refer the full code.

6.c. Module Display_ALV

This part contains rationale to recognize whether the program has been executed in closer view/foundation. Contingent upon that, it utilizes a specific class reference. Keep in mind, on the off chance that you have made an object of a custom compartment (for example assuming you have utilized CL_GUI_CUSTOM_CONTAINER), foundation execution of the report will come up short and occupation status will be dropped. Continuously use docking holder reference in such cases. We use CL_GUI_ALV_GRID_OFFLINE to distinguish whether the program is executed on frontal area/foundation.

Docking Container

6.d. Refer the full code.

We should perceive how accurately it was planned.

Selection Screen
SAP OOPs Report
List Screen

Click on any Buying Record no in list screen and explore back to the report. You ought to have the option to see all related lines of the buying report editable.

Attempted with other PO number and it worked consistently!

Why ALV Report is dumping in Background

Execute the program in foundation

Foundation Occupation Status ought to be “Done”

Further Reading

For comparative usefulness and better comprehension allude BCALV_EDIT_02 program.

Extra Perusing

The client will clearly need some altering activity with change-save usefulness. When the lines are in the editable mode, the client will change a few information and hit save button. This will ultimately set off the PAI part of the custom screen and to deal with the save we want to utilize ‘SPOS’ capability code. Changes can be saved to particular standard tables/custom tables(depending on the prerequisite). To simplify our article I presented no such save activity except for showed the changed information in another ALV design utilizing the manufacturing plant technique.

Code for the PAI section is attached below.

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       Process After Input and Back,Exit and Cancel logic
*----------------------------------------------------------------------*

MODULE USER_COMMAND_0100 INPUT.

  if sy-ucomm = 'E'.

    leave to screen 0.

  elseif sy-ucomm = 'ENDE'.

    leave to screen 0.

  elseif sy-ucomm = 'ECAN'.

    leave to screen 0.

  elseif sy-ucomm = 'SPOS'.

* When save trigger this section
  ref_ag->check_changed_data(

  importing e_valid = c_valid ).

  if c_valid eq abap_true.

*Check the data change

    if lt_final_old[] NE lt_final[].

      LOOP AT lt_final into ls_final.

        read table lt_final_old into ls_final_old index sy-tabix.

         if ls_final_old ne ls_final.

           append ls_final to t_final.

         endif.

      ENDLOOP.

*Any table update should be handled here

*Create the ALV to show the final data updated

    TRY.

     CALL METHOD CL_SALV_TABLE=>FACTORY
        IMPORTING
          R_SALV_TABLE   = ref_salv
        CHANGING
          T_TABLE        = t_final.

    CATCH CX_SALV_MSG .
    ENDTRY.

*Display the final updated table
    ref_salv->display( ).

    leave to screen 0.

    endif.

  endif.

  endif.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

The last result in the wake of consolidating this activity will look something like beneath.

The client will alter something in the ALV yield (I have changed the ‘Material’ as WL-test and DG-test).

After change hit the ‘SAVE’ button and see the changed tuples in last ALV.

So… What Is Your Take?

Presently we need to hear from you.

What is your take of this technique? Do you have a superior methodology?

YOU MAY BE INTERESTED IN

Introduction to SAP ABAP for HANA

Future of ABAP on Cloud

ABAP Evolution: From Monolithic Masterpieces to Agile Architects

Create and Consume Business Add-in(BAdI) in ABAP

SAP

OOPs Report Using Splitter and ALV Tree Combination

Let’s dive into OOPs Report Using Splitter and ALV Tree Combination. For one client necessity, we needed to construct a report with splitter compartments alongside tree structure. The mix of these two could sound troublesome however, these are very simple to deal with. Quickly, we constructed a model and it worked impeccably.

Albeit the plan of the underneath made sense of model can be improved in various folds, essential skeleton for programming ought to continue as before. As we were obliging our advancement we discovered a few very much examined subjects over the web which I have attempted to tweak and address through this article.

Objective: OOPs Report Using Splitter and ALV Tree Combination

The goal of this article is to clear up how for utilize SPLITTER Compartment and TREE MODEL (TREE_STRUCTURE) in Uh oh ABAP report age coordinating standard occasions.

Also, the second and more significant goal is to destroy our apprehension about utilizing Tree Models and Splitter Compartments, for the last time.

Scope

This article covers the arrangements of the accompanying normal issues experienced by designers

  • Full screen use of custom holder when it is splitted into additional sub-compartments.
  • Enlisting custom occasions with standard occasions of tree model
  • Width customization of splitter compartments.

Overview

The accompanying code has been composed to show a report which has 2 compartments in the rundown screen. The left board compartment has been intended to hold the tree model and the right compartment is to show the subtleties of the left board record upon an occasion of double tapping. In this model a tree structure has been made with deals orders which have deal as a first record. These business orders can be chosen by giving specific determination screen models. After tapping on the leaf hub framework will show subtleties of the deals request in the right holder as an ALV design (if it’s not too much trouble, allude fig. 1).

Tree ALV

fig. – 1

Program Construct

Step – I: Declare all required structures and tables
Step –II: Declare reference of various classes
Step – III: Definition of event class
Step – IV: Implementation of Event Class
Step – V:  Selection Screen
Step – VI: Subroutine to fetch basic data for tree model
Step – VII: Screen Design
Step – VIII: Module for object creation of various classes. (In PBO of output screen)
Step – IX: Module for event registration. (In PBO of output Screen)
Step – X: Module for output processing. (In PBO of output Screen)

You can also read for:- A Deep Dive into the SAP API Hub

Step-I: Declare all required structures and tables

Tables: vbak,vbap,vbfa.

*&---------------------------------------------------------------------*
*&            Structures and Table Declarations
*&---------------------------------------------------------------------*
Data: ls_vbak type vbak,
lt_vbak type table of vbak,
ls_vbap type vbap,
lt_vbap type table of vbap.

Types: begin of ty_vbfa,
vbelv type vbfa-vbelv, "Preceding SD Document
posnv type vbfa-posnv, "Preceding SD Document Item Number
vbeln type vbfa-vbeln, "Subsequent SD Document
posnn type vbfa-posnn, "Subsequent SD Document Item Number
vbtyp_n type vbfa-vbtyp_n, "Subsequent Document Category
vbtyp_v type vbfa-vbtyp_v, "Preceding Document Category
end of ty_vbfa.

Data: ls_vbfa type ty_vbfa,
lt_vbfa type table of ty_vbfa.

Data: ls_vbfa_copy type ty_vbfa,
lt_vbfa_copy type table of ty_vbfa.

Types: begin of ty_vbak,
vbeln type vbak-vbeln,  "Contract Number
audat type vbak-audat,  "Document Date
ernam type vbak-ernam,  "Name of Person who Created the Object
auart type vbak-auart,  "Sales Document Type
end of ty_vbak.

Data: ls_vbak_cont type ty_vbak,
lt_vbak_cont type table of ty_vbak.

Step –II: Declare reference of various classes

*&---------------------------------------------------------------------*
*&            Type Reference of Various Classes
*&---------------------------------------------------------------------*
Data: ref_split type ref to cl_gui_splitter_container,
ref_cust  type ref to cl_gui_custom_container,
ref_alv1  type ref to cl_gui_alv_grid,
ref_alv2  type ref to cl_gui_alv_grid,
ref_cont1 type ref to cl_gui_container,
ref_cont2 type ref to cl_gui_container.
Data: ref_tree  type ref to cl_simple_tree_model.

Step – III: Definition of event class

*&---------------------------------------------------------------------*
*&                       Event Class
*&---------------------------------------------------------------------*
class lcl_event_handler definition.
public section.
methods: node_dc for event node_double_click of cl_simple_tree_model
importing node_key sender.
endclass.

Step – IV: Implementation of Event Class

class lcl_event_handler implementation.
method: node_dc.

Data: lt_children type tm_nodekey,
v_so        type vbeln,
v_item      type posnr.

Data: ls_layout type lvc_s_layo.
* 'sender' is an implicit event parameter that is provided by
* ABAP Objects runtime system. It contains a reference to the
* object that fired the event. You may directly use it to
* call methods of this instance.

CALL METHOD SENDER->NODE_GET_LAST_CHILD
EXPORTING
NODE_KEY       = node_key
IMPORTING
CHILD_NODE_KEY = lt_children.

* ‘Level_count’ in expand_node method determines in which level of the tree
* we want the double_click method to be triggered.

if lt_children is not initial.
CALL METHOD SENDER->EXPAND_NODE
EXPORTING
NODE_KEY            = node_key
LEVEL_COUNT         = 2.
endif.

split node_key at space into v_so v_item.

refresh: lt_vbap.

select * from vbap
into table lt_vbap
where vbeln = v_so.

if sy-subrc = 0.

ls_layout-grid_title = text-002.
ls_layout-zebra      = 'X'.
ls_layout-smalltitle = ''.
ls_layout-cwidth_opt = 'X'.

CALL METHOD REF_ALV2->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_STRUCTURE_NAME              = 'VBAP'
IS_LAYOUT                     = ls_layout
CHANGING
IT_OUTTAB                     = lt_vbap.

CALL METHOD REF_ALV2->REFRESH_TABLE_DISPLAY.

endif.

endmethod.
endclass.

Step – V:  Selection Screen

*&---------------------------------------------------------------------*
*&                   Selection Screen
*&---------------------------------------------------------------------*
selection-screen: begin of block b1 with frame title text-001.
select-options: s_vbeln for vbak-vbeln, "Document Number
s_audat for vbak-audat, "Document Date
s_ernam for vbak-ernam. "Name who Created the Object
selection-screen: end of block b1.

Step – VI: Subroutine to fetch basic data for tree model

*&---------------------------------------------------------------------*
*&                   Start Of Selection
*&---------------------------------------------------------------------*
start-of-selection.
perform Get_Data.

*&---------------------------------------------------------------------*
*&      Form  GET_DATA
*&---------------------------------------------------------------------*
*       Get All the display relevant Data for Tree Structure
*----------------------------------------------------------------------*
FORM GET_DATA .

select vbeln audat ernam auart
from vbak
into table lt_vbak_cont
where vbeln in s_vbeln and
audat in s_audat and
ernam in s_ernam.

if sy-subrc <> 0.
message E001(ZMSG) with 'No Record Found' display like 'I'.
elseif sy-subrc = 0.

select vbelv posnv vbeln posnn vbtyp_n vbtyp_v
from vbfa
into table lt_vbfa
for all entries in lt_vbak_cont
where vbelv = lt_vbak_cont-vbeln and
vbtyp_n = 'C' and
vbtyp_v = 'G'.

if lt_vbfa is initial.
message E002(ZMSG) with 'No Subsequent Record Found' display like 'I'.
else.
select * from vbak
into table lt_vbak
for all entries in lt_vbfa
where vbeln = lt_vbfa-vbeln.

select * from vbap
into table lt_vbap
for all entries in lt_vbak
where vbeln = lt_vbak-vbeln.

endif.
endif.
ENDFORM.

Step – VII: Screen Design

call screen 0100.
Splitter Container

*The holder ought to be drawn as extensive as could be expected. Likewise, the Lines/segments in the qualities tab of the screen painter are to be loaded up with the worth 240 to get the full-screen splitter compartment.

OOPs ALV Report

Step – VIII: Module for object creation of various classes. (In PBO of output screen)

Create one module in the flow logic of the screen.

*&---------------------------------------------------------------------*
*&      Module  OBJECT_CREATION  OUTPUT
*&---------------------------------------------------------------------*
*       Object Creation for Classes
*----------------------------------------------------------------------*
MODULE OBJECT_CREATION OUTPUT.

CREATE OBJECT REF_CUST
EXPORTING
CONTAINER_NAME    = 'SPLIT_CONT'.

CREATE OBJECT REF_SPLIT
EXPORTING
PARENT            = ref_cust
ROWS              = 1
COLUMNS           = 2.

CALL METHOD REF_SPLIT->GET_CONTAINER
EXPORTING
ROW       = 1
COLUMN    = 1
RECEIVING
CONTAINER = ref_cont1.

* The width of the splitter container can be adjusted with the SET_COLUMN_WIDTH method. Pass the width as required.

CALL METHOD REF_SPLIT->SET_COLUMN_WIDTH
EXPORTING
ID                = 1
WIDTH             = 22.

CALL METHOD REF_SPLIT->GET_CONTAINER
EXPORTING
ROW       = 1
COLUMN    = 2
RECEIVING
CONTAINER = ref_cont2.

CREATE OBJECT REF_TREE
EXPORTING
NODE_SELECTION_MODE   = cl_simple_tree_model=>node_sel_mode_single.

CALL METHOD REF_TREE->CREATE_TREE_CONTROL
EXPORTING
PARENT                = ref_cont1.

CREATE OBJECT REF_ALV2
EXPORTING
I_PARENT  = ref_cont2.

ENDMODULE.                 " OBJECT_CREATION  OUTPUT

Step – IX: Module for event registration. (In PBO of output Screen)

ALV Tree
*&---------------------------------------------------------------------*
*&      Module  EVENT_REGISTRATION  OUTPUT
*&---------------------------------------------------------------------*
*       Double Click Event Registration

*§4a. Frontend registration(i):  get already registered tree events.
*................................................................
* The following four tree events registers ALV Tree in the constructor
* method itself.
*    - cl_gui_column_tree=>eventid_expand_no_children
* (needed to load data to frontend when a user expands a node)
*    - cl_gui_column_tree=>eventid_header_context_men_req
* (needed for header context menu)
*    - cl_gui_column_tree=>eventid_header_click
* (allows selection of columns (only when item selection activated))
*   - cl_gui_column_tree=>eventid_item_keypress
* (needed for F1-Help (only when item selection activated))
*
* Nevertheless you have to provide their IDs again if you register
* additional events with SET_REGISTERED_EVENTS (see below).
* To do so, call first method  GET_REGISTERED_EVENTS (this way,
* all already registered events remain registered, even your own):

* (If you do not these events will be deregistered!!!).
* You do not have to register events of the toolbar again.
*----------------------------------------------------------------------*
MODULE EVENT_REGISTRATION OUTPUT.
Data: lt_events type cntl_simple_events,
ls_event type cntl_simple_event.

Data: event_handler type ref to lcl_event_handler.

CALL METHOD REF_TREE->GET_REGISTERED_EVENTS
IMPORTING
EVENTS = lt_events.

ls_event-eventid = cl_simple_tree_model=>eventid_node_double_click.
append ls_event to lt_events.

CALL METHOD REF_TREE->SET_REGISTERED_EVENTS
EXPORTING
EVENTS                    = lt_events.

create object event_handler.
set handler event_handler->node_dc for ref_tree.

ENDMODULE.                 " EVENT_REGISTRATION  OUTPUT

Step – X: Module for output processing. (In PBO of output Screen)

OOPs ALV for Hierarchy Tree
*&---------------------------------------------------------------------*
*&      Module  PROCESSING_OUTPUT  OUTPUT
*&---------------------------------------------------------------------*
*       Processing Output of the Table
*----------------------------------------------------------------------*
MODULE PROCESSING_OUTPUT OUTPUT.

Data: ls_node type treemsnodt.

CALL METHOD REF_TREE->ADD_NODE
EXPORTING
NODE_KEY                = 'ROOT'
ISFOLDER                = 'X'
TEXT                    = 'Orders'
EXPANDER                = 'X'.

loop at lt_vbak into ls_vbak.

ls_node-node_key = ls_vbak-vbeln.

concatenate 'Sales Order#' ':' ls_vbak-vbeln
into ls_node-text
separated by space.

CALL METHOD REF_TREE->ADD_NODE
EXPORTING
NODE_KEY                = ls_node-node_key
RELATIVE_NODE_KEY       = 'ROOT'
RELATIONSHIP            = cl_simple_tree_model=>relat_last_child
ISFOLDER                = 'X'
TEXT                    = ls_node-text
EXPANDER                = 'X'.

endloop.

loop at lt_vbap into ls_vbap.

concatenate ls_vbap-vbeln ls_vbap-posnr
into ls_node-node_key
separated by space.

ls_node-relatkey = ls_vbap-vbeln.

concatenate ls_vbap-posnr ls_vbap-matnr
into ls_node-text
separated by space.

CALL METHOD REF_TREE->ADD_NODE
EXPORTING
NODE_KEY                = ls_node-node_key
RELATIVE_NODE_KEY       = ls_node-relatkey
RELATIONSHIP            = cl_simple_tree_model=>relat_last_child
ISFOLDER                = ''
TEXT                    = ls_node-text
EXPANDER                = ''.

endloop.
ENDMODULE.                 " PROCESSING_OUTPUT  OUTPUT

Duplicate or allude the inserted code however change the plan. I would prefer to propose foster the whole report with the assistance of nearby class or possibly apply some modularization ideas. I utilized different PBO modules which are a major ‘no’ for any continuous articles.

Tree designs should likewise be possible in numerous alternate ways. A lot of reports is accessible over the web. I picked the least difficult approach to doing that(ironically the class name is “cl_simple_tree_model”). Splitter holders are all around investigated yet barely utilized except if we have such unambiguous prerequisites. Nonetheless, this report is only “Old wine in another container”. Trust this annihilates our restraint of utilizing Splitter Compartments and Tree Models on a similar call and meet the second level headed of this instructional exercise.

At the point when you are done with your new development, the eventual outcome of your steady exertion should look something like underneath.

OOPs ABAP Tutorial
Selection Screen
Output List Screen
Expanded List
On Double-Click Event

We put a great deal of exertion in conceptualizing, testing and composing every single article. In the event that you could pass this connect to no less than 5 partners/companions who you think would profit from our post, it would be an extraordinary blessing to our group. We believe our articles should reach to whatever number crowds as could be allowed so everybody would benefit and our group would stay spurred and our work doesn’t lose all sense of direction in this colossal expanse of the web.

YOU MAY LIKE THIS

Cracking the Code: Your Earning Potential as a SAP ABAP Developer with 5 Years of Experience

A Comprehensive Guide to SAP ABAP Training Online

SAP LUW in ABAP Cloud

SAP ABAP Interview Questions Real time Expectations

SAP

Future of APIs in SAP: Gazing into the Crystal Ball

The world of SAP APIs is constantly evolving, driven by innovation and the ever-growing need for seamless data exchange in a hybrid IT landscape. In this, the final part of our blog series, we delve into the exciting Future of APIs in SAP, exploring emerging trends, the role of APIs in the cloud, and the importance of developing your API skillset.

You can also read for: how sap api works ?

As we look towards the future, several key trends are poised to shape the landscape of SAP API development and integration:

  • API Gateways: These intelligent gateways will act as central hubs for managing API traffic, enforcing security policies, and providing valuable analytics on API usage. Think of them as sophisticated airport terminals for your APIs, ensuring smooth and secure data flow.
  • Serverless Computing: The rise of serverless architectures will allow developers to focus on building API functionalities without worrying about server infrastructure management. This frees up valuable resources and empowers faster development cycles.
  • AI and Machine Learning (AI/ML): The integration of AI/ML with APIs will unlock a new level of automation and intelligence. Imagine APIs that can learn user behavior and preferences, personalizing data delivery and optimizing API performance.
  • Microservices Architecture: The popularity of microservices architectures, where applications are built as small, independent services, will further increase the demand for APIs as the communication channels between these services.

Embracing the Cloud: The Role of APIs in S/4HANA Cloud

The future of SAP is undoubtedly cloud-based, with S/4HANA Cloud leading the charge. APIs play a vital role in this cloud-centric world by enabling seamless integration between S/4HANA Cloud and other applications, both within and outside the SAP ecosystem. This fosters a more agile and extensible enterprise application landscape.

  • Pre-built APIs: S/4HANA Cloud offers a rich library of pre-built APIs that cater to various functionalities, streamlining the integration process for developers.
  • API Management as a Service (APIaaS): Cloud-based API management platforms will simplify API development, deployment, and governance within S/4HANA Cloud environments.
  • Event-Driven Architecture: APIs will play a crucial role in event-driven architectures, where applications react to real-time events, enabling a more dynamic and responsive business environment.

Future-Proofing Your Career: The Importance of API Skills

As the reliance on APIs in SAP continues to grow, developing your API skillset becomes increasingly important for future-proofing your career in the SAP world. Here are some ways to stay ahead of the curve:

  • Learn about API Design Principles: Understanding best practices for designing secure, well-documented, and user-friendly APIs is crucial.
  • Master API Development Tools: Familiarize yourself with SAP’s API development tools, such as the SAP Cloud Platform API Management service and the SAP API Business Hub.
  • Explore Integration Technologies: Gain knowledge of integration technologies like OData and SOAP, which form the backbone of SAP API communication.
  • Stay Updated with the Latest Trends: Continuously learn about emerging trends in the API landscape, such as serverless computing and AI/ML integration with APIs.

Resources for Staying Ahead of the Curve

Here are some valuable resources to help you stay updated on the latest advancements and best practices in SAP APIs:

  • SAP API Hub: This central repository provides access to a wealth of information on SAP APIs, including documentation, tutorials, and best practices. 
  • SAP Community: Engage with other SAP developers and experts in the SAP Community to discuss API-related topics and learn from their experiences. 
  • SAP Learning Hub: Explore online courses and learning resources offered by SAP to enhance your API development skills.

The future of SAP APIs is brimming with exciting possibilities. By embracing emerging trends, understanding the role of APIs in the cloud, and actively developing your API skillset, you can ensure you’re well-positioned to thrive in the ever-evolving world of SAP technology. So, dive into the world of SAP APIs, and unlock a future filled with innovation, agility, and seamless data integration!

you may be interested in this blog here:-

SAP API Hub

What is SAP?

What Does an SAP Developer Do?

SAP

SAP API Landscape

Mastering the Maze: Managing Your SAP API Landscape (Part 5)

Congratulations! You’ve conquered the foundational knowledge of SAP APIs, explored their various types and use cases, and even delved into the practicalities of consuming and developing them. But the journey doesn’t end there. Just like a bustling city, your SAP API landscape requires careful management to ensure its smooth operation and continued value.

In this final part of our SAP API series, we’ll equip you with the knowledge to effectively manage your API landscape. We’ll explore strategies for monitoring usage, establishing governance practices, prioritizing security, and utilizing valuable tools for streamlined API management.

Keeping a Pulse on Your APIs: Usage Monitoring and Performance Analysis

Just like any critical business function, your SAP APIs deserve close monitoring. Here’s how to ensure they’re performing optimally:

  • Track API Usage: Implement tools that track the frequency of API calls, user access patterns, and overall API utilization. This data helps identify popular APIs, potential bottlenecks, and areas for optimization.
  • Monitor API Performance: Measure response times, identify slow-performing APIs, and pinpoint potential performance issues. This proactive approach ensures your APIs remain responsive and deliver a seamless user experience.
  • Analyze API Errors: Track and analyze errors encountered during API calls. This can reveal integration issues, data inconsistencies, or faulty logic within the APIs themselves.

By implementing these monitoring practices, you can gain valuable insights into your API landscape’s health, identify areas for improvement, and proactively address potential issues before they disrupt business operations.

Governing Your APIs: Establishing Lifecycle Management Practices

Effective governance is paramount for a well-managed SAP API landscape. Here are some key practices to establish:

  • API Versioning: As APIs evolve, implement a versioning strategy to maintain compatibility with existing integrations while introducing new functionalities.
  • Deprecation Management: Clearly define a process for deprecating outdated APIs. This ensures developers are aware of upcoming changes and can plan their integrations accordingly.
  • Standardization and Documentation: Establish clear standards for API design, development, and documentation. This promotes consistency, simplifies maintenance, and ensures everyone is on the same page.
  • Access Controls and Security: Implement robust access control mechanisms to restrict access to specific APIs based on user roles and permissions.

By establishing these governance practices, you can ensure the order, control, and predictability needed for a healthy and sustainable SAP API landscape.

Security First: Prioritizing API Security Throughout the Lifecycle

The security of your SAP APIs is non-negotiable. Here’s how to prioritize security throughout the entire API lifecycle:

  • Threat Modeling: Identify potential security threats and vulnerabilities associated with your APIs. This proactive approach helps you mitigate risks before they can be exploited.
  • Authentication and Authorization: Implement robust authentication mechanisms to verify user identities and authorization controls to restrict access to authorized users only.
  • Data Encryption: Encrypt sensitive data transmitted through APIs to safeguard it from unauthorized access or interception.
  • API Gateway Security: Utilize an API Gateway that enforces security policies, monitors API traffic for suspicious activity, and provides additional layers of protection.

By adhering to these security best practices, you can build a strong defense against cyberattacks and ensure the confidentiality, integrity, and availability of your valuable SAP data.

Tools and Technologies: Your SAP API Management Arsenal

Fortunately, you don’t have to navigate the complexities of API management alone. Here are some valuable tools and platforms to consider:

  • SAP Cloud Application Programming Model (CAPM): A robust platform for building and managing APIs in the SAP Cloud environment.
  • SAP API Management (SAP APIM): A comprehensive solution for designing, securing, publishing, and monitoring APIs across both on-premise and cloud environments.
  • Third-Party API Management Tools: Several third-party API management tools integrate seamlessly with SAP, offering additional functionalities and features.

By leveraging these tools and platforms, you can streamline API development, governance, and monitoring processes, allowing you to focus on the strategic utilization of your SAP APIs to drive business value.

Conclusion: A Landscape Under Control

Managing your SAP API landscape effectively requires a multi-pronged approach. By implementing the strategies and practices outlined in this blog, you can ensure your APIs are monitored, governed, and secured effectively. Additionally, utilizing the available tools and platforms empowers you to streamline API management tasks and maximize the potential of your SAP API ecosystem.

Remember, a well-managed SAP API landscape fosters innovation, streamlines integrations, and unlocks a world of possibilities for your business. So, take control, implement these valuable practices, and watch your SAP APIs become the driving force behind agility, efficiency, and a competitive edge in the ever-evolving digital landscape.

you may be interested in this blog here:-

Customer 360 in Salesforce: A Holistic Approach

Spark Joyful Learning Engaging English Worksheet For UKG Class

Introduction SAP FLORI

SAP

Consuming APIs in SAP Applications

External Power: Consuming APIs in SAP Applications (Part 4)

The previous parts of this blog series have demystified APIs in SAP, explored their various types, and unveiled their potential benefits. Now, it’s time to delve into the practical aspects – consuming third-party APIs in SAP applications. This empowers you to integrate with external systems, unlock a world of data, and orchestrate complex workflows.

Bridging the Gap: Tools and Libraries for API Consumption

Consuming APIs in SAP applications doesn’t require reinventing the wheel. Here are some powerful tools and libraries that streamline the process:

  • ABAP Connectivity Framework (ICF): This built-in framework within SAP NetWeaver provides classes and functionalities specifically designed for sending HTTP requests and receiving responses. Ideal for developers familiar with ABAP programming.
  • SAP Cloud Platform – Integration Services: For cloud-based integrations, SAP Cloud Platform offers a robust suite of tools. Leverage services like “API Business Hub” to discover and manage APIs, and “SAP Cloud Connector” to securely connect to on-premise systems.
  • External Libraries: The world of open-source libraries offers a wealth of options for API consumption in SAP. Popular choices include libraries like “RestEasy” (Java) or “Requests” (Python), which can be integrated with SAP Cloud Platform applications.

Crafting the Code: Sending Requests and Handling Responses

Once you’ve chosen your tools, here’s a basic structure for consuming an API within your SAP application:

  1. API Discovery and Definition: Carefully analyze the API documentation to understand its endpoints, authentication methods, request parameters, and response formats.
  2. Building the Request: Use the chosen library or framework to construct the HTTP request message. Specify the API endpoint URL, HTTP method (GET, POST, etc.), headers (including authentication tokens if required), and any request body data.
  3. Sending the Request: Trigger the request using the appropriate library functions, initiating communication with the external API.
  4. Handling the Response: Parse the response received from the API. This might involve converting JSON or XML data into usable structures within your SAP application.
  5. Processing the Data: Extract the relevant information from the API response and utilize it within your application logic. This could involve updating SAP data models, triggering workflows, or displaying data to users.

Remember: Security is paramount! Always adhere to best practices for secure API access, such as using HTTPS and implementing proper authentication mechanisms.

Building Integration Symphonies: Combining Data from Multiple Sources

The true power of API consumption lies in its ability to orchestrate complex integrations. Here’s how you can combine data from various APIs and internal SAP data sources:

  • Data Mapping and Transformation: Utilize tools within your chosen integration platform (like SAP Cloud Platform Integration Services) to map data from different sources into a unified format, ensuring seamless integration within your SAP application logic.
  • Orchestration Workflows: Design workflows that call upon multiple APIs in a specific sequence, potentially combining data from internal SAP tables and external APIs to achieve a desired outcome.
  • Error Handling and Exception Management: Robust error handling mechanisms are crucial. Implement logic to handle potential API failures, timeouts, or unexpected responses, ensuring the overall integration process remains resilient.

You can also read for:-how sap api works ?

Beyond Simple Requests: Exploring Advanced Integration Patterns

For truly sophisticated integrations, consider these advanced patterns:

  • Message Queues: Implement message queues as a buffer between your SAP application and external APIs. This decouples the systems, allowing them to communicate asynchronously and improving overall scalability.
  • Real-time Event Processing: For scenarios requiring immediate action based on external events, leverage real-time event processing tools. These tools can react to data changes in real-time, triggering workflows or updates within your SAP system.

By mastering these techniques, you can transform your SAP applications into powerful integration hubs, seamlessly exchanging data with external systems and unlocking a new level of functionality and efficiency within your organization.

Conclusion: The API Advantage – A World of Opportunity Awaits

Consuming APIs in SAP applications opens a gateway to a world of possibilities. By leveraging the tools, libraries, and integration patterns discussed in this blog, you can craft robust and scalable integrations that empower your SAP applications to interact with external systems, exchange data seamlessly, and automate complex workflows. Embrace the power of API consumption and transform your SAP landscape into a truly connected and intelligent ecosystem.

This concludes our in-depth exploration of APIs in SAP applications. We hope this series has equipped you with the knowledge and tools to embark on your API integration journey. Stay tuned for further explorations into the ever-evolving world of SAP and its integration capabilities!

You may be also like this:

What is SAP Fiori?

SAP’s Travel Manager

Common eLearning Testing Challenges and How to Overcome Them

SAP

Building APIs with SAP Tools and Technologies

Part 1 and 2 of this blog series unveiled the magic of APIs in SAP, exploring their role in system integration and the diverse landscape of SAP API types. Now, it’s time to step into the developer’s shoes and delve into the exciting world of building custom APIs with SAP tools and technologies.

SAP Tools: Essential API Development

SAP offers a robust ecosystem of tools and frameworks to empower you to craft APIs that seamlessly connect your SAP system with various applications. Here are some of the most popular choices:

  • SAP Cloud Platform API Management (SAP CP API Management): This comprehensive suite provides a one-stop shop for designing, developing, securing, publishing, and monitoring your APIs. It simplifies the entire API lifecycle, allowing you to build robust and scalable APIs in the cloud.
  • ABAP Web Services: For developers familiar with the ABAP programming language, ABAP Web Services offer a powerful way to expose SAP data and functionalities as SOAP APIs. This approach leverages the existing ABAP infrastructure within your SAP system.
  • SAP Leonardo and SAP HANA Cloud Platform: These cutting-edge platforms provide innovative tools for building and deploying microservices-based APIs. They cater to a more modern development approach, leveraging cloud-native technologies for greater agility and scalability.

The choice of tool often depends on factors like your specific needs, existing infrastructure, and developer skillset. No matter which tool you choose, SAP offers extensive documentation, tutorials, and training resources to guide you through the development process.

Building Your First API: A Step-by-Step Guide

Let’s embark on a practical journey by building a simple RESTful API in SAP using SAP Cloud Platform API Management. Here’s a basic roadmap:

  1. API Design: Define the purpose of your API, the data it will expose, and the functionalities it will offer. Plan the API endpoints (URLs) and the data format (like JSON) for request and response messages.
  2. Development: Use the SAP CP API Management console to create your API definition. Specify the endpoints, data models, and authentication mechanisms. Code the backend logic to interact with your SAP system using tools like ABAP or external libraries, depending on your chosen approach.
  3. Testing: Rigorously test your API using tools like Postman to simulate API calls and validate responses. Ensure your API functions as intended and handles various scenarios, including error conditions.
  4. Deployment and Monitoring: Publish your API through SAP CP API Management, making it accessible to authorized consumers. Monitor API usage and performance metrics to identify potential issues and optimize your API for efficiency.

Remember: This is a simplified overview. The development process can involve additional steps depending on the complexity of your API and the chosen tool.

Securing Your Gates: API Authentication and Authorization

Since APIs act as gateways to your SAP data, security is paramount. Here’s how to safeguard your API:

  • Authentication: Implement mechanisms like API keys, OAuth, or basic authentication to verify the identity of users or applications trying to access your API.
  • Authorization: Define access control rules to determine which users or applications have permission to perform specific actions on your API (e.g., read, write, update data).

SAP Cloud Platform API Management offers robust security features to help you implement these mechanisms and protect your valuable SAP data.

Building Well-Designed APIs: Best Practices for Success

While building your API, consider these best practices for optimal functionality and user experience:

  • Versioning: Implement API versioning to manage changes to your API over time, ensuring compatibility with existing consumers.
  • Documentation: Provide clear and comprehensive API documentation that explains how to use your API, including endpoint details, request/response formats, and error codes.
  • Error Handling: Design your API to handle errors gracefully, providing informative error messages to developers consuming your API.

By following these best practices, you can create well-designed, secure, and user-friendly APIs that empower seamless integration within your SAP ecosystem.

Conclusion: Empowering Innovation with Custom SAP APIs

Building custom APIs with SAP tools opens a world of possibilities for integration and innovation. You can unlock valuable SAP data for external applications, extend SAP functionalities to mobile devices, or even create entirely new business models through API-driven solutions.

As you embark on your SAP API development journey, remember that the tools and technologies discussed in this blog series are your companions. Leverage them effectively, prioritize security, and embrace best practices to craft exceptional APIs that bridge the gap between your SAP system and the ever-evolving world of applications.

So, unleash your inner developer, explore the potential of SAP API.

you may be interested in this blog here:-

Mastering the Fundamentals: A Beginner’s Guide to Java Coding Basics, Syntax, and Terminology (2024 Edition)

Guarding Data Integrity: Mastering Field-Level Access Control in Salesforce

The Quest for Knowledge: A Journey to Find the Perfect Tuition Classes

How to Navigate the Different Sub-Modules in SAP Finance

× How can I help you?