 
/*------------------------------------------------------------------------
   File        : adresse_dict
   Purpose     : 
   Syntax      : 
   Description : 
   Author(s)   : walter.riechsteiner
   Created     : Thu Jun 26 13:56:20 CEST 2025
   Notes       : 
 ----------------------------------------------------------------------*/
 
BLOCK-LEVEL ON ERROR UNDO, THROW.

USING OpenEdge.Core.String FROM PROPATH.
USING OpenEdge.Net.HTTP.IHttpResponse FROM PROPATH.
USING OpenEdge.Net.HTTP.StatusCodeEnum FROM PROPATH.
USING OpenEdge.Web.IWebRequest FROM PROPATH.
USING OpenEdge.Web.WebHandler FROM PROPATH.
USING OpenEdge.Web.WebResponseWriter FROM PROPATH.
USING Progress.Json.ObjectModel.JsonObject FROM PROPATH.
USING Progress.Json.ObjectModel.JsonArray FROM PROPATH.
USING Progress.Json.ObjectModel.ObjectModelParser FROM PROPATH.
USING src.ch.adprime.gemis.WebHandlerUtilities FROM PROPATH.
USING utilities.utilitiesHandler FROM PROPATH.
USING Progress.Json.ObjectModel.JsonDataType FROM PROPATH.
USING System.Windows.Forms.HtmlDocument FROM ASSEMBLY.
USING System.Windows.Forms.VisualStyles.FilenameProperty FROM ASSEMBLY.

