martes, 30 de abril de 2024

[SQL] LISTAGG Function

Sometimes, I'm find needing go group data grouping by a line. For example, how get and export all user emails. Normally, we have 1-1 relation a database table, but we want export grouping un a unique line by user. I'm sure, we could export to a excel and pivot in a table, or with other tool. But, how to do it in SQL?

The solution lies in the LISTAGG function, which groups all rows results into a single colum.

The sintax is the next:

           
SELECT LISTAGG(column_name, delimiter) WITHIN GROUP (ORDER BY ordering_column)
FROM table_name

        

Consequently, in the previous example, we could achieve this with the following query:

SELECT EAAN8, ABALPH, LISTAGG(TRIM(EAEMAL), ',') WITHIN GROUP (ORDER BY EAEMAL) AS EMAILS FROM F01151 JOIN F0101 ON EAAN8=ABAN8 WHERE EAETP = 'E' GROUP BY EAAN8, ABALPH;

Return the nex ouptut:


In next posts we are looking how export in XML, JSON, etc. format.

Kind regards and good code!


[SQL] Función LISTAGG

 Hola JDEFriends,

En ocasiones me he encontrado con la necesidad de obtener datos agrupando en una línea. Por ejemplo, cómo obtener y exportar todos los emails de un usuario. Normalmente, para ello tenemos relación 1-1 en una tabla en base de datos, pero queremos exportar agrupado en una única línea por usuario. Seguramente podamos exportarlo a un excel y pivotarlo en una tabla o con otra herramienta ¿Cómo hacemos esto en SQL?

La solución está en la función LISTAGG, la cual agrupa en una única columna todos los resultados de las filas.

La sintaxis es la siguiente:

        
           
SELECT LISTAGG(column_name, delimiter) WITHIN GROUP (ORDER BY ordering_column)
FROM table_name

        

Por lo cual, en el ejemplo anterior podríamos realizarlo con la siguiente query:

SELECT EAAN8, ABALPH, LISTAGG(TRIM(EAEMAL), ',') WITHIN GROUP (ORDER BY EAEMAL) AS EMAILS FROM F01151 JOIN F0101 ON EAAN8=ABAN8 WHERE EAETP = 'E' GROUP BY EAAN8, ABALPH;

Con la siguiente salida:


En otro posts veremos cómo exportar en formato XML, JSON, etc.

Saludos y buen código!


viernes, 1 de abril de 2022

[JD Edwards - BSSV] Import external JAVA library (ENG)

Hi jde friends,

Sometimes, we find ourselves with need to extend JD Edwards functionalities and we find many functionalities in JAVA packages or libraries, JAVA is one of the most languages and platform used in technologies. For example, recently I worked in a project to implement Bidimensional code QR. So, what is the JDE solution?


Well, we use a JAVA library to facilitate the coding. In this case IdAutomation (that is license paid, but there are other as Google (Zxing) and many other open source, depending on each case and use). So, this provider provides a java library in witch it has a class and a method for facility implementation, that we pass the string to be encoded and it return as array string encoded. Later, to this array we put a font in BIPublisher and we already have our encoded QR code. Easy right?

Then, we generated our BSSV object (and we cannot forget our BSFN in C to communicate our report or application with BSSV component), with our class and main method. But, how import IdAutomation QR library to our JD Developer project?

1. On our project, we press the rigth button and in the context menu click on Project Properties:

2. Press in Librares and Classpath menu and next press button Add JAR Directory

