ABAP SQL Indicator

Generally speaking, an indicator is a one-byte character field that is either set on (‘1’) or off (‘0’). Indicators are like switches which normally used to indicate the result or to control the processing of an operation.

ABAP SQL: Indicator Structures

As a rule, marker is a one-byte character field that is either set on (‘1’) or off (‘0’). Pointers resemble switches which regularly used to show the outcome or to control the handling of an activity. You can utilize a pointer structure as an ABAP SQL marker addressing an invalid marker in ABAP SQL read or as a set pointer in compose explanations. In read articulations, the pointers can store data while in compose explanations, markers can be utilized to check segments for change. The parts of the invalid marker demonstrate which sections of the outcome set contain the invalid worth to show a vague worth or result and which don’t. The pointer structure is made similarly for every information kind of a first-level part of construction. This intends that, for instance, every foundation or each reference variable is reflected similarly as a marker part is reflected as a rudimentary part of construction.

How to utilize ABAP SQL pointer structure?
The fundamental reason for a pointer structure is to act as an ABAP SQL marker. As said, the expansion WITH Markers works with the meaning of invalid pointers or set pointers for ABAP SQL proclamations. This is particularly significant for the UPDATE explanation with the expansion Pointers since no inline statements can be utilized there. For ABAP SQL pointers, just the sorts c and x of length 1 are applicable.


TYPES dtype TYPE struct WITH Pointers ind.

Here we drive an organized information type with a marker structure called ind. For struct, a current nearby or worldwide organized type should be indicated. For ind, a name should be determined that follows the naming shows.

This variation of the assertion TYPES characterizes an organized information type that has similar parts as the organized sort struct determined behind TYPE, as well as an extra last part named ind as a marker structure. The last part ind is a base that contains similar number of first-level parts as struct, in a similar request as in struct and with similar names as in struct. The standard information kind of every part is x of length 1 and can be characterized expressly with the discretionary expansion TYPE.

Update a data set table to some degree utilizing set markers
The expansion Signs of the UPDATE FROM provision can be utilized to determine set markers for a workspace or an inside table. The reason for set pointers is to show segments to be changed. The parts of a set marker demonstrate the sections of a DDIC information base table to be changed utilizing the UPDATE explanation.

UPDATE FROM without markers overwrites all fields of a column yet when set pointers are utilized, just the showed fields are refreshed.


… Pointers {[NOT] SET Design set_ind}

| (indicator_syntax) …

This expansion can be determined solely after UPDATE FROM for organized workspaces wa or inside tables itab with an organized line type. The source workspace or inward table priority a construction set_ind as last field with similar number of parts as the DDIC information base table to be refreshed, and every part fills in as set marker for one column. All singular parts of set_ind should have either the information type c and length 1, or the information type x and length 1. The UPDATE FROM statement actually looks at the substance of set_ind and refreshes just fields that are set apart with ‘X’ (information type c) or ‘1’ (information type x). Fields that contain some other person or digit are not refreshed. Key fields should continuously be remembered for the marker structure. Nonetheless, the set markers affect key fields.

While utilizing the expansion Pointers NOT SET, the opposite rationale is applied: all fields are refreshed, aside from the ones set apart with ‘X’ (information type c) or ‘1’ (information type x).

Model
An inside table that has a line structure with a marker structure, is halfway loaded up with the flight information for a given flight association from the DDIC data set table SFLIGHT. In the inward table, the cost is decreased by 80 %. The changed table is utilized to refresh the separate date in the data set table. While the lines that are to be refreshed are chosen by the substance of key fields in the inner table, the section to be refreshed is shown by denoting the segment Cost of the pointer structure. In the event that you don’t utilize the Pointers expansion of the UPDATE explanation, any remaining non-key sections of the data set table would be introduced since their qualities are starting in the interior table.

TYPES wa TYPE sflight WITH INDICATORS ind.

DATA itab TYPE TABLE OF wa WITH EMPTY KEY.

SELECT carrid, connid, fldate, price
       FROM sflight
       WHERE carrid = char`LH` AND
             connid = numc`0400` AND
             fldate > '20180601'
       INTO CORRESPONDING FIELDS OF TABLE @itab.

IF sy-subrc  = 0.

  LOOP AT itab ASSIGNING FIELD-SYMBOL(<wa>).
    <wa>-price *= '0.8'.
    <wa>-ind-price = '01'.
  ENDLOOP.

  UPDATE sflight FROM TABLE @itab INDICATORS SET STRUCTURE ind.

ENDIF.

Below, sflight table for Lufthansa flights in 2018 with flight connection number of 0400 is shown:

If you use the UPDATE statement without INDICATORS, all those non selected fields of the database table SFLIGHT will be initialized as well. In other words, the values of those fields which are not selected from the database table SFLIGHT, remains initial in your internal table as it is shown below:

With the addition of “INDICATORS SET STRUCTURE ind” in UPDATE statement as follow:

UPDATE sflight FROM TABLE @itab INDICATORS SET STRUCTURE ind.

only the “Price” field will get updated. Then, all other fields in the database table won’t be affected and remain untouched as it can be seen:

So, one can say that the INDICATORS structure acts as a flag to update the selected fields.