CLASS admin.formdesignerImpl INHERITS WebHandler: 

    DEFINE VARIABLE oResponse         AS IHttpResponse     NO-UNDO.         
    DEFINE VARIABLE oWriter           AS WebResponseWriter NO-UNDO.
    DEFINE VARIABLE oBody             AS String            NO-UNDO.
    
    DEFINE VARIABLE ccompany          AS CHARACTER         NO-UNDO.
    DEFINE VARIABLE cuser_name        AS CHARACTER         NO-UNDO.
    DEFINE VARIABLE cAnzeigeName      AS CHARACTER         NO-UNDO.
    DEFINE VARIABLE ilanguage_id      AS INTEGER           NO-UNDO.
    DEFINE VARIABLE cSessionToken     AS CHARACTER         NO-UNDO.
    DEFINE VARIABLE cFunction         AS CHARACTER         NO-UNDO.
    
    DEFINE VARIABLE outilitiesHandler AS utilitiesHandler  NO-UNDO.
    
    DEFINE TEMP-TABLE tcompanies
        SERIALIZE-NAME 'companies'
        FIELD company      AS CHARACTER SERIALIZE-NAME 'company'
        FIELD company_Name AS CHARACTER SERIALIZE-NAME 'company_name'
        FIELD lselected    AS LOGICAL   SERIALIZE-NAME 'selected'
        .
    DEFINE VARIABLE htcompanies AS HANDLE NO-UNDO.
        
    DEFINE TEMP-TABLE tusers
        FIELD user_name    AS CHARACTER 
        FIELD display_name AS CHARACTER
        .
    DEFINE VARIABLE htusers AS HANDLE NO-UNDO.
    
    DEFINE TEMP-TABLE tlanguages
        FIELD language_id   AS INTEGER 
        FIELD language_name AS CHAR
        .
    DEFINE VARIABLE htlanguages AS HANDLE NO-UNDO.
        
    DEFINE TEMP-TABLE tFileDict
        SERIALIZE-NAME 'fields'
        FIELD cId          AS CHARACTER SERIALIZE-NAME 'id'
        FIELD cName        AS CHARACTER SERIALIZE-NAME 'fieldName'
        FIELD cLabel       AS CHARACTER SERIALIZE-NAME 'label' 
        FIELD cType        AS CHARACTER SERIALIZE-NAME 'type'
        FIELD cDisplayType AS CHARACTER SERIALIZE-NAME 'displayType'
        FIELD cInputMode   AS CHARACTER SERIALIZE-NAME 'inputMode'
        FIELD lshowSpinner AS LOGICAL   SERIALIZE-NAME 'showSpinner'
        FIELD cFormat      AS CHARACTER SERIALIZE-NAME 'format'
        FIELD iMaxLength   AS INTEGER   SERIALIZE-NAME 'maxLength'
        FIELD iDecimals    AS INTEGER   SERIALIZE-NAME 'decimalPlaces'
        FIELD leditable    AS LOGICAL   SERIALIZE-NAME 'editable'
        FIELD lhidden      AS LOGICAL   SERIALIZE-NAME 'hidden'
        FIELD cAusrichtung AS CHARACTER SERIALIZE-NAME 'align'
        FIELD iMaxExtent   AS INTEGER   SERIALIZE-NAME 'maxExtent'
        FIELD iAnzZeilen   AS INTEGER   SERIALIZE-NAME 'rowSpan'
        .
        
    DEFINE TEMP-TABLE tConfig
        SERIALIZE-NAME 'existingConfigs'
        FIELD cId        AS CHARACTER SERIALIZE-NAME 'id'
        FIELD cFormTitle AS CHARACTER SERIALIZE-NAME 'formTitle'
        FIELD cFormId    AS CHARACTER SERIALIZE-NAME 'formId' 
        FIELD cCreated   AS CHARACTER SERIALIZE-NAME 'created'
        . 

    DEFINE DATASET dsResponse
        SERIALIZE-NAME 'dsResponse'
        FOR tFileDict, tConfig.
    DEFINE VARIABLE hdsResponse AS HANDLE NO-UNDO.
        
    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/

    METHOD PUBLIC LOGICAL createTemptable(
        INPUT  ipoJsonFields AS JsonArray,
        OUTPUT ophtTable     AS HANDLE   ,
        OUTPUT ophBuffer     AS HANDLE 
        ):
        
        DEFINE VARIABLE lRetVal          AS LOGICAL    NO-UNDO.
        DEFINE VARIABLE iType            AS INTEGER    NO-UNDO.
        DEFINE VARIABLE cType            AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cField           AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE hField           AS HANDLE     NO-UNDO.
        DEFINE VARIABLE ii               AS INTEGER    NO-UNDO.
        DEFINE VARIABLE i1               AS INTEGER    NO-UNDO.
        DEFINE VARIABLE iExtent          AS INTEGER    NO-UNDO.
        DEFINE VARIABLE iNumber          AS INTEGER    NO-UNDO.
        DEFINE VARIABLE cFieldAttributes AS CHARACTER  NO-UNDO EXTENT.
        DEFINE VARIABLE cFieldAttribute  AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE oJsonField       AS JsonObject NO-UNDO.
        DEFINE VARIABLE oJsonAttr        AS JsonObject NO-UNDO.
        DEFINE VARIABLE cValue           AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cAddFields       AS CHARACTER  NO-UNDO
            INIT 'id,fieldName,label,type,maxLength,format,decimalPlaces,widthInChars,source,align,selectOptionsType'.
        DEFINE VARIABLE cAddedFields     AS CHARACTER  NO-UNDO.

        CREATE TEMP-TABLE ophtTable.

        cAddedFields = ''.
        DO i1 = 1 TO ipoJsonFields:LENGTH:
            oJsonField       = NEW JsonObject().
            oJsonField       = ipoJsonFields:GetJsonObject(i1).

            EXTENT(cFieldAttributes) = ?.
            cFieldAttributes = oJsonField:getNames() NO-ERROR.
            iExtent = EXTENT(cFieldAttributes).

            DO ii = 1 TO iExtent:
                cField = cFieldAttributes[ii].
                IF cField = ''                           THEN NEXT.
                IF LOOKUP(cField, cAddFields  , ',') = 0 THEN NEXT.
                IF LOOKUP(cField, cAddedFields, ',') > 0 THEN NEXT. 
                iType  = oJsonField:getType(cField).

                CASE iType:
                    WHEN 1 THEN 
                        cType = 'character'.
                    WHEN 2 THEN 
                        cType = 'integer'.
                    WHEN 3 THEN 
                        cType = 'logical'.
                // 4    JsonDataType:OBJECT JSON Object
                // 5    JsonDataType:ARRAY  JSON Array
                // 6    JsonDataType:NULL   Null
                    OTHERWISE 
                    DO:
                        MESSAGE cField 'otherwise' iType.   
                        cType = 'character'.
                    END.
                END CASE.
                
                cAddedFields = cAddedFields
                    + (IF cAddedFields = '' THEN '' ELSE ',')
                    + cField.
                ophtTable:ADD-NEW-FIELD(cField, cType) NO-ERROR.
                IF outilitiesHandler:evaluateErrorStatus(ERROR-STATUS:HANDLE) THEN NEXT.
            END.
        END.

        ophtTable:TEMP-TABLE-PREPARE('ttTemp').
        ophBuffer = ophtTable:DEFAULT-BUFFER-HANDLE.

        DO i1 = 1 TO ipoJsonFields:LENGTH:
            oJsonField  = NEW JsonObject().
            oJsonField  = ipoJsonFields:GetJsonObject(i1) NO-ERROR.
            IF outilitiesHandler:evaluateErrorStatus(ERROR-STATUS:HANDLE) THEN NEXT.
            
            cValue = oJsonField:GetCharacter('id') NO-ERROR.

            REPEAT TRANSACTION ON ERROR UNDO, LEAVE:
                ophBuffer:BUFFER-CREATE().
                iExtent = NUM-ENTRIES(cAddedFields, ',').
                
                DO ii = 1 TO iExtent:
                    cField = ENTRY(ii, cAddedFields, ',').
                    IF NOT oJsonField:Has(cField) THEN NEXT.
                    
                    hField = ophBuffer:BUFFER-FIELD(cField) NO-ERROR.
                    IF outilitiesHandler:evaluateErrorStatus(ERROR-STATUS:HANDLE) THEN NEXT.

                    IF oJsonField:IsNull(cField) THEN
                    DO:
                        MESSAGE 'NULLWERT'.
                        hField:BUFFER-VALUE = ?.
                        NEXT.
                    END.
                    // cValue = oJsonField:GetCharacter(cField).
                    CASE hField:DATA-TYPE:
                        WHEN 'character' THEN 
                            hField:BUFFER-VALUE = oJsonField:GetCharacter(cField) NO-ERROR. 
                        WHEN 'integer' THEN 
                            hField:BUFFER-VALUE = oJsonField:GetInteger(cField) NO-ERROR. 
                        WHEN 'logical' THEN 
                            hField:BUFFER-VALUE = STRING(oJsonField:GetLogical(cField)) NO-ERROR.
                    END CASE.
                    IF hField:BUFFER-VALUE = ? THEN hField:BUFFER-VALUE = ''.
                END.
                LEAVE.
            END.
        END.
        
        // DELETE OBJECT oJsonField NO-ERROR.

        lRetVal = TRUE.
        RETURN lRetVal.

    END METHOD.

    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/

    METHOD PUBLIC LOGICAL fillFileDict(
        INPUT oJsonIdent AS JsonObject
        ):

        DEFINE VARIABLE lresult      AS LOGICAL   NO-UNDO INIT FALSE.
        DEFINE VARIABLE ii           AS INTEGER   NO-UNDO.
        DEFINE VARIABLE i1           AS INTEGER   NO-UNDO.
        DEFINE VARIABLE j1           AS INTEGER   NO-UNDO.
        DEFINE VARIABLE j2           AS INTEGER   NO-UNDO.
        DEFINE VARIABLE lRetVal      AS LOG       NO-UNDO INIT FALSE.
        DEFINE VARIABLE rFile        AS RECID     NO-UNDO.
        DEFINE VARIABLE cViewas      AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cSidelabel   AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cHeadlabel   AS CHARACTER NO-UNDO.
        DEFINE VARIABLE rLabelTexte  AS RECID     NO-UNDO.
        
        DEFINE VARIABLE hBuffer      AS HANDLE    NO-UNDO.
        DEFINE VARIABLE hField       AS HANDLE    NO-UNDO.
        DEFINE VARIABLE hQuery       AS HANDLE    NO-UNDO.
        DEFINE VARIABLE httTable     AS HANDLE    NO-UNDO.
        DEFINE VARIABLE hBufferFile  AS HANDLE    NO-UNDO.
        DEFINE VARIABLE hBufferField AS HANDLE    NO-UNDO.
        
        DEFINE VARIABLE cFileNames   AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cFileName    AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cFieldName   AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cLDBName     AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cDBFileName  AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cWhere       AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cValue       AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cLabel       AS CHARACTER NO-UNDO.
        
        DEFINE VARIABLE ccompany     AS CHARACTER NO-UNDO.
        DEFINE VARIABLE cuser_name   AS CHARACTER NO-UNDO.
        DEFINE VARIABLE iLanguage_id AS INTEGER   NO-UNDO.
        
        DEFINE BUFFER blabeltexte FOR labeltexte.
        DEFINE BUFFER btFileDict  FOR tFileDict.
        
        ccompany     = oJsonIdent:GetCharacter('company').
        cuser_name   = oJsonIdent:GetCharacter('user_name').
        iLanguage_id = oJsonIdent:GetInteger  ('language_id').
        
        outilitiesHandler = NEW utilitiesHandler().
        
        EMPTY TEMP-TABLE tFileDict.
        lRetVal = FALSE.
        cFileNames = oJsonIdent:GetCharacter('tables').
        cFileNames = REPLACE(cFileNames, '%2C', ';').
        cFileNames = REPLACE(cFileNames, '%3C', ';').
        cFileNames = REPLACE(cFileNames, ',', ';').

        DO ii = 1 TO NUM-ENTRIES(cFileNames, ';'):
            cFileName   = ENTRY(ii,cFileNames, ';').
            cLDBName    = outilitiesHandler:getLogicalDBName(cFileName).
            cDBFileName = cLDBName + '.' + '_File'.
            CREATE BUFFER hBufferFile FOR TABLE cDBFileName.

            hBufferFile:FIND-UNIQUE(SUBSTITUTE('WHERE _File._File-Name = &1', QUOTER(cFileName)), NO-LOCK) NO-ERROR.

            CREATE QUERY hQuery.
            cDBFileName = REPLACE(cDBFileName, '_File', '_Field').
            CREATE BUFFER hBufferField FOR TABLE cDBFileName.
            hQuery:SET-BUFFERS(hBufferField).
            cWhere = SUBSTITUTE('FOR EACH _Field WHERE _Field._File-recid = &1 BY _Order', hBufferFile:RECID ).
            hQuery:QUERY-PREPARE(cWhere).

            hQuery:QUERY-OPEN ().
            hQuery:GET-FIRST(). 
            hBuffer = hBufferField.
            DO WHILE NOT hQuery:QUERY-OFF-END:
                cFieldName = hBufferField::_Field-Name.
                
                IF cFieldName  = 'wordindex' THEN 
                DO:
                    hQuery:GET-NEXT ().
                    NEXT.
                END.
                
                hField = hBufferField:BUFFER-FIELD('_Label'):HANDLE NO-ERROR.
                IF VALID-HANDLE(hField) THEN cLabel = hField:BUFFER-VALUE.

                IF  cLabel = ?   OR
                    cLabel = '?' OR
                    clabel = ''  THEN cLabel = cFieldName.
                
                CREATE  tFileDict.
                ASSIGN
                    tFileDict.cId          = cFileName + '_' + cFieldName
                    tFileDict.cName        = cFilename + '_' + cFieldName
                    tFileDict.cFormat      = hBuffer::_FORMAT
                    tFileDict.cType        = hBuffer::_DATA-TYPE
                    tFileDict.iDecimals    = 0
                    tFileDict.lhidden      = FALSE
                    tFileDict.leditable    = TRUE
                    tFileDict.iMaxLength   = 12
                    tFileDict.cAusrichtung = 'left'
                    tFileDict.cDisplayType = ?
                    tFileDict.lShowSpinner = ?
                    tFileDict.cInputMode   = ?
                    .
                DO WHILE TRUE TRANSACTION:
                    FIND FIRST labeltexte NO-LOCK
                        WHERE labeltexte.company     = ccompany
                        AND   labeltexte.user_name   = 'admin'
                        AND   labeltexte.table_name  = cFileName
                        AND   labeltexte.field_name  = cFieldName
                        AND   labeltexte.language_id = iLanguage_id
                        AND   labeltexte.program     = '' NO-ERROR.
                    IF AVAILABLE labeltexte THEN
                    DO:
                        rLabelTexte = RECID(labeltexte).
                        LEAVE.
                    END.

                    FIND FIRST blabeltexte NO-LOCK
                        WHERE blabeltexte.company     = ccompany
                        AND   blabeltexte.user_name   = 'admin'
                        AND   blabeltexte.field_name  = cFieldName
                        AND   blabeltexte.language_id = iLanguage_id
                        AND   blabeltexte.program     = '' NO-ERROR.
                    IF AVAILABLE blabeltexte THEN
                        ASSIGN
                            cSidelabel = blabeltexte.sidelabel
                            cHeadlabel = blabeltexte.headlabel.
                    ELSE
                        ASSIGN
                            cSidelabel = cLabel
                            cHeadlabel = cLabel.

                    CREATE  labeltexte.
                    ASSIGN
                        labeltexte.company     = ccompany
                        labeltexte.user_name   = 'admin'
                        labeltexte.table_name  = cFileName
                        labeltexte.field_name  = cFieldName
                        labeltexte.language_id = iLanguage_id
                        labeltexte.program     = ''
                        labeltexte.created_at  = NOW NO-ERROR.

                    ASSIGN
                        labeltexte.sidelabel = cSidelabel
                        labeltexte.headlabel = cHeadlabel.

                    rLabelTexte = RECID(labeltexte).
                    RELEASE labeltexte.
                    RELEASE blabeltexte.
                    LEAVE.
                END.

                DO WHILE TRUE TRANSACTION:
                    IF cuser_name = 'admin' THEN LEAVE.

                    FIND FIRST labeltexte NO-LOCK
                        WHERE labeltexte.company     = ccompany
                        AND   labeltexte.user_name   = cuser_name
                        AND   labeltexte.table_name  = cFileName
                        AND   labeltexte.field_name  = cFieldName
                        AND   labeltexte.language_id = iLanguage_id
                        AND   labeltexte.program     = '' NO-ERROR.
                    IF AVAILABLE labeltexte THEN
                    DO:
                        rLabelTexte = RECID(labeltexte).
                        LEAVE.
                    END.

                    FIND FIRST blabeltexte NO-LOCK
                        WHERE blabeltexte.company     = ccompany
                        AND   blabeltexte.user_name   = cuser_name
                        AND   blabeltexte.field_name  = cFieldName
                        AND   blabeltexte.language_id = iLanguage_id
                        AND   blabeltexte.program     = '' NO-ERROR.
                    IF AVAILABLE blabeltexte THEN
                    DO:
                        rLabelTexte = RECID(blabeltexte).
                        LEAVE.
                    END.
                    LEAVE.
                END.

                FIND labeltexte NO-LOCK
                    WHERE RECID(labeltexte) = rLabelTexte.
                tFileDict.cLabel = labeltexte.headlabel.

                IF INDEX(hBuffer::_FORMAT, '(') = 0 THEN tFileDict.iMaxLength = LENGTH(hBuffer::_FORMAT).
                ELSE
                DO:
                    j1 = INDEX(hBuffer::_FORMAT, '(') + 1.
                    j2 = INDEX(hBuffer::_FORMAT, ')').
                    tFileDict.iMaxLength = INTEGER(SUBSTRING(hBuffer::_FORMAT, j1, j2 - j1)).
                END.
                IF hBuffer::_EXTENT > 0 THEN tFileDict.iMaxLength = tFileDict.iMaxLength * hBuffer::_EXTENT.

                CASE tFileDict.cType:
                    WHEN 'character' THEN
                        DO:
                            ASSIGN
                                tFileDict.cType     = 'text'
                                tFileDict.iDecimals = 0.
                            IF hBuffer::_Extent > 0 THEN 
                            DO:
                                ASSIGN 
                                    tFileDict.cType      = 'extent'
                                    tFileDict.iMaxExtent = hBuffer::_Extent
                                    tFileDict.iAnzZeilen = tFileDict.iMaxExtent.
                            END. 
                        END.
                    WHEN 'Date' THEN
                        DO:
                            ASSIGN
                                tFileDict.cType        = 'date'
                                tFileDict.cFormat      = '99.99.9999'
                                tFileDict.iDecimals    = 0
                                tFileDict.iMaxLength   = tFileDict.iMaxLength + 2
                                tFileDict.cAusrichtung = 'center'.
                        END.
                    WHEN 'Decimal' THEN
                        DO:
                            ASSIGN
                                tFileDict.cType        = 'decimal'
                                tFileDict.iDecimals    = hBuffer::_DECIMALS
                                tFileDict.cDisplayType = 'text'
                                tFileDict.cInputMode   = 'decimal'
                                tFileDict.lShowSpinner = FALSE
                                tFileDict.iMaxLength   = tFileDict.iMaxLength
                                tFileDict.cAusrichtung = 'right'.
                        END.
                    WHEN 'Integer' OR
                    WHEN 'Int64'   THEN
                        DO:
                            ASSIGN
                                tFileDict.cType        = 'integer'
                                tFileDict.iDecimals    = 0
                                tFileDict.cDisplayType = 'text'
                                tFileDict.cInputMode   = 'numeric'
                                tFileDict.lShowSpinner = FALSE
                                tFileDict.iMaxLength   = tFileDict.iMaxLength
                                tFileDict.cAusrichtung = 'right'.
                        END.
                    WHEN 'Recid' THEN
                        DO:
                            ASSIGN
                                tFileDict.cType        = 'integer'
                                tFileDict.iDecimals    = 0
                                tFileDict.cDisplayType = 'text'
                                tFileDict.cInputMode   = 'text'
                                tFileDict.lShowSpinner = FALSE
                                tFileDict.lHidden      = TRUE
                                tFileDict.leditable    = FALSE.
                        END.
                    WHEN 'logical' THEN
                        DO:
                            ASSIGN
                                tFileDict.cType        = 'checkbox'
                                tFileDict.cAusrichtung = 'center'.
                        END.
                END CASE.

                cViewas = hBuffer::_VIEW-AS NO-ERROR.
                IF ERROR-STATUS:ERROR THEN 
                DO:
                    hQuery:GET-NEXT ().
                    NEXT.
                END.
                IF INDEX(cViewas, 'COMBO-BOX') > 0 THEN cViewAS = 'combo-box'.
                
                CASE cViewas:
                    WHEN 'combo-box' THEN
                        DO:
                            tFileDict.cType = 'select'.
                            CREATE btFileDict.
                            ASSIGN
                                btFileDict.cId          = cFileName + '_' + cFieldName + '_BoxField'
                                btFileDict.cName        = cFilename + '_' + cFieldName + '_BoxField'
                                btFileDict.cFormat      = 'x(100)'
                                btFileDict.cType        = 'character'
                                btFileDict.iDecimals    = 0
                                btFileDict.lhidden      = TRUE
                                btFileDict.leditable    = FALSE
                                btFileDict.iMaxLength   = 100
                                btFileDict.cAusrichtung = 'left'
                                btFileDict.cDisplayType = ?
                                btFileDict.lShowSpinner = ?
                                btFileDict.cInputMode   = ?
                                btFileDict.cLabel       = cFieldName + '_BoxField'.
                            .
                        END.
                    WHEN 'editor' THEN
                        ASSIGN
                            tFileDict.cType = 'textarea'.
                END CASE.

                hQuery:GET-NEXT().
            END.

            DELETE OBJECT hBufferFile   NO-ERROR.
            DELETE OBJECT hBufferField  NO-ERROR.
            DELETE OBJECT hQuery        NO-ERROR.
        END.
        
        lResult = TRUE.

        RETURN lresult.

    END METHOD.

    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/

    METHOD OVERRIDE PROTECTED INTEGER HandleGet (INPUT poRequest AS IWebRequest ):
        DEFINE VARIABLE oJsonResponse   AS JsonObject NO-UNDO.
        DEFINE VARIABLE oJsonIdent      AS JsonObject NO-UNDO.
        
        DEFINE VARIABLE oJsonCompanies  AS JsonArray  NO-UNDO.
        DEFINE VARIABLE oJsonUsers      AS JsonArray  NO-UNDO.
        DEFINE VARIABLE oJsonLanguages  AS JsonArray  NO-UNDO.
        DEFINE VARIABLE oBody           AS String     NO-UNDO.
        
        DEFINE VARIABLE cDefautlCharSet AS CHARACTER  NO-UNDO INIT 'UTF-8'.
        DEFINE VARIABLE cCorralationID  AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cContent-Type   AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE htFileDict      AS HANDLE     NO-UNDO.
        DEFINE VARIABLE htConfig        AS HANDLE     NO-UNDO.
        DEFINE VARIABLE lcJsonInhalt    AS LONGCHAR   NO-UNDO.
        DEFINE VARIABLE cFileNames      AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cFileName       AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE ii              AS INTEGER    NO-UNDO.
        DEFINE VARIABLE iMatches        AS INTEGER    NO-UNDO.
        DEFINE VARIABLE dDateTime       AS DATETIME   NO-UNDO.
        DEFINE VARIABLE cDateTime       AS CHARACTER  NO-UNDO.
        
        DEFINE VARIABLE cConfig_id      AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE lRetVal         AS LOGICAL    NO-UNDO INIT FALSE.
        DEFINE VARIABLE cQueryString    AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cQueryPairs     AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cQueryKey       AS CHARACTER  NO-UNDO.
        DEFINE VARIABLE cQueryValue     AS CHARACTER  NO-UNDO.
        
        outilitiesHandler = NEW utilitiesHandler().
