Quantcast
Channel: SCN : All Content - SAP BusinessObjects Design Studio
Viewing all articles
Browse latest Browse all 4216

Design Studio SDK: Simple Date Object Component

$
0
0

Purpose

Date-based navigation (roll days, months) in BIAL script directly, format days to own formats.

 

Show Case

You can use this component like this:

 

var today = APPLICATION.getInfo().dateNowInternalFormat;
DATEOBJECT_1.initializeWithInternalDate(today);
DATEOBJECT_1.rollWeeks(-4); // go back by 4 weeks
var calendarWeek = DATEOBJECT_1.getCalendarWeek();
var dateFormatted = DATEOBJECT_1.format("DD.WW.YYYY"); // -> results in eg. 01.08.2012


Background

Solution for date-based navigation in Filters, eg. get the current date and set the filter on data source by DATE - 4 weeks. Or get the current calendar week from todays day, and get the calendar week which was 2 weeks before. This component contains only some logic in the BIAL script (no rendering).

 

Technical Solution

I have long searched for some option to make this running in BIAL script. The current solution is probably not the best, but this was the only one I can offer for 1.3 release. It is based on "pre-generated JSON values for concrete days.

 

Secont "problem" was that SDK is always sending all properties to the client, therefore I hold only the "oneDay" property as this is small, I need to clean up always the "days" property as this is holding a huge array of days. Seems to work correctly - the array will never be send to client.

 

Available Properties

 

Property NameDescription
N/A

Currently no properties.

 

Scripting Functions

 

ScriptsShort Description

initialize(...)

initializeWithDate (...)

You can initialize the simple date object with any date from January 2009 to December 2019 by giving year, month, day

initializeWithInternalDate (...)

You can initialize by passing the internal date format "20140814" (8 characters). This is for direct passing of the "APPLICATION.getInfo().dateNowInternalFormat;" content.

rollDays(int)

rollWeeks(int)

rollMonths(int)

rollYears(int)

functions for rolling the date object. You can use NEGATIVE numbers to roll down.

get(...)

many getters (in this preview no documentation, but the names are self-explained)

format(Sting)

format method can be used for formatting of the date to some string (primitive format by replacing characters):

  • YYYY -> year (4 chars)
  • YY -> year (last 2 chars)
  • MM -> month (2 chars)
  • M -> month (1 char if < 10)
  • DD -> day ( chars)
  • D -> day (1 char if < 10)
  • WW -> calendar week (2 chars)
  • W -> calendar week (1 char if < 10)
  • Q -> quarters
internal_*some internal methods, do not use directly

 

Example Application

An Application with example can be downloaded at the BIAPP Repository:

 

In this example all methods are shown behind the buttons, try it out!

 

Current Restrictions

  • currently, in BIAL scripts only restricted functional scope is possible, therefore the dates are as "big array" (but performance seems to be ok)
  • restricted to navigation between 31st December 2004 and 1st January 2020 - this shoudl be ok for normal use

 

Releases

 

Source Code & Licensing

This component is for free use. It is under the Open Source Apache Version 2.0 License.

 

Important MaintenanceNotice (... as I am SAP Employee)

The component is NOT delivered under SAP maintenance license.

You cannot claim any Support on this component from SAP!


The components are created on "private" basis - you can use them as is. I can modify (in compatible way), correct or improve - but there is no obligation to do it. Of course I will try to correct bugs or improve the component as long I can.

 

Q&A

Feel free to add any comments or ideas which can go into future versions, or feel free to take a copy and add extensions on your own.


Viewing all articles
Browse latest Browse all 4216

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>