Posts

Showing posts from March, 2022

Window Expressions in ABAP SQL -Open SQL Enhancement ABAP on HANA - Part 14

Image
*&---------------------------------------------------------------------* *& Report zr_opensql_23_widow_expression *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zr_opensql_23_widow_expression. SELECT  FROM vbak  FIELDS vbeln AS so,         kunnr AS cust_id,         waerk AS curre,         netwr AS net_amt,         SUM( netwr ) OVER(                          PARTITION BY kunnr                          ORDER BY netwr *ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW * ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING  ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING                       ...

Host Expression in where -Open SQL Enhancement ABAP on HANA - Part 8

Image
*&---------------------------------------------------------------------* *& Report zr_opensql_16_host_expre_where *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zr_opensql_16_host_expre_where. CLASS demo DEFINITION.   PUBLIC SECTION.     CLASS-METHODS class_constructor.     CLASS-METHODS main.   PRIVATE SECTION.     CLASS-DATA: it_scarr TYPE STANDARD TABLE OF scarr. ENDCLASS. CLASS demo IMPLEMENTATION.   METHOD class_constructor.     SELECT *      FROM scarr      INTO TABLE @it_scarr.   ENDMETHOD.   METHOD main.     DATA : lv_carrame TYPE scarr-carrname VALUE 'American Airlines'.     cl_demo_input=>request(       CHANGING         field       =  lv_carrame     ).    ...

Client Handling - Open SQL Enhancement ABAP on HANA - Part 9

Image
*&---------------------------------------------------------------------* *& Report zr_opensql_15_client_handlin_t *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zr_opensql_15_client_handlin_t. CLASS demo DEFINITION.   PUBLIC SECTION.     CLASS-METHODS main. ENDCLASS. CLASS demo IMPLEMENTATION.   METHOD main.     SELECT      FROM vbak AS so      INNER JOIN vbap AS item      ON  so~mandt = item~mandt      AND so~vbeln = item~vbeln      CLIENT SPECIFIED      FIELDS so~vbeln, so~vkorg, so~vkgrp,             item~posnr, item~matnr      WHERE so~mandt = '800'      INTO TABLE @DATA(it_result)      .     IF sy-subrc IS INITIAL.       cl_demo_outpu...

Group by in detail - Open SQL Enhancement ABAP on HANA - Part 11

Image
*&---------------------------------------------------------------------* *& Report zr_opensql_20_unioon_grp_by *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zr_opensql_20_unioon_grp_by. *Use case only n select list *Use case in select list and grp by *Chaining operator *demo_sql_expr_with_group_by SELECT  FROM vbak AS so  INNER JOIN kna1 AS cust  ON so~kunnr = cust~kunnr  FIELDS so~kunnr AS cust_id,         cust~name1 AS customer,         so~waerk AS curre,         SUM( so~netwr ) AS tot_netprice, *        AVG( so~netwr ) AS net, *        MAX( so~netwr ) AS max, *        MIN( so~netwr  ) AS min,         COUNT( so~netwr ) AS count,       CASE          WHEN so...

Cross and Right outer join - Open SQL Enhancement ABAP on HANA - Part 10

Image
*&---------------------------------------------------------------------* *& Report zr_opensql_14_join_t *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zr_opensql_14_join_t. CLASS demo DEFINITION.   PUBLIC SECTION.     CLASS-METHODS main. ENDCLASS. CLASS demo IMPLEMENTATION.   METHOD main.     SELECT      FROM vbak AS so      RIGHT OUTER JOIN kna1 AS cust      ON so~kunnr = cust~kunnr      FIELDS cust~kunnr,             so~vbeln,             so~netwr      INTO TABLE @DATA(it_result).     IF sy-subrc IS INITIAL.       cl_demo_output=>write( it_result  ).     ENDIF.     TYPES: BEGIN OF helper_type.     TYPES   clnt TYPE t000-mand...

Inline declaration in SAP ABAP 7.4 /7.5 ( Program and Package creation i...

Image
*&---------------------------------------------------------------------* *& Report z_inline_declaration_program *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT z_inline_declaration_program. CLASS lcl_main DEFINITION.   PUBLIC SECTION.     TYPES: BEGIN OF ty_helper_type,              vbeln TYPE vbak-vbeln,              vkorg TYPE vbak-vkorg,              vkgrp TYPE vbak-vkgrp,            END OF ty_helper_type.     CLASS-METHODS: main       EXPORTING         ls_vbak TYPE ty_helper_type. ENDCLASS. CLASS lcl_main IMPLEMENTATION.   METHOD main. *  data: lv_lines TYPE i.     SELECT      FROM vbak      FIELDS vbeln,vkorg,vkgrp ...

SAP Enhancement Framework ( Implicit and Explicit enhancements ) ( Enhan...

Image
*&---------------------------------------------------------------------* REPORT zr_hello_world_yu. DATA lv_string TYPE string. DATA lv_name TYPE sy-uname. lv_name = cl_abap_syst=>get_user_name( ). ENHANCEMENT-POINT Z_ENH_POINT_RAM SPOTS Z_ENH_SPOT_RAM . ENHANCEMENT-SECTION Z_ENH_SECTION_RAM SPOTS Z_ENH_SPOT_RAM . lv_string = |hello { lv_name }, Welcome to the abap development for sap hana!|. END-ENHANCEMENT-SECTION. WRITE: lv_string.

Kernel BADI in ECLIPSE ADT Part - 2 ( Kernel BADI Implementation )

Image
CLASS zcl_imp1_kernal_badi DEFINITION   PUBLIC   FINAL   CREATE PUBLIC .   PUBLIC SECTION.     INTERFACES if_badi_interface .     INTERFACES zif_sales_order_info .   PROTECTED SECTION.   PRIVATE SECTION. ENDCLASS. CLASS zcl_imp1_kernal_badi IMPLEMENTATION.   METHOD zif_sales_order_info~modify_header.     LOOP AT it_vbak ASSIGNING FIELD-SYMBOL(<ls_vbak>).        <ls_vbak>-zzdate = sy-datum + 1.        <ls_vbak>-zzusername = 'Krishna'.     ENDLOOP.   ENDMETHOD. ENDCLASS. ********************************************** CLASS zcl_imp2_badi DEFINITION   PUBLIC   FINAL   CREATE PUBLIC .   PUBLIC SECTION.     INTERFACES if_badi_interface .     INTERFACES zif_sales_order_info .   PROTECTED SECTION.   PRIVATE SECTION. ENDCLASS. CLASS zcl_imp2_badi IMPLEMENTATION.   METHOD zif_sales_order_info~modify_header....

Kernel BADI in ECLIPSE ADT (ABAP development tool for eclipse)

Image
REPORT z_kernel_badi_example. DATA: lv_vbeln TYPE vbeln. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.   SELECT-OPTIONS:s_vbeln FOR lv_vbeln.   PARAMETERS:           p_vkorg TYPE vkorg . SELECTION-SCREEN END OF BLOCK b1. START-OF-SELECTION.   DATA : it_vbak TYPE STANDARD TABLE OF vbak,          lr_badi TYPE REF TO z_sales_order_badi.   SELECT *    FROM vbak    INTO TABLE @it_vbak    WHERE vbeln IN @s_vbeln    and   vkorg = @p_vkorg.   IF sy-subrc IS INITIAL.     GET BADI lr_badi FILTERS sales_org_filter = p_vkorg.     CALL BADI lr_badi->modify_header       CHANGING         it_vbak = it_vbak.     cl_salv_table=>factory(       IMPORTING         r_salv_table   = DATA(lr_alv)       CHANGING         ...

COALESCE function in Select - Open SQL Enhancement ABAP on HANA - Part 7

Image
REPORT zr_opensql_11_coalesce_t. SELECT  FROM vbak AS so  LEFT OUTER JOIN vbfa AS flow  ON flow~vbelv = so~vbeln  AND flow~vbtyp_v = 'C'  AND flow~vbtyp_n = 'M'  LEFT OUTER JOIN vbrk AS inv   ON inv~vbeln = flow~vbeln   FIELDS so~vbeln AS sales_order,          so~netwr AS so_amount,          inv~netwr AS inv_amount,          CASE WHEN inv~netwr IS NOT NULL  THEN  inv~netwr          ELSE so~netwr          END AS amount_net,          COALESCE( inv~netwr , so~netwr ) as amount_co   INTO TABLE @DATA(it_result). IF sy-subrc IS INITIAL.   cl_demo_output=>display( it_result ). ENDIF.

Literals in select field list - Open SQL Enhancement ABAP on HANA - Part 2

Image