// MESSAGE 'GetHandler '.
        cQueryString = STRING(poRequest:GetContextValue("QUERY_STRING"))    NO-ERROR.
        outilitiesHandler:getHeaderData(
            INPUT  poRequest    ,
            OUTPUT ccompany     ,
            OUTPUT cuser_name   ,
            OUTPUT cAnzeigeName ,
            OUTPUT ilanguage_id ,
            OUTPUT cSessionToken,
            OUTPUT cFunction    ,
            OUTPUT oJsonIdent   
            ).
            
// oJsonIdent:WriteFile('C:\TEMP\formdesigner_GET.json', TRUE).
// MESSAGE 'getHandler Function =' cFunction.        
        DO WHILE cFunction = 'init':
            EMPTY TEMP-TABLE tcompanies.
            FOR EACH companies NO-LOCK WHERE companies.active:
                CREATE  tcompanies.
                BUFFER-COPY companies TO tcompanies.
                ASSIGN 
                    tcompanies.lselected = (IF companies.company = ccompany THEN TRUE ELSE FALSE).
            END.
            
            EMPTY TEMP-TABLE tusers.
            FOR EACH users NO-LOCK WHERE users.active:
                CREATE  tusers.
                BUFFER-COPY users TO tusers.
            END.
            
            EMPTY TEMP-TABLE tlanguages.
            FOR EACH languages NO-LOCK:
                CREATE  tlanguages.
                BUFFER-COPY languages TO tlanguages.
            END.
            
            oJsonResponse   = NEW JsonObject().
            oJsonCompanies  = NEW JsonArray().
            oJsonUsers      = NEW JsonArray().
            oJsonLanguages  = NEW JsonArray().
            
            htcompanies = TEMP-TABLE tcompanies:DEFAULT-BUFFER-HANDLE.
            htusers     = TEMP-TABLE tusers    :DEFAULT-BUFFER-HANDLE.
            htlanguages = TEMP-TABLE tlanguages:DEFAULT-BUFFER-HANDLE.
            
            htcompanies:WRITE-JSON('JsonArray', oJsonCompanies ).
            htusers    :WRITE-JSON('JsonArray', oJsonUsers     ).
            htlanguages:WRITE-JSON('JsonArray', oJsonLanguages ).
            
            oJsonResponse:ADD('companies', oJsonCompanies).
            oJsonResponse:ADD('users'    , oJsonUsers    ).
            oJsonResponse:ADD('languages', oJsonLanguages).
            
            oJsonResponse:WRITE(lcJsonInhalt, FALSE).
            
            lRetVal = TRUE.
            LEAVE.
        END.

        DO WHILE cFunction = 'load': 
            lRetVal = fillFileDict(
                INPUT oJsonIdent
                ).

            cFileNames = oJsonIdent:GetCharacter('tables').
            cFileNames = REPLACE(cFileNames, ',', ';').

            EMPTY TEMP-TABLE tConfig.
            FOR EACH htmldokumente NO-LOCK 
                WHERE htmldokumente.company     = ccompany
                AND   htmldokumente.user_name   = cuser_name
                AND   htmldokumente.language_id = ilanguage_id:

                iMatches = 0.
                DO ii = 1 TO NUM-ENTRIES(cFileNames, ';'):
                    cFileName = ENTRY(ii, cFileNames, ';').

                    IF INDEX(htmldokumente.Tables, cFileName) = 0 THEN NEXT.
                    
                    IF htmldokumente.updated_at = ? THEN 
                    DO:
                        dDateTime = htmldokumente.created_at. 
                        cDateTime = STRING(htmldokumente.created_at,'99-99-9999THH:MM:SS').
                    END.
                    ELSE 
                    DO:
                        dDateTime = htmldokumente.updated_at. 
                        cDateTime = STRING(htmldokumente.updated_at,'99-99-9999THH:MM:SS').
                    END.
                    iMatches = iMatches + 1.
                END.
                IF  iMatches <> NUM-ENTRIES(cFileNames, ';')           OR
                    iMatches <> NUM-ENTRIES(htmldokumente.tables, ',') THEN NEXT. 

                CREATE  tConfig.
                ASSIGN  
                    tConfig.cId        = htmldokumente.formId
                    tConfig.cFormTitle = htmldokumente.formtitle
                    tConfig.cCreated   = STRING(YEAR(dDateTime),'9999')
                                       + '-'
                                       + STRING(MONTH(dDateTime),'99')
                                       + '-'
                                       + STRING(DAY(dDateTime),'99')
                                       + SUBSTRING(cDateTime,11).

            END.
        
            htFileDict  = TEMP-TABLE tFileDict :DEFAULT-BUFFER-HANDLE.
            htConfig    = TEMP-TABLE tConfig   :DEFAULT-BUFFER-HANDLE.
            hdsResponse = DATASET dsResponse:HANDLE.
                 
            oJsonResponse = NEW JsonObject().
            oJsonResponse:READ(hdsResponse).
            oJsonResponse:WRITE(lcJsonInhalt, FALSE).
