jueves, 26 de julio de 2018

Power BI connector to BW (BEx queries), version 2.0 - First Impressions

Introduction

In June-2018 Microsoft released the connector for SAP BW version 2.0. You can read about the announcement here. 

 As you can see there one of the new features is:
"Ability to retrieve several million rows of data, and fine-tuning through the batch size parameter."

I decided to give it a try.

Keep in mind that SAP says: "Bex queries are not made for mass data extraction." as stated on SAP note: 1968598 - Mass data in Bex queries Options and Workarounds.
 
Also, note that you may need to fine-tune some memory parameters in your application server to avoid memory problems, which at some point will anyways occur since BEx queries are not meant for mass data extraction.
 

The configuration 

The source system

SAP BW/4 HANA SP5 deployed from CAL.SAP.COM to Google cloud platform. The dataset consists of 2.4 million records, with one characteristic or dimension that is a unique ID.

This unique ID it is generated by ABAP code in the transformation and is the key of the DSO. This happens in real life scenarios, having a dimension with millions of different values, examples are billing document numbers, accounting document numbers, etc.

I loaded the data to two targets, both advanced DSOs, one where the unique key (the dimension with 14 million different values) was an info object (which means SID generation) and another where the unique key was a HANA field (no SID generation).

On top of those advanced DSOs, I created queries, and Power BI connects to those queries.

The data I loaded is from here.

The Target

I was using Power BI Desktop 64-bits 2.59.5135.781 64-bit (June 2018)

Note: Since this new connector is in BETA, I did not test it using the Power BI gateway, which is a must (in most cases) for production use.

The first parameter tested - Batch Size

 

Image 1 - The new connector screen, showing all available parameters (highlighted in the Batch size parameter)

There is not much documentation by Microsoft about execution mode, but in transaction MDXTEST if you press "Execute..." you can find the same parameters, and from there you can do some research.

Image 2 - Correlation between PowerBI parameters and MDXTEST parameters


My intuition for this parameter was a follow:
For a smaller batch size, more RFC calls, and less memory consumption, for bigger batch size, fewer RFC calls, and more memory consumption.

With batch size 50.000

Each batch was around 50k records, which is just a coincidence. Depending on the width of your dataset this can vary.
Here is a short video (30 seconds) where you can see the load:

And here is a screenshot from transaction ST04:

In 1 we can see the memory consumption, in 3 (R=30) we can see that there have been 30 RFC calls (30 x 5000 = 1 500 000 records at the moment of the screenshot).


With batch size 100 

Each batch was around 600 records. Here is a short video (30 seconds) where you can see the load:
 And here is a screenshot from transaction ST04:
n 1 we can see the memory consumption strangely same as in the previous case, in 3 (R=925) we can see that there have been 30 RFC calls (925 x 600 = 555000 records at the moment of the screenshot).

This load was noticeably slower.

With batch size 1 000 000

With this batch size, the load ended with an out of memory (TSV_TNEW_PAGE_ALLOC_FAILED) error in BW.
You can see the video here:


This load was noticeable faster but did not finish successfully.

Conclusion 

Start with a small batch size and increment, to get better performance. You will know it's too big when it fails. Always experiment in a SandBox system, never in production!

This parameter is a great addition to the connector!

In a new blog I will test the other parameters!

Appendix A 

The memory parameters of the application server (Screenshot from ST02)















martes, 12 de diciembre de 2017

SAP can help you learn NodeJS,Angular and Microservices thanks to YAAS.io!

Another year is almost gone, and everybody is getting ready for the holidays, which usually means traveling. Having to wait in airports and stations is the perfect excuse for getting a book. In my case, I decide to get this book Manning | Node.js in Action, Second Edition.

If you are not into technical books, here is a list of great books (by Bill Gates) with deeper topics.

As with any development platform, one of the first questions one expects to answer is how to organise your code; for small developments this is trivial, but for medium to big developments, this can be a decisive factor in the quality and speed of development.

The book and the offi cial NodeJS documentation has clear ideas of how you should organise your code using modules. But if you are a newbie to NodeJS (like myself) maybe bigger and more complex examples will help you digest the concept.

It would also be helpful to see a microservice-driven implementation in real life, and better still with a fancy Angular front end.

