Skip to Content
Author's profile photo Vikram chavan

Tips and Tricks for SAP EC Calculations

Attaching the tips and tricks for SAP EC calculation.

Topics covered are

1.    Strings
Operations

 

2.    Date
operation

Thanks and Regards,

Vikram Chavan

Tips and Tricks for
Calculations:
 
Applies to:
EC SP 15
Summary:
This article covers tips and tricks which can be used in EC
calculations.
Author: Vikram Chavan.
Company: Igate Corporation.
Created on: 22nd Oct 2013.
Author Bio:
Vikram Chavan is working as ABAP/EC technical consultant in Igate
Corporation and has More than 9 years of experience in SAP ABAP and EC.

Table of Contents

  1. Strings Operations. 3
  2. 1.1         Concatenate strings. 3
  3. 1.2         Concatenate strings with
    numerical variable. 3
  4. 1.3         Concatenate with New line. 3
  5. Date operation. 3
  6. 2.1         Difference between two dates. 3
  7. 2.2         Get start date of the period
    and previous years date. 3
  8. 2.3         To get month, day or year. 4
  9. 2.4       Shift
    the period to last year. 4

1.     Strings Operations

1.1           Concatenate strings

lv_ fstname
=  “Mr Sam”;

    
lv_lstname = “Buck”;

    
lv_fullname  = Lv_ fstname  + “ “ + Lv_lstname;

Result: lv_fullname will have value “Mr Sam
Buck”.

1.2           Concatenate strings with numerical variable

lv_ fstname
=  “Mr Sam”;

    
lv_lstname = “Buck”;

lv_age =
“Age”;

lv_ageno
= 35;

lv_str  =  lv_
fstname  + ” “ +  lv_lstname
+ ”,  “ +  lv_age
+  “  “  +
lv_ageno  ;

Result : lv_str will have value “Mr Sam
Buck,  Age 35”.

1.3           Concatenate with New line

lv_str = “Hello
World”.

lv_str1 = “First
Code”.

Lv_str = “Hello
World” +  “\nFirst Code”.

Result: Hello World

             First Code. 

2.     Date
operation

2.1           Difference between two dates.

lv_date1 =
#2005.12.05 00:00:00#

      lv_date2
= #2005.12.01 00:00:00#.

lv_numdays  =  LV_DATE1  –
LV_DATE2;

         Result: Lv_numdays = 4.

2.2           Get start date of the period and previous years
date

Example:

Consumption C has a start date
5/10/2011 11:00:00 (that is, May, 10th, 11 a.m.).

            CalculateTimePeriod(C,”YEARS”,1,”PREVOUS”)

returns: ([1/1/2010
12:00:00],[31/12/2010 11:59:59])

CalculateTimePeriod(C,”YEARS”,1,”FROM_TODAY”)

returns: ([5/10/2010
11:00:00],[5/10/2011 10:59:59])

2.3           To get month, day or year

FROMDATE = C.from;

Result:

j =
FROMDATE.month  ;

p =
FROMDATE.day  ;

k =
FROMDATE.year  ;

2.4        Shift the period to last year

  1. fromDate.year = fromDate.year – 1;
  2. fromDate.hour = 12;
  3. fromDate.minute = 00;
  4. fromDate.second = 00;
  5. toDate.year = toDate.year – 1;
  6. toDate.hour = 11;
  7. toDate.minute = 59;
  8. toDate.second = 59;

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.