// oJsonResponse:WriteFile('C:\TEMP\Dataset_loaddata_formdesigner.json', TRUE).
            LEAVE.
        END.
        
        DO WHILE cFunction = 'loaddetail':
            cConfig_id = oJsonIdent:GetCharacter('config_id').
            FIND FIRST htmldokumente NO-LOCK 
                WHERE htmldokumente.company     = ccompany
                AND   htmldokumente.user_name   = cuser_name
                AND   htmldokumente.language_id = ilanguage_id
                AND   htmldokumente.formId     = cConfig_id NO-ERROR.
                
            lcJsonInhalt    = htmldokumente.htmltext.
            lRetVal         = TRUE.
            LEAVE.
        END.
        
        DO WHILE cFunction = 'delete':
            lRetVal = FALSE.
            cConfig_id = oJsonIdent:GetCharacter('config_id').
            REPEAT TRANSACTION ON ERROR UNDO, LEAVE:
                FIND FIRST htmldokumente 
                    WHERE htmldokumente.company     = ccompany
                    AND   htmldokumente.user_name   = cuser_name
                    AND   htmldokumente.language_id = ilanguage_id
                    AND   htmldokumente.formId     = cConfig_id NO-ERROR.
                IF NOT AVAILABLE htmldokumente THEN LEAVE.
                DELETE  htmldokumente.
                lRetVal = TRUE.
                LEAVE.
            END.
            
            oJsonResponse   = NEW JsonObject().
            oJsonResponse:ADD("success", lRetVal).
            IF lRetVal THEN oJsonResponse:ADD('message', 'Konfiguration erfolreich gelöscht').
            ELSE            oJsonResponse:ADD('error'  , 'Konfiguration nicht gefunden'     ).
            oJsonResponse:write(lcJsonInhalt, FALSE).
                            
            LEAVE.
        END.
        
        IF NOT lRetVal THEN 
        DO:
            oJsonResponse = NEW JsonObject().
            oJsonResponse:ADD('success', FALSE).
            oJsonResponse:WRITE(lcJsonInhalt, FALSE).
        END.
                
        cContent-Type   = "application/json".
        cDefautlCharSet = 'utf-8'.
        oBody           = NEW STRING(lcJsonInhalt).
        WebHandlerUtilities:createHttpResponse(INPUT INTEGER(StatusCodeEnum:OK), INPUT oBody, INPUT cContent-Type, INPUT cDefautlCharSet, INPUT cCorralationID, OUTPUT oResponse).
           
        oWriter = NEW WebResponseWriter(oResponse).
        oWriter:Open(). 
        oWriter:Close(). 

        RETURN 0.
        
        CATCH e AS Progress.Lang.Error:

        END CATCH.

        FINALLY:

        END FINALLY.

    END METHOD.

    METHOD OVERRIDE PROTECTED INTEGER HandleNotAllowedMethod(INPUT poRequest AS IWebRequest):
        DEFINE VARIABLE result AS INTEGER NO-UNDO.
        MESSAGE "HandleNotAllowedMethod called" VIEW-AS ALERT-BOX.
        RETURN result.
    END METHOD.

    METHOD OVERRIDE PROTECTED INTEGER HandleNotImplemented(INPUT poRequest AS IWebRequest):
        DEFINE VARIABLE result AS INTEGER NO-UNDO.
        MESSAGE "HandleNotImplemented called" VIEW-AS ALERT-BOX.
        RETURN result.
    END METHOD.

    /*------------------------------------------------------------------------------
     Purpose:
     Notes:
    ------------------------------------------------------------------------------*/

    METHOD OVERRIDE PROTECTED INTEGER HandlePost(INPUT poRequest AS IWebRequest):
        
        DEFINE VARIABLE oResponse       AS IHttpResponse     NO-UNDO.
        DEFINE VARIABLE oWriter         AS WebResponseWriter NO-UNDO.
        DEFINE VARIABLE oJsonData       AS JsonObject        NO-UNDO.
        DEFINE VARIABLE oJsonMessage    AS JsonObject        NO-UNDO.
        DEFINE VARIABLE oFelder         AS JsonArray         NO-UNDO.
        DEFINE VARIABLE oFeld           AS JsonObject        NO-UNDO.
        
        DEFINE VARIABLE lRetVal         AS LOGICAL           NO-UNDO.
        DEFINE VARIABLE lcJsonString    AS LONGCHAR          NO-UNDO.
        DEFINE VARIABLE cJSON           AS LONGCHAR          NO-UNDO.
        DEFINE VARIABLE i1              AS INTEGER           NO-UNDO.
        DEFINE VARIABLE ii              AS INTEGER           NO-UNDO.
        DEFINE VARIABLE oJsonConfig     AS JsonObject        NO-UNDO.
        DEFINE VARIABLE oJsonFields     AS JsonArray         NO-UNDO.
        
        DEFINE VARIABLE ctables         AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE ccompany        AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cuser_name      AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE ilanguage_id    AS INTEGER           NO-UNDO.
        DEFINE VARIABLE cformtitle      AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cFormId         AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cFormColumns    AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE lcJsonConfig    AS LONGCHAR          NO-UNDO.
        DEFINE VARIABLE iItemsPerPage   AS INTEGER           NO-UNDO.
        DEFINE VARIABLE ctableMaxHeight AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE htTable         AS HANDLE            NO-UNDO.
        DEFINE VARIABLE hBuffer         AS HANDLE            NO-UNDO.
        DEFINE VARIABLE hQuery          AS HANDLE            NO-UNDO.
        DEFINE VARIABLE hField          AS HANDLE            NO-UNDO.
        DEFINE VARIABLE cFieldNames     AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cFieldName      AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cFileName       AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cField          AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cBoxfields      AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cBoxfieldsFix   AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE lBoxField       AS LOGICAL           NO-UNDO.
        DEFINE VARIABLE cLabel          AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cAlign          AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cadminLabel     AS CHARACTER         NO-UNDO.
        DEFINE VARIABLE cadminAlign     AS CHARACTER         NO-UNDO.

        lRetVal = WebHandlerUtilities:getJsonFromRequest(INPUT poRequest, OUTPUT oJsonData) NO-ERROR.
