Skip to Content
0
Former Member
Feb 07, 2011 at 09:04 PM

Unable to call BRFPlus function from ABAP with workbench closed

86 Views

I have used the BRFPlus workbench to develop a simple decision table function. I've also written ABAP function modules to call the BRFPlus function, one using the static method and the other using the instance method.

Both methods will return a result into export parameter 'RULE' as long as the workbench is open and running, but once I close the workbench, any attempted function call produces a short dump raising exception CX_FDT_GEN_ERROR. Has anyone seen an error like this before?

Static method:

  DATA: 
        lv_id            TYPE if_fdt_types=>id,
        lt_context_value TYPE abap_parmbind_tab,
        ls_context_value TYPE abap_parmbind.

  FIELD-SYMBOLS <ls_message> TYPE if_fdt_types=>s_message.

  lv_id = '4D4C0FD924043229E10000000A5C08AA'.

* Add TYPE to context value table
  IF type IS SUPPLIED.
    ls_context_value-name = 'TYPE'.
    CREATE DATA ls_context_value-value TYPE z_de_type.
    FIELD-SYMBOLS <field_symbol00001>  TYPE z_de_type.

    ASSIGN ls_context_value-value->* TO <field_symbol00001>.
    <field_symbol00001> = type.

    INSERT ls_context_value INTO TABLE lt_context_value.
  ENDIF.

* Add CATEGORY  to context value table
  IF category IS SUPPLIED.
    ls_context_value-name = 'CATEGORY'.
    CREATE DATA ls_context_value-value TYPE z_de_category.
    FIELD-SYMBOLS <field_symbol00002>  TYPE z_de_category.

    ASSIGN ls_context_value-value->* TO <field_symbol00002>.
    <field_symbol00002> = category.

    INSERT ls_context_value INTO TABLE lt_context_value.
  ENDIF.

  TRY.
      CALL METHOD cl_fdt_function_process=>process
        EXPORTING
          iv_function_id = lv_id
        IMPORTING
          ea_result      = rule
        CHANGING
          ct_name_value  = lt_context_value.

    CATCH cx_fdt.
      MESSAGE   e041(sfdt_code_composer) RAISING cx_fdt.

  ENDTRY.

Instance method:

  DATA:
    lo_factory TYPE REF TO if_fdt_factory,
    lo_function TYPE REF TO if_fdt_function,
    lv_function TYPE if_fdt_types=>id,
    lo_context TYPE REF TO if_fdt_context,
    lo_result TYPE REF TO if_fdt_result,
    lv_result TYPE string.

  lv_function = '4D4C0FD924043229E10000000A5C08AA'.

  lo_factory =
    cl_fdt_factory=>if_fdt_factory~get_instance(
       iv_application_id = '4D4C0FA624043229E10000000A5C08AA' ).

  lo_function = lo_factory->get_function( iv_id = lv_function ).

  lo_context  = lo_function->get_process_context( ).
  lo_context->set_value( iv_name =: 'TYPE'     ia_value = type ).
  lo_context->set_value( iv_name =: 'CATEGORY' ia_value = category  ).

  lo_function->process( EXPORTING io_context = lo_context
                        IMPORTING eo_result  = lo_result ).

  lo_result->get_value( IMPORTING ea_value = lv_result ).

  rule = lv_result.