Posts

Showing posts from April, 2024

Select query new syntax in ABAP(7.4+).

Image
 * The separator between the columns is , .  *  ABAP data objects used in open SQL statements are called as host variables and they  are prefixed with @ . Report  REPORT  zab_rp_select_query_new . TABLES :   mara . TYPES :   BEGIN  OF  ls_mara ,          matnr  TYPE  mara - matnr ,          mtart  TYPE  mara - mtart ,          mbrsh  TYPE  mara - mbrsh ,          matkl  TYPE  mara - matkl ,          meins  TYPE  mara - meins ,         END  OF  ls_mara . DATA :   lt_mara  TYPE  TABLE  OF  ls_mara . SELECT-OPTIONS :   s_matnr  FOR  mara - matnr . SELECT  matnr mtart mbr...

New Keyword in SAP ABAP (7.4+).

Image
* Before ABAP 7.4, we used CREATE OBJECT statement to create an object of the class. * From ABAP 7.4 onwards, SAP introduced the NEW keyword. * This NEW keyword is used to create an object of the class. Report      REPORT  zab_rp_new .      PARAMETERS :   p_input1  TYPE  i ,                 p_input2  TYPE  i .      CLASS   a  DEFINITION .        PUBLIC  SECTION .          METHODS  sum  IMPORTING   pval1   TYPE  i                               pval2   TYPE  i                      ...

Alpha statement using function module in SAP ABAP (7.4+).

Image
                                           Refer-   Alpha without function module  *  CONVERSION_EXIT_ALPHA_INPUT is used to add the leading zero's.  * CONVERSION _EXIT_ALPHA_OUTPUT is used to remove the leading zero's. Report      REPORT  zab_rp_alpha_fm .      DATA :   lv_var1 ( 10 )  TYPE  c  VALUE  '12345' ,           lv_var2 ( 10 )  TYPE  c  VALUE  '0000012345' .      CALL  FUNCTION  ' CONVERSION_EXIT_ALPHA_INPUT '        EXPORTING          input   =  lv_var1        IMPORTING          output  =  lv_var1 .      WRITE :  ...

Switch statement in ABAP ( 7.4+)

Image
                 First Refer * -   Introduction to case and switch   Report      REPORT  zab_rp_switch .      PARAMETERS :  p_day  TYPE  i .      DATA ( lv_output )  =  SWITCH char40 (   p_day   WHEN   1   THEN   TEXT - 000                                         WHEN  2   THEN  TEXT - 001                                         WHEN  3   THEN  TEXT - 002         ...

Use switch statement instead of case statement. (7.4+).

Image
Switch statement.          *  From ABAP 7.4 onwards, SAP introduced SWITCH statement.     *  We need to use SWITCH statement instead of CASE statement.     *  In CASE statement, we need to specify the variable which is getting filled in every condition.     *  In SWITCH statement, we need not to mention the variable which is getting filled in every condition.  CASE (Old).          REPORT  zab_rp_switch .      PARAMETERS :  p_day  TYPE  i .      DATA :  lv_output ( 15 )  TYPE  c .      CASE  p_day .        WHEN  1 .         lv_output  =  TEXT - 000 .    " SUNDAY.        WHEN  2 .         lv_output  =  TEXT - 001 ....