// MESSAGE 'getJsonFromRequest    = ' lRetVal.
        
        cFunction = poRequest:URI:GetQueryValue("function").
// MESSAGE 'Funktion = ' cFunction.
        
        oJsonData:WRITE(lcJsonString, FALSE).
// MESSAGE 'ganzer Eingangsstring = ' STRING(lcJsonString).
        
        outilitiesHandler = NEW utilitiesHandler().
        
        ccompany     =         oJsonData:GetCharacter('company' ).
        cuser_name   =         oJsonData:GetCharacter('user_name' ).
        ilanguage_id = INTEGER(oJsonData:GetCharacter('language_id')).
        ctables      =         oJsonData:GetCharacter('tables').
        MESSAGE ccompany '-' cuser_name '-' ilanguage_id '-' ctables.
        
        oJsonConfig     = NEW JsonObject().
        oJsonConfig     = oJsonData:GetJsonObject ('config'        ).
        cformtitle      = oJsonConfig:GetCharacter('formTitle'     ).
        cFormId         = oJsonConfig:GetCharacter('formId'        ).
        iItemsPerPage   = oJsonConfig:Getinteger  ('itemsPerPage'  ).
        ctableMaxHeight = oJsonConfig:GetCharacter('tableMaxHeight').
        cFormColumns    = oJsonConfig:GetCharacter('formColumns'   ).

        oJsonFields     = NEW JsonArray().
        oJsonFields     = oJsonConfig:GetJsonArray('selectedFields').
        oJsonConfig:WRITE(lcJsonConfig, FALSE).
        