Go to www.yaas.io! YaaS is a microservices ecosystem helping businesses to rapidly expand and build new, highly flexible solutions, and it is powered by SAP Hybris.

With this commands:

git clone https://github.com/SAP/yaas-storefront.git
cd yaas-storefront/
node install

You can get the source code of a full blown NodeJS applications based on microservices that uses Angular. 

You can have this application running in under 10 minutes, and easily enhance it.

For more details check SAP documentation: https://www.sap.com/developer/tutorials/yaas-download-run-default-storefront.html and other recommended reads:

YaaS Bites: First Steps

YaaS Bites: The essentials


Happy holidays!

miércoles, 9 de agosto de 2017

Solving a simple linear regression using TensorFlow

On 2014 I blogged about how Google is currently leading big data and machine learning world. Since then, they have been busy and one of their latest creations is TensorFlow.

Using SAP products has paid for my salary for the last 15 years, and when I learned that SAP is using Google's TensorFlow, I thought I should start learning more about it and see what the fuzz is all about.

In this blog post, I will be talking about:
  • Linear regression
  • Machine Learning
  • Programming languages
  • TensorFlow
You have been warned!

Let's start with a simple linear regression problem. We have the following table that contains the age and the weight of a certain animal.

Age
Weight
1
2,00
2
3,10
3
4,15
4
5,40
6
7,00

Using linear regression, I want to find an equation where I can input a new value of age, for example, 7 and it will predict the corresponding weight.

Using the explanation from this article, the equation for linear regression is: y = a + bx. And the equations for a and b are:



In our case, x is the age and y is the weight. Applying the above formulas, a = 1,09324324324324 and  b = 1,01148648648649.

Applying the linear regression formula on the original data, it predicts the following results:

Age (x)
Weight (y)
Predicted weight (y)
1
2,00
2,10472972972973
2
3,10
3,11621621621621
3
4,15
4,1277027027027
4
5,40
5,13918918918919
6
7,00
7,16216216216216
7

8,17364864864865

For the age of 7, the predicted weight will be 8,17.

Now let's do the same using TensorFlow.

The instructions to install and configure TensorFlow can be found here.

The code in TensorFlow looks like this:

import numpy as np
import tensorflow as tf

# Model parametersb = tf.Variable([.3], dtype=tf.float32)
a = tf.Variable([-.3], dtype=tf.float32)

# Model input and outputx = tf.placeholder(tf.float32)
linear_model = a + b * x
y = tf.placeholder(tf.float32)

# lossloss = tf.reduce_sum(tf.square(linear_model - y)) # sum of the squares# optimizeroptimizer = tf.train.GradientDescentOptimizer(0.01)
train = optimizer.minimize(loss)

# training datax_train = [1,2,3,4,6]
y_train = [2,3.10,4.15,5.40,7]

# training loopinit = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init) # reset values to wrong
for i in range(1000):
  sess.run(train, {x:x_train, y:y_train})

# evaluate training accuracycurr_W, curr_b, curr_loss = sess.run([a, b, loss], {x:x_train, y:y_train})
print("a: %s b: %s loss: %s"%(curr_W, curr_b, curr_loss))

And the output is:
a: [ 1.09324002] b: [ 1.01148736] loss: 0.106047

The same values as in the manual calculation.

Now I will go through the main parts of the code.

In these lines, we pass the original data, in machine learning terminology, this is called "training the model":

x_train = [1,2,3,4,6]
y_train = [2,3.10,4.15,5.40,7]

In these lines we run the model:

sess = tf.Session()
sess.run(init) 
for i in range(1000):
  sess.run(train, {x:x_train, y:y_train})

If you need more details about getting started with TensorFlow try this link: https://www.tensorflow.org/get_started/get_started


My next blog post will be about loading data from a SAP BW source to TensorFlow. In the meantime go ahead and experiment with TensorFlow.


Cheers!


sábado, 14 de enero de 2017

4 metas de seguridad digital que puedes implementar este 2017

¡Hola!

Solo 14 días han pasado desde que comenzó el 2017 y ya dos amigos míos han sido víctimas de accesos no autorizados a sus cuentas en linea: una amiga, a su cuenta de Facebook y el otro, a su cuenta de Skype.

