Saturday, 2 September 2023

ALV IDA Using CDS View Long Text using (Calculation Field)

Mostly people facing problem to how to use long text using function module, Call class in CDS while creating ALV IDA from CDS View. In this blog I will share my knowledge of ALV IDA Using CDS View and ALV IDA Calculation field (Mostly is used for virial element). Using Calculation Field in this blog I am going to display Long Text and Other Field

In this blog I will focus on below points.

1. Create CDS View (Generic) with 2 or 3 fields.
2. Create class with interface calculation field.
3. Long Text working in method
4. Creation of ALV IDA Program

Let’s begin with our learning.

Create CDS View (Generic) with 2 or 3 fields.


Mostly of people aware of to create a CDS View. That’s why I am creating as generic.

◉ Create Data Definition

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

◉ Select Data Definition and then Select Finish.

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

Write your query and then Activate.

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

Create class with interface calculation field.


SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

Long Text working in method


◉ Double click on IF_SALV_IDA_CALC_FIELD_HANDLER~CALCULATE_LINE

Program code is given below.

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

Code Example


REPORT ZALV_IDA_DEMO_LONG_TEXT.

"Data Declataion for ALV IDA and Class handler
DATA: LO_ADDITIONAL_CONDITION TYPE REF TO IF_SALV_IDA_CONDITION,
      LO_CONDITION_FACTORY    TYPE REF TO IF_SALV_IDA_CONDITION_FACTORY,
      LS_PERSISTENCE_KEY      TYPE IF_SALV_GUI_LAYOUT_PERSISTENCE=>YS_PERSISTENCE_KEY,
      LR_DISP                 TYPE REF TO IF_SALV_GUI_TABLE_DISPLAY_OPT.
*      LO_CALC_FLD             TYPE REF TO ZCL_LONGTEXT.


DATA(LO_CALC_FLD) = NEW ZCL_LONGTEXT( ). 

*Create 'ALV with IDA' for Core Data Services(CDS)
DATA(O_DATA) = CL_SALV_GUI_TABLE_IDA=>CREATE_FOR_CDS_VIEW(
  IV_CDS_VIEW_NAME      = 'ZPURCHASE_ORDER_CDS'
  IO_CALC_FIELD_HANDLER = LO_CALC_FLD
).

*For Layout this is must be user coz it will enable layout button
DATA(L_GLOBAL_SAVE_ALLOWED) = ABAP_TRUE.
DATA(L_USER_SPECIFIC_SAVE_ALLOWED) = ABAP_TRUE.
LS_PERSISTENCE_KEY-REPORT_NAME = SY-REPID.
O_DATA->LAYOUT_PERSISTENCE( )->SET_PERSISTENCE_OPTIONS(
EXPORTING
  IS_PERSISTENCE_KEY           = LS_PERSISTENCE_KEY
  I_GLOBAL_SAVE_ALLOWED        = L_GLOBAL_SAVE_ALLOWED
  I_USER_SPECIFIC_SAVE_ALLOWED = L_USER_SPECIFIC_SAVE_ALLOWED
).

*Display ALV IDA
O_DATA->FULLSCREEN( )->DISPLAY( ).

SAP ABAP, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Tutorial and Materials

Note: Before creating ALV IDA must sure below note is implemented or already implemented. This is for save global layout.

No comments:

Post a Comment