// oJsonConfig:WriteFile('C:\TEMP\FormDesignerConfig.json', TRUE).
// oJsonFields:WriteFile('C:\TEMP\FormDesignerFields.json', TRUE).
        
        createTemptable (
            INPUT  oJsonFields,
            OUTPUT htTable    ,
            OUTPUT hBuffer    ).
        
// hBuffer:WRITE-JSON ('file', 'C:\TEMP\FeldAttributeAusFormdesigner.csv', TRUE).

        REPEAT TRANSACTION ON ERROR UNDO, LEAVE:
            FIND htmldokumente
                WHERE htmldokumente.company     = ccompany
                AND   htmldokumente.user_name   = cuser_name
                AND   htmldokumente.formId      = cFormId
                AND   htmldokumente.language_id = ilanguage_id NO-ERROR.
            IF NOT AVAILABLE htmldokumente THEN 
            DO:
                CREATE  htmldokumente.
                ASSIGN 
                    htmldokumente.company     = ccompany
                    htmldokumente.user_name   = cuser_name
                    htmldokumente.formId      = cFormId
                    htmldokumente.language_id = ilanguage_id
                    htmldokumente.created_at  = NOW.
            END.
            ASSIGN 
                htmldokumente.tables         = ctables
                htmldokumente.formtitle      = cformtitle
                htmldokumente.itemsPerPage   = iItemsPerPage
                htmldokumente.tableMaxHeight = ctableMaxHeight
                Htmldokumente.formColumns    = cFormColumns.
            htmltext = STRING(lcJsonConfig).
// MESSAGE 'htmldokument gschrieben mit config ' STRING(lcJsonConfig).
            RELEASE htmldokumente.
            LEAVE.
        END.

        cBoxfields    = ''.
        cBoxfieldsFix = ''.
        CREATE QUERY hQuery.
        hQuery:SET-BUFFERS(hBuffer).
        hQuery:QUERY-PREPARE ('FOR EACH ttTemp NO-LOCK').
        hQuery:QUERY-OPEN ().
        hQuery:GET-FIRST ().
        
        DO WHILE NOT hQuery:QUERY-OFF-END TRANSACTION:
            cFieldName = hBuffer:BUFFER-FIELD('fieldName'):BUFFER-VALUE.
            cFileName  = ENTRY(1, cFieldName, '_').
            cField     = REPLACE(cFieldName, cFileName + '_', '').
            //
            //  Standard-Label-Text für admin und table
            //
            clabel = hBuffer:BUFFER-FIELD('label'):BUFFER-VALUE.
            calign = hBuffer:BUFFER-FIELD('align'):BUFFER-VALUE.
// MESSAGE 'cFileName =' cFileName 'FieldName =' cField 'cLabel =' cLabel 'cAlign =' cAlign.
            FIND FIRST labeltexte
                WHERE labeltexte.company     = ccompany
                AND   labeltexte.user_name   = 'admin'
                AND   labeltexte.program     = 'program'
                AND   labeltexte.table_name  = 'table'
                AND   labeltexte.field_name  = cField
                AND   labeltexte.language_id = ilanguage_id NO-ERROR.
            IF NOT AVAILABLE labeltexte THEN 
            DO:
                CREATE  labeltexte.
                ASSIGN
                    labeltexte.company     = ccompany
                    labeltexte.user_name   = 'admin'
                    labeltexte.program     = 'program'
                    labeltexte.table_name  = 'table'
                    labeltexte.field_name  = cField
                    labeltexte.language_id = ilanguage_id
                    labeltexte.created_at  = NOW
                    labeltexte.sidelabel   = cLabel
                    labeltexte.headlabel   = cLabel
                    labeltexte.alignment   = cAlign.
            END.
            ELSE 
            DO:
                IF cuser_name = 'admin' THEN 
                DO:
                    ASSIGN
                        labeltexte.updated_at = NOW
                        labeltexte.sidelabel  = cLabel
                        labeltexte.headlabel  = cLabel
                        labeltexte.alignment  = cAlign.
                END.
            END.
            cadminlabel = labeltexte.headlabel.
            cadminalign = labeltexte.alignment.
            
            DO WHILE TRUE:
                IF  cLabel = cadminlabel AND
                    cAlign = cadminalign THEN LEAVE.
            
                FIND FIRST labeltexte
                    WHERE labeltexte.company     = ccompany
                    AND   labeltexte.user_name   = 'admin'
                    AND   labeltexte.program     = 'program'
                    AND   labeltexte.table_name  = cFileName
                    AND   labeltexte.field_name  = cField
                    AND   labeltexte.language_id = ilanguage_id NO-ERROR.
                IF NOT AVAILABLE labeltexte THEN 
                DO:
                    CREATE  labeltexte.
                    ASSIGN
                        labeltexte.company     = ccompany
                        labeltexte.user_name   = 'admin'
                        labeltexte.program     = 'program'
                        labeltexte.table_name  = cFileName
                        labeltexte.field_name  = cField
                        labeltexte.language_id = ilanguage_id
                        labeltexte.created_at  = NOW
                        labeltexte.sidelabel   = cLabel
                        labeltexte.headlabel   = cLabel
                        labeltexte.alignment   = cAlign.
                END.
                IF cuser_name = 'admin' THEN LEAVE.
            
                cadminlabel = labeltexte.headlabel.
                cadminalign = labeltexte.alignment.
                
                IF  cLabel = cadminlabel AND
                    cAlign = cadminalign THEN LEAVE.
                    
                FIND FIRST labeltexte
                    WHERE labeltexte.company     = ccompany
                    AND   labeltexte.user_name   = cuser_name
                    AND   labeltexte.program     = 'program'
                    AND   labeltexte.table_name  = cFileName
                    AND   labeltexte.field_name  = cField
                    AND   labeltexte.language_id = ilanguage_id NO-ERROR.
                IF NOT AVAILABLE labeltexte THEN 
                DO:
                    CREATE  labeltexte.
                    ASSIGN
                        labeltexte.company     = ccompany
                        labeltexte.user_name   = cuser_name
                        labeltexte.program     = 'program'
                        labeltexte.table_name  = cFileName
                        labeltexte.field_name  = cField
                        labeltexte.language_id = ilanguage_id
                        labeltexte.created_at  = NOW.
                END.
                ELSE 
                DO:
                    ASSIGN                             
                        labeltexte.updated_at = NOW.
                END.

                ASSIGN 
                    labeltexte.sidelabel = hBuffer:BUFFER-FIELD('label'):BUFFER-VALUE
                    labeltexte.headlabel = hBuffer:BUFFER-FIELD('label'):BUFFER-VALUE
                    labeltexte.alignment = hBuffer:BUFFER-FIELD('align'):BUFFER-VALUE.
                
                LEAVE.
            END.
            RELEASE labeltexte.
                
            
            hField = hBuffer:BUFFER-FIELD('id'):HANDLE NO-ERROR.
            IF hField:BUFFER-VALUE = 'addresses_salutation_code' THEN 
            DO:
                hField = hBuffer:BUFFER-FIELD('type'):HANDLE.