Aunque nunca hayas pensado en tu seguridad digital o tal vez, ya lleves un tiempo pensando en tomar ciertas acciones; este comienzo de año es las excusa perfecta para hacerlo.

El pensar en tomar acciones para protegerte puede parecer abrumador y llevarte a abandonar el intento. No hay dudas que tomar las riendas de tu seguridad te va a generar trabajo extra; por eso voy a intentar mostrarte algunas medidas que exigen poco de esfuerzo pero generan mucho valor, el equivalente a "en vez de dejar tu bicicleta simplemente apoyada contra un árbol, asegurarla".

Estos son mis consejos:

Activen la autenticación de 2 pasos, también conocidos como aprobaciones de inicio de sesión

Esta medida que usualmente requiere que ingreses tu password y además, ciertos códigos que son enviados o generados en tu teléfono, te protege en el caso de que tu password sea obtenido por terceras personas.

No todos los servicios ofrecen esta opción, pero la mayoría lo hace, aunque los nombres pueden cambiar. Por ejemplo, en Twitter se llama "Verificación de inicio de sesión", y en Facebook es "Autorización de inicio de sesión".

Estos servicios no generan molestias en el día a día porque tienes la opción de marcar tus dispositivos personales (teléfono, PC) como confiables, y pare estos no necesitarás el código adicional. Claro que se pueden volver un poco molestos cuando estas apurado en iniciar sesión en un dispositivo que nunca antes has usado, o estas en un lugar donde no hay señal para recibir los códigos.

Aquí las instrucciones para los sitios más usados, te recomiendo comenzar por los sitios que tienen tu información financiera, por ejemplo Amazon:

Amazon -> ver aquí.    Facebook -> ver aquí.  Gmail -> ver aquí. 

Usen un administrador de contraseñas

Todos tenemos un montón de cuentas en línea, y la idea de catalogarlas, cambiar las contraseñas de manera regular, usar contraseñas distintas para cada una de ellas, es enloquecedora. Precisamente por eso es que necesitas un administrador de contraseñas. Lo interesante de usar un administrador de contraseñas es que, una vez haya pasado por el proceso de alimentarlo hará tu vida más simple. No tendrás, nunca más, que pasar por el proceso de "olvidé mi contraseña" cada  vez que quieras acceder un servicio que no accedes con frecuencia o sentarte a pensar qué poner como contraseña.

Aquí hay una lista de los mejores administrador de contraseñas pagos, y también existen algunos gratuitos.

Después de instalado, añade tus cuentas más usadas, y veras que en un par de semanas, con el uso regular de las otras cuentas, estas se añadirán automáticamente cada vez que inicies sesión.

Los administradores de contraseñas no son perfectos. Estos centralizan todos tus datos, y es posible que las compañías que los proveen sean infiltradas. Ya ha ocurrido antes.

Al menos que estés dispuesto a invertir mucho de tu tiempo en una estrategia, elaborada por ti mismo, para administrar tus contraseñas, los administradores de contraseñas son una manera viable de tener tus contraseñas bajo control. ¡Haz que el 2017 sea el año en que comenzaste a usar un administrador de contraseñas!

Realicen copias de seguridad periódicamente

Puedes hacer tus copias de seguridad en dispositivos externos (discos duros externos, flashs, etc.), o en servicios en la nube, o en ambos.

Las herramientas que aconsejo más abajo cifran tus datos antes de moverlos a los dispositivos externos o a la nube. Esto es muy importante en caso de que roben tu dispositivo externo, o el servicio en la nube se vea comprometido. Dado que tu información esta cifrada, no podrán verla.

Los servicios CrashPlan and Backblaze son algunas de mis recomendaciones. CrashPlan realiza tus copias de seguridad automáticamente a dispositivos externos y a la nube.

Aprendan a usar una VPN

Cuando estas conectado al internet, la VPN crea un canal de comunicación seguro entre tu dispositivo y un servidor seguro, para evitar el espionaje de la información en los lugares que visitas en internet. El uso de una VPN son casi obligatorio si sos alguien que se conecta a redes WiFi públicas. Una advertencia: el uso de una VPN reduce la velocidad de tu internet.

Uno de mis servicios de VPN favoritos es Freedome.


Haz que la seguridad digital no sea parte de tu ya extensa lista de preocupaciones diarias y sigue estos simples cuatro consejos.