3. Select the JAVA library (I recommend leaving in the JDE Path JDE system\Classes (later I explain the reason)

4. Press on Open button in the dialog, and it is added to the project:

5. Press OK and save the project. We can use library classes and method importing to our java class.

               boolean bestMask = true;           // Best pattern mask
               
               String resultQREncode = qre.FontEncode(dataToEncode, applyTilde, encodingMode, errorCorrectionLevel, version, bestMask);
               internalVO.setSzQREncodedData(resultQREncode);
               
               printMsg(context, "Encoded => ");
               printMsg(context, resultQREncode);

And we have everything ready in our project!!!

To deploy, we have to configure system to use a external library for when compiling and generating deploy package it imports the external library in jar jde deploy package. This configuration is done in deploy server (although I also configure it in my fat client).

1. Copy the library to system\Classes folder:

2. Modify the file sbffoundation.ini inside the same folder, in the section [Foundation] y and add a line "LIB" + "next sequence" + "=" + "library name"

And with this we already our BSSV project with an external library ready to deploy!

Pd: I have also used an external library for Datamatrix code, integrate with Webcenter Content through RIDC standard java package, and recently to create a proxy client webservice through an external library with java wsimport command to integrate with Salesforce that you can see here.

Good code JDE Friends!

sábado, 19 de febrero de 2022

[JD Edwards] Form Charts - ChartControl Component (ENG)

Hola jdedwerds,

I recently worked on a project where we needed to display KPI's of sales orders processed automatically, so beside showing the boring tables with the processed orders info and the percentage calculation in certain fields, I thought of adding a graph which is always more visually pleasing.

This time I have done it natively, it's true that we have had this tool for quite some time but I've rarely seen it used even in a standard apps - on the P41021 availability app and on some planning/production applications- and I don't understand why (it are not the most powerful charts for that there are other tools, but for simple cases use it should be enough)

It's true that we have other tools in the environment itself such as One View Reporting OVR or that KPI's are usuarlly analyzed in business with Business Intelligence BI tools, but why not give them a touch of color to our JDE applications??




The first thing to do is to insert a ChartControl in our form:



Then, in the event where we have the information to display (after reading each grid line, at the end of the grid, etc.) we create a variable to load the XML tags needed for the chart -in my case a foot chart-. Then, we load the information to the chart through the Set Data XML function available in the Chart Control Functions section of the System Functions. And finally, we perform the action to draw the chart with the Draw Chart function avaible in the same section previously seen:




Therefore, the code would like this:


The following chart types are available:

  • bar_basic
  • bar_basic_percent
  • cluster_bar_basic
  • combo_basic
  • line_basic
  • pie_basic
  • pie_ontime
  • stacked_bar_basic
  • stacked_bar_ontime

We can perform visualization tests of graphs and examples created in our installation on our web server with the resource http://<webhost>:<webport>/jde/GraphPrototype.maf




For more oficial information in the next link: https://support.oracle.com/epmos/faces/DocumentDisplay?id=648865.1

The next thing I want to integrate are external charts from Google Charts, through a TextBlock and with the API's provided by Google. I'll try to make a POC, soon.

I hope you found it interesting and useful.

Best regards.

Alfredo.

viernes, 18 de febrero de 2022

[JD Edwards] Gráficos Formularios - Componente ChartControl (ESP)

Hola jdedwerds,

Recientemente trabajé en un proyecto donde necesitaba mostrar unos KPI's de pedidos de ventas procesados automáticamente, por lo que aparte de mostrar las aburridas tablas con la info de pedidos procesados y el cálculo del porcentaje en ciertos campos, se me ocurrió añadir una gráfica que siempre resulta más agradable visualmente. 

Ésta vez lo hice de manera nativa, es cierto que tenemos desde hace bastante tiempo ésta herramienta pero pocas veces la he visto ser utilizada incluso de manera estándar -en pantalla disponibilidad P41021 y en algunas de planificación/producción- y no entiendo el motivo (no son las gráficas más potentes para eso existen otras herramientas, pero para un uso y casos sencillos debería ser suficiente).. 

Es cierto que disponemos de otras herramientas en el propio entorno como One View Reporting OVR o que normalmente los KPI's se analizan en negocio con herramientas de Business Intelligence BI, pero por qué no darles un toque de color a nuestras pantallas JDE??




Lo primero que debemos realizar es insertar un ChartControl en nuestro formulario:



A continuación en el evento donde dispongamos de la información para mostrar (después de leer cada línea, al finalizar el grid, etc.), lo que haremos será crear una variable para cargar las etiquetas XML necesarias para el gráfico -en mi caso un gráfico de pie-. Posteriormente, cargamos la información al gráfico a través de la función Set Data XML disponible en la sección Chart Control Functions de las System Functions. Y finalmente realizamos la acción para que se dibuje el gráfico con la función Draw Chart disponible en la misma sección anteriormente vista:




Por lo cual, el código quedaría tal que así:


Disponemos de los siguientes tipos de gráficos:

  • bar_basic
  • bar_basic_percent
  • cluster_bar_basic
  • combo_basic
  • line_basic
  • pie_basic
  • pie_ontime
  • stacked_bar_basic
  • stacked_bar_ontime

Podemos realizar pruebas de visualización de gráficas y ejemplos creados en nuestra instalación, en nuestro servidor web con el recurso http://<webhost>:<webport>/jde/GraphPrototype.maf




Para más información oficial en el siguiente enlace: https://support.oracle.com/epmos/faces/DocumentDisplay?id=648865.1

Lo siguiente que quiero integrar son gráficas externas de Google Charts, mediante un TextBlock y con las API's facilitadas por Google. Intentaré hacer una POC, próximamente.

Espero les haya resultado interesante y útil.

Un saludo,

Alfredo.

jueves, 9 de diciembre de 2021

[JD Edwards - BSSV] JD Edwards - Salesforce integration: Making proxy package JAVA with WSIMPORT tool

Hi friend,

Recently, I've done a JDE with Salesforce Cloud integration, through BSSV both inbound and outbound communication with Soap technology. Salesforce use Apex (Oracle Application Express) for integrations

Integración JDE - Salesforce



One of the main problems that I found was generate proxy client, the  Organization WSDL  has a lot of methods (this service is the principal , and it is used for all access related: login, logout, sessions, userinfo, etc), and besides that when trying to generate proxy client in JDeveloper 12c (12.2.1.3.0) it gave errors to namespaces conflicts.

So, I decided try alternate path, using JAVA wsimport tool, it tool from the file or IP WSDL will generate us a package java .jar with all classes and method services, it package we could import to a ower bssv project as external library and works comfortable.

You can look a lot of information about the use of it java tool:

https://docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html

https://www.ibm.com/support/knowledgecenter/es/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/twbs_jaxwsclientfromwsdl.html

https://www.ibm.com/support/knowledgecenter/es/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/rwbs_wsimport.html

https://mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/

http://chuwiki.chuidiang.org/index.php?title=Ejemplo_sencillo_de_web_service_con_jax-ws


And more specific for Salesforce service:

https://stackoverflow.com/questions/2322953/jax-ws-adding-soap-headers

https://udby.com/archives/132

I recommend, java version it's the same for wsimport and JDeveloper configured for your JDE enviroment ( it can do directly with the java executable version in JDE machine or add java version path on the PATH operative system).


Execution example:

wsimport -b bindings.xjb -keep -B-XautoNameResolution -XadditionalHeaders -Xdebug OrganizationDEV.wsdl -clientjar SalesForceOrganizationDEVWSDLConnector.jar 

Donde

wsimport: java  command for class generation from wsdl

-b: specify link files jaxws/jaxb or additional schemes

bindings.xjb: link file or additional schemes

-keep: keep generated files 

-B-XautoNameResolution: JAXB instructions to automatically resolve names conflicts.

-XadditionalHeaders: generates header parameters in request methods

-Xdebug: print debug information

OrganizationDEV.wsdl: wsdl file with service information

-clientjar: make jar file with artifacts generated together WSDL metadata for call web service.

SalesForceOrganizationDEVWSDLConnector.jar: jar file will generate with all java class and wsdl to project import.

bindings.xjb file will depends from namespaces and transformations to do.

bindings.xjb

<?xml version="1.0" encoding="UTF-8"?>

<bindings

    wsdlLocation="wsdlcalidad.wsdl"

    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"

    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="http://java.sun.com/xml/ns/jaxws">

    <bindings node="//xsd:schema[@targetNamespace='urn:sobject.enterprise.soap.sforce.com']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

    </bindings>

</bindings>


Other example:

<?xml version="1.0" encoding="UTF-8"?>

<bindings

    wsdlLocation="INTProducto_JDE.wsdl"

    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"

    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="http://java.sun.com/xml/ns/jaxws">

    <bindings node="//xsd:schema[@targetNamespace='http://soap.sforce.com/schemas/class/INTProducto_JDE']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

  <jaxb:schemaBindings>

        <jaxb:nameXmlTransform>

          <jaxb:typeName suffix="Type" />

        </jaxb:nameXmlTransform>

      </jaxb:schemaBindings>

    </bindings>

    <bindings node="//xsd:schema[@targetNamespace='http://soap.sforce.com/schemas/class/INTResponse']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

  <jaxb:schemaBindings>

        <jaxb:nameXmlTransform>

          <jaxb:typeName suffix="Type" />

        </jaxb:nameXmlTransform>

      </jaxb:schemaBindings>

    </bindings>

    <enableWrapperStyle>false</enableWrapperStyle>

    <enableAsyncMapping>false</enableAsyncMapping>

</bindings>

And finally, you import jar file to project, adding libraries for deploy and start to use classes and method to call service.

I hope it is useful for you friend.

Best regards.




jueves, 29 de julio de 2021

[JD Edwards - BSSV] Integración JDE - Salesforce: Crear proxy paquete JAVA con WSIMPORT

 Hola amigos,

Recientemente he realizado una integración de JDE con Salesforce Cloud, a través de BSSV tanto de entrada como de salida con Soap. Salesforce utiliza Apex para las integraciones.

Integración JDE - Salesforce

Uno de los problemas principales que me encontré fue al generar el proxy client, ya que el WSDL de Organization que se genera tiene una gran cantidad de métodos (éste servicio es el principal, y se utiliza para todo lo relacionado con el acceso: login, logout, sessions, userinfo, etc), y además al generar el proxy client en JDeveloper 12c (12.2.1.3.0) daba errores por conflictos en los namespaces.

Así que, decidí utilizar un camino alternativo, utilizando la herramienta de JAVA wsimport el cual a partir del archivo o dirección WSDL nos generará un paquete java .jar con las clases y métodos del servicio, el cual podremos importar a nuestro proyecto como una librería externa y trabajar cómodamente.

Podéis encontrar mucha información acerca del uso de ésta herramienta java:

https://docs.oracle.com/javase/7/docs/technotes/tools/share/wsimport.html

https://www.ibm.com/support/knowledgecenter/es/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/twbs_jaxwsclientfromwsdl.html

https://www.ibm.com/support/knowledgecenter/es/SSEQTP_9.0.5/com.ibm.websphere.base.doc/ae/rwbs_wsimport.html

https://mkyong.com/webservices/jax-ws/jax-ws-wsimport-tool-example/

http://chuwiki.chuidiang.org/index.php?title=Ejemplo_sencillo_de_web_service_con_jax-ws


Y más específicos para servicios de Salesforce:

https://stackoverflow.com/questions/2322953/jax-ws-adding-soap-headers

https://udby.com/archives/132

Os recomiendo, que la versión java que utilicéis para wsimport sea la misma que utilice la versión del JDeveloper configurado para vuestro JDE (esto podréis hacerlo directamente con el ejecutable de la versión java instalado o añadiendo la ruta de la versión java sobre el PATH del sistema operativo).


Ejemplo ejecución:

wsimport -b bindings.xjb -keep -B-XautoNameResolution -XadditionalHeaders -Xdebug OrganizationDEV.wsdl -clientjar SalesForceOrganizationDEVWSDLConnector.jar 

Donde

wsimport: comando java para la generación de clases a partir de wsdl

-b: expecifica archivos de enlace jaxws/jaxb o esquemas adicionales

bindings.xjb: archivo de enlace o esquemas adicionales

-keep: mantiene los archivos generados

-B-XautoNameResolution: instrucción de JAXB para automáticamente resolver conflictos de nombres

-XadditionalHeaders: genera parámetros de cabecera en los métodos de la peticiones

-Xdebug: imprime la información de depuración

OrganizationDEV.wsdl: archivo wsdl con la información del servicio

-clientjar: crea el archivo jar de los artefactos generados junto con los metadatos WSDL necesarios para llamar al servicio web.

SalesForceOrganizationDEVWSDLConnector.jar: archivo jar a generar con todas las clases java y wsdl para importar al proyecto.

El archivo bindings.xjb dependerá de los namespaces y transformaciones a realizar.

bindings.xjb

<?xml version="1.0" encoding="UTF-8"?>

<bindings

    wsdlLocation="wsdlcalidad.wsdl"

    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"

    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="http://java.sun.com/xml/ns/jaxws">

    <bindings node="//xsd:schema[@targetNamespace='urn:sobject.enterprise.soap.sforce.com']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

    </bindings>

</bindings>


Otro ejemplo:

<?xml version="1.0" encoding="UTF-8"?>

<bindings

    wsdlLocation="INTProducto_JDE.wsdl"

    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"

    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

    xmlns:xsd="http://www.w3.org/2001/XMLSchema"

    xmlns="http://java.sun.com/xml/ns/jaxws">

    <bindings node="//xsd:schema[@targetNamespace='http://soap.sforce.com/schemas/class/INTProducto_JDE']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

  <jaxb:schemaBindings>

        <jaxb:nameXmlTransform>

          <jaxb:typeName suffix="Type" />

        </jaxb:nameXmlTransform>

      </jaxb:schemaBindings>

    </bindings>

    <bindings node="//xsd:schema[@targetNamespace='http://soap.sforce.com/schemas/class/INTResponse']">

      <jaxb:globalBindings generateElementProperty="false" underscoreBinding="asCharInWord"/>

  <jaxb:schemaBindings>

        <jaxb:nameXmlTransform>

          <jaxb:typeName suffix="Type" />

        </jaxb:nameXmlTransform>

      </jaxb:schemaBindings>

    </bindings>

    <enableWrapperStyle>false</enableWrapperStyle>

    <enableAsyncMapping>false</enableAsyncMapping>

</bindings>

Y por último, importar el archivo .jar al proyecto, añadirlo a las librerías para el despliegue y empezar a utilizar las clases y métodos para la llamada al servicio.

Espero os sea útil.

Un saludo.