Export of Module Data in JSON File
General
Using the Read module data interface, the data of a PLANTA project module can be read out via the web and saved in a JSON file for easy readability or to process the data further or to exchange it between other platforms.
This approach can be seen as a more comprehensive alternative to the transformation of data via web entities, the possibilities of which are limited by the fact that web entities always refer to a table and they can therefore not be used to map complex module constructions.
The approach can also be used for simplified customizing, as the entire customizing toolbox (formats, summarization, grouping, virtual fields, ...) is available.
Module End Point
A released module can be read out via the web using the ModuleReaderImplementation module endpoint. The query parameters are passed on to the module class. The data for a module are provided as JSON by default. If you pass on “format=json-schema”, you get a JSON schema file for the module instead of the module data.
The implementation checks whether the requested module is released for the web. If so, it is opened via a macro module (009DVH) in a clientless session and the read_module_data_for_web() - method is called.
Configuration in Customizing
In the Further Module Parameters module, you must activate the Web-Export checkbox for the module the data of which is to be exported.
The data areas of the module that are to be included in the export must have a Python ID and data fields in window 1/2/3.
If the Never show checkbox is activated for a data area at the top level, it is skipped.
The behavior for individual fields can be adjusted via the data field configuration:
get-tech-value: Reads the technical value from the field instead of the string representation
use-df-heading: Instead of the Python ID, the DF heading is used as the key
Individual customer customizings
The read_module_data_for_web(self, query_parameters) method on the module class is responsible for reading and returning the data. It can be overwritten in a module subclass in order to adapt the behavior and, for example, set the filters in the module via the query parameters.
class ExampleCustomerReader(Base):
def read_module_data_for_web(self, query_parameters):
# Read a project_id from the query parameters and set it as search criteria in a specific DA
project_id = query_parameters.get('project_id', None)
if project_id is not None:
self.project.get_customizing().pr_id.set_search_criteria(project_id, project_id)
return super().read_module_data_for_web(query_parameters)