INTO Proviso and the Idea of Invalid Marker
The expansion Signs of the INTO condition can likewise be utilized to determine markers. It is as of now conceivable to determine an invalid pointer that stores data about which segments of the outcome set contain the invalid worth and which don’t. An invalid worth is an exceptional worth returned by a data set to demonstrate an indistinct worth or result. Invalid qualities relate to no satisfied of information objects in ABAP and has a preferable presentation over Combine. Particularly, an invalid worth isn’t equivalent to a kind ward starting worth.

Language structure
… Pointers [NOT] Invalid Design null_ind

This Determines the base null_ind of an organized objective region determined in the INTO condition as an invalid marker after a predefined existing workspace wa or existing inward table itab, this should contain a foundation with the name null_ind as a part. The foundation should contain to some extent however many parts as the quantity of sections in the outcome set characterized utilizing the SELECT rundown. These may likewise be parts of different bases. Every part should be of type x or c with length 1. The position and name of the base should be characterized so that it isn’t impacted by the task of information from the outcome set for the question.

The option Pointers after an inline statement with @DATA(wa) or @DATA(itab) adds a foundation with the name null_ind to the furthest limit of the design or line structure pronounced inline. For every section in the outcome set, this foundation contains an indistinguishably named part of type x and length 1 in a similar request. Assuming going before parts of the design proclaimed inline are foundations, the base null_ind is likewise organized as needs be. The name null_ind should not be utilized as the name of a segment in the outcome set. It is prescribed to give the parts of the invalid pointer similar name as the sections of the outcome set.

On the off chance that the discretionary expansion NOT is determined, the part esteem hexadecimal 1 for type x and “X” for type c imply that the relating section doesn’t contain the invalid worth. For segments that contain the invalid worth, the related parts are instated.

Model
The third section of the outcomes set of the SELECT assertion contains the invalid worth on the grounds that the WHEN state of the CASE articulation is bogus and no ELSE is indicated. In like manner, part z of base wa-null_ind contains the worth hexadecimal 1 true to form.

DELETE FROM demo_expressions.
INSERT demo_expressions FROM @( VALUE #( id = 'X' num1 = 1 ) ).

SELECT SINGLE
       FROM demo_expressions
       FIELDS
         num1 AS x,
         CASE WHEN num1 = 0 THEN 0 ELSE 1 END AS y,
         CASE WHEN num1 = 0 THEN 0 END AS z
       INTO @DATA(wa) INDICATORS NULL STRUCTURE null_ind.

cl_demo_output=>new(
  )->write( |{ wa-x } { wa-null_ind-x }|
  )->write( |{ wa-y } { wa-null_ind-y }|
  )->write( |{ wa-z } { wa-null_ind-z }|
  )->display( ).

So, the output would be:

1 00
1 00
0 01

More examples on dynamical specification of null indicators and their use cases in internal tables can be found in ABAP Keyword Documentation as well.FollowLikeRSS Feed

Conclusion

In conclusion, ABAP SQL indicators are indispensable tools for developers working with SAP applications. Their role in ensuring data accuracy, handling errors, and optimizing performance cannot be overstated.

FAQs

  1. What are the key advantages of using ABAP SQL indicators?
  2. How can developers handle null values effectively in ABAP SQL?
  3. What is the significance of indexing in ABAP SQL queries?
  4. Are there any tools available for debugging ABAP SQL code?
  5. How does ABAP SQL contribute to the overall efficiency of SAP applications?

  • Related Posts

    सबसे लोकप्रिय परियोजना प्रबंधन सॉफ्टवेयर कौन सा है? -2024

    सबसे लोकप्रिय परियोजना प्रबंधन सॉफ्टवेयर कौन सा है? -2024 व्यापार की तेज गति वाली दुनिया में, कुशल परियोजना प्रबंधन सफलता के लिए यह बहुत ज़रूरी है। सही Project. मैनेजमेंट सॉफ़्टवेयर चुनने से…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    Part 11 of Core Data Services: How Do I Use CDS View in the KPI Fiori Apps for Smart Business Services?

    • By Varad
    • October 4, 2024
    • 5 views
    Part 11 of Core Data Services: How Do I Use CDS View in the KPI Fiori Apps for Smart Business Services?

    SAP Fiori. Chapter 12: SAP Fiori Launchpad Tcode: Uses and Upkeep

    • By Varad
    • October 3, 2024
    • 4 views
    SAP Fiori. Chapter 12:  SAP Fiori Launchpad Tcode: Uses and Upkeep

    Step by Step Guide to Install SAP Web IDE Personal Edition

    • By Varad
    • October 2, 2024
    • 3 views
    Step by Step Guide to Install SAP Web IDE Personal Edition

    “A Strategic View of SAP Fiori: Insights from a Space Level Perspective”

    • By Varad
    • October 1, 2024
    • 6 views
    “A Strategic View of SAP Fiori: Insights from a Space Level Perspective”

    An Overview of SAP Fiori ABAP Programming Model – 1

    • By Varad
    • October 1, 2024
    • 6 views

    SAP Fiori ABAP Programming Model – 2 – CDS – Overview

    • By Varad
    • September 30, 2024
    • 5 views
    SAP Fiori ABAP Programming Model – 2 – CDS – Overview