1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

How to pass parameters to a Progress program using database field dynamic-based rules?

Discussão em 'StackOverflow' iniciado por fdantas, Maio 4, 2015.

  1. fdantas

    fdantas Administrator Moderador

    I have in my database a set of records that concentrates information about my .W's, e.g. window name, parent directory, file name, procedure type (for internal treatments purposes), used to build my main menu. With this data I'm developing a new start procedure for the ERP that I maintain and using the opportunity in order to rewrite some really outdated functions and programs and implement new functionalities. Until now, I hadn't any problems but when I started to develop the .P procedure which will check the database register of a program that was called from the menu of this new start procedure - to check if it needs to receive fixed parameters to be run and its data types - I found a problem that I can't figure out a solution.

    In this table, I have stored in one of the fields the parameters needed by the program, each with his correspondent data type. The problem is on how to pass different data types to procedures based only on the stored data. I tried to pre-convert data using a CASE clause and an include to check the parameter field for correct parameter sending but the include doesn't work as I've expected.

    My database field is stored as this:

    Description | DATATYPE | Content


    I've declared some variables and converted properly the stored data into their correct datatype vars.

    DEF VAR c-param-exec AS CHAR NO-UNDO EXTENT 9 INIT ?.
    DEF VAR i-param-exec AS INT NO-UNDO EXTENT 9 INIT ?.
    DEF VAR de-param-exec AS DEC NO-UNDO EXTENT 9 INIT ?.
    DEF VAR da-param-exec AS DATE NO-UNDO EXTENT 9 INIT ?.
    DEF VAR l-param-exec AS LOG NO-UNDO EXTENT 9 INIT ?.
    DEF VAR i-count AS INT NO-UNDO.

    blk-count:
    DO i-count = 0 TO 8:
    IF TRIM(programa.parametro[i-count]) = '' THEN
    LEAVE blk-count.
    i-count = i-count + 1.

    CASE ENTRY(2,programa.parametro[i-count],CHR(1)):
    WHEN 'CHARACTER' THEN
    c-param-exec[i-count] = ENTRY(3,programa.parametro[i-count],CHR(1)).
    WHEN 'INTEGER' THEN
    i-param-exec[i-count] = INT(ENTRY(3,programa.parametro[i-count],CHR(1))).
    WHEN 'DECIMAL' THEN
    de-param-exec[i-count] = DEC(ENTRY(3,programa.parametro[i-count],CHR(1))).
    WHEN 'DATE' THEN
    da-param-exec[i-count] = DATE(ENTRY(3,programa.parametro[i-count],CHR(1))).
    WHEN 'LOGICAL' THEN
    l-param-exec[i-count] = (ENTRY(3,programa.parametro[i-count],CHR(1)) = 'yes').
    OTHERWISE
    c-param-exec[i-count] = ENTRY(3,programa.parametro[i-count],CHR(1)).
    END CASE.

    END.


    Then I tried to run the program using an include to pass parameters (in this example, the program have 3 INPUT parameters).

    RUN VALUE(c-prog-exec) ({util\abrePrograma.i 1},
    {util\abrePrograma.i 2},
    {util\abrePrograma.i 3}).


    Here is my abrePrograma.i

    /* abrePrograma.i */

    (IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'CHARACTER' THEN c-param-exec[{1}] ELSE
    IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'INTEGER' THEN i-param-exec[{1}] ELSE
    IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'DECIMAL' THEN de-param-exec[{1}] ELSE
    IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'DATE' THEN da-param-exec[{1}] ELSE
    IF ENTRY(2,programa.parametro[{1}],CHR(1)) = 'LOGICAL' THEN l-param-exec[{1}] ELSE
    c-param-exec[{1}])


    If I suppress the 2nd, 3rd, 4th and 5th IF's from the include or use only one data type in all IF's (e.g. only CHAR, only DATE, etc.) the program works properly and executes like a charm but I need to call some old programs, which expects different datatypes in its INPUT parameters and using the programs as described OpenEdge doesn't compile the caller, triggering the error number 223.

    ---------------------------
    Erro (Press HELP to view stack trace)
    ---------------------------
    ** Tipos de dados imcompativeis em expressao ou atribuicao. (223)
    ** Nao entendi a linha 86. (196)
    ---------------------------
    OK Ajuda
    ---------------------------


    Can anyone help me with this ? Thanks in advance.

    Continue reading...

Compartilhe esta Página