// MESSAGE 'addresses_salutation_code type' hField:BUFFER-VALUE.
                hField = hBuffer:BUFFER-FIELD('selectOptionsType'):HANDLE NO-ERROR.
// MESSAGE 'addresses_salutation_code selectOptionsType =' hField:BUFFER-VALUE.
            END.

            lBoxField = (IF hBuffer:BUFFER-FIELD('type'):BUFFER-VALUE = 'select' THEN TRUE ELSE FALSE).
            DO WHILE lBoxField: 
                hField = hBuffer:BUFFER-FIELD('selectOptionsType'):HANDLE NO-ERROR.
// IF outilitiesHandler:evaluateErrorStatus(ERROR-STATUS:HANDLE) THEN LEAVE.
// MESSAGE 'Selectboxfeld ->' hField:NAME '-' hField:BUFFER-VALUE.
                IF VALID-HANDLE(hField) AND hField:BUFFER-VALUE BEGINS 'variable' THEN
                    cBoxFields = cBoxfields
                        + (IF cBoxfields = '' THEN '' ELSE ';')
                        + hBuffer:BUFFER-FIELD('fieldName'):BUFFER-VALUE.
                ELSE 
                    cBoxFieldsFix = cBoxfieldsFix
                        + (IF cBoxfieldsFix = '' THEN '' ELSE ';')
                        + hBuffer:BUFFER-FIELD('fieldName'):BUFFER-VALUE.
// MESSAGE 'Feldname =' hBuffer:BUFFER-FIELD('fieldName'):BUFFER-VALUE VALID-HANDLE(hField).
                LEAVE.
            END.

            hQuery:GET-NEXT ().
        END. 

        IF  cBoxfields    <> '' OR
            cBoxFieldsFix <> '' THEN 
        DO:
            REPEAT TRANSACTION ON ERROR UNDO, LEAVE:
                FIND FIRST selectboxfields
                    WHERE selectboxfields.company   = ccompany
                    AND   selectboxfields.program   = cFormId
                    AND   selectboxfields.user_name = cuser_name
                    AND   selectboxfields.table_Name = 'table' NO-ERROR.
                IF NOT AVAILABLE selectboxfields THEN 
                DO:
                    CREATE  selectboxfields.
                    ASSIGN
                        selectboxfields.company    = ccompany
                        selectboxfields.program    = cFormId
                        selectboxfields.user_name  = cuser_name
                        selectboxfields.table_Name = 'table'.
                END.
                ASSIGN 
                    selectboxfields.boxfields    = cBoxFields
                    selectboxfields.boxfieldsFix = cBoxfieldsFix.
                RELEASE selectboxfields.
                LEAVE.
            END.
        END. 
        
// MESSAGE 'geschrieben ' ccompany '-' cuser_name '-' cFormId '-' ilanguage_id.
            
        oResponse             = NEW OpenEdge.Web.WebResponse().
        oResponse:StatusCode  = INTEGER(StatusCodeEnum:OK).
        oResponse:ContentType = "application/json;charset=utf-8".
        oWriter               = NEW WebResponseWriter(oResponse).
        
        oJsonMessage = NEW JsonObject().
        oJsonMessage:ADD('id', cFormId).
        oJsonMessage:ADD('message', 'erfolgreich gespeichert').
        oJsonMessage:WRITE(lcJsonString, TRUE).
// MESSAGE 'Rueckmeldung ' STRING(lcJsonString).
            
        oWriter:Open().
        oWriter:Write(lcJsonString).
        oWriter:Close().

        CATCH e AS Progress.Lang.Error:

        END CATCH.

        FINALLY:
        /*            DELETE OBJECT oJsonConfig  NO-ERROR.*/
        /*            DELETE OBJECT oJsonMessage NO-ERROR.*/
        /*            DELETE OBJECT oJsonFields  NO-ERROR.*/
        END FINALLY.

    END METHOD.

END CLASS.