cancel
Showing results for 
Search instead for 
Did you mean: 

Output in ABAP from BRF+

former_member198721
Participant
0 Kudos

Hi,

I have created a BRFplus function and added the code for same.

but sometimes output comes and sometimes it does not.

Whenever i make any change in my ABAP code , i need to goto BRFplus function , have to make a change there and activate it .

Then only output comes in lo_result  w_t.

below ABAP code is added.

-----------------------------------------------------------------------------------

DATA: lo_function TYPE REF TO if_fdt_function,

         lo_context  TYPE REF TO if_fdt_context,

         lo_result   TYPE REF TO if_fdt_result,

         e_wa_dref   TYPE REF TO data,

         lx_fdt      TYPE REF TO cx_fdt.

   DATA: lo_message TYPE REF TO cx_fdt.

   FIELD-SYMBOLS: <fs_any>     TYPE any,

                  <fs_is_final> TYPE STANDARD TABLE,

                  <fs_message> TYPE if_fdt_types=>s_message.

   DATA: ls_werks    TYPE if_fdt_types=>element_text,

         ls_matnr    TYPE if_fdt_types=>element_text,

         ls_statm    TYPE if_fdt_types=>element_text,

         ls_grp      TYPE if_fdt_types=>element_boolean,

         w_t         TYPE REF TO data.

   FIELD-SYMBOLS : <d_ref>  TYPE ANY TABLE,

                   <d_ref1> TYPE zctde.

   CLEAR : ls_werks,

           ls_matnr,

           ls_statm,

           ls_grp.

   MOVE : inp_data-werks TO ls_werks,

          inp_data-matnr TO ls_matnr,

          'X'     TO ls_statm.

   TRY.

*"GET BRFPlus Function

       lo_function ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function('001E0B8362C21ED39FCE26B763418104').

*" set BRFlus function context(Input variable)

       lo_context = lo_function->get_process_context( ).

       lo_context->set_value( iv_name = 'MATNR' ia_value = ls_matnr ).

*      lo_context->set_value( iv_name = 'MAT_GRP_CHECK' ia_value = ls_grp ).

       lo_context->set_value( iv_name = 'STATM' ia_value = ls_statm ).

       lo_context->set_value( iv_name = 'WERKS' ia_value = ls_werks ).

* " Process the BRFplus function

       lo_function->process( EXPORTING io_context    =  lo_context

                             IMPORTING eo_result     =  lo_result ).

       CREATE DATA w_t TYPE STANDARD TABLE OF zctde.

       ASSIGN w_t->* TO <d_ref>.

       lo_result->get_value( IMPORTING er_value = w_t ).

       lo_result->get_value( IMPORTING ea_value = <d_ref> ).

   CATCH cx_fdt INTO lx_fdt.

   ENDTRY.

-------------------------------------------------------

Kindly suggest is that i need to do every time or there is some issue with my Code?

Regards,

Khushbu

Accepted Solutions (1)

Accepted Solutions (1)

anindyaSAP
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello All,

For this particular issue there was a code bug in a part of generated code of decision table. The issue was solved in note 1669944. I have suggested this note in the OSS message raised for this issue. Still waiting for a confirmation on whether the issue is resolved.

Thanks,

Anindya

former_member198721
Participant
0 Kudos

Hello Anindya,

Issue is resolved after implementing this note and running the FDT_GENERATION_TOOL  with function name.

Thanks for your valuable reply.

Regards,

khushbu

Answers (1)

Answers (1)

anbusivam_s
Participant
0 Kudos

I have already replied the reason in another post. Kindly see that. Also seeing at the code for passing context values kindly use name value or id value pair as input which will be better performance wise. You can use the report FDT_TEMPLATE_FUNCTION_PROCESS to get the code template for your calling your BRF+ function which is already optimized performance wise. You just need to fill out the portion where you need to pass value.

former_member198721
Participant
0 Kudos

Hi Anubusivam,

As suggested by you we have implemented SAP note 1912092 in out box but still our issue is not resolved.

issue is:

We have many brf functions with the output as a table

----------------------------------------------------------------------------

Function 1.

Input parameters: Matnr (element)

                               Mat_grp_check (element(boolean))

                               Statm (element)

                               Werks (element)

Ouptut: Z_ZCTDE (table)

---------------------------------------------------------------------------

Now i have called this function in ABAP as below

-----------------------------------------------------------------------------

DATA: lo_function TYPE REF TO if_fdt_function,

           lo_context  TYPE REF TO if_fdt_context,

           lo_result   TYPE REF TO if_fdt_result,

           e_wa_dref   TYPE REF TO data,

           lx_fdt      TYPE REF TO cx_fdt.

   DATA: lo_message TYPE REF TO cx_fdt.

   FIELD-SYMBOLS: <fs_any>     TYPE any,

                  <fs_is_final> TYPE STANDARD TABLE,

                  <fs_message> TYPE if_fdt_types=>s_message.

   DATA: ls_werks    TYPE if_fdt_types=>element_text,

         ls_matnr    TYPE if_fdt_types=>element_text,

         ls_statm    TYPE if_fdt_types=>element_text,

         ls_grp      TYPE if_fdt_types=>element_boolean,

         w_t         TYPE REF TO data.

   FIELD-SYMBOLS : <d_ref>  TYPE ANY TABLE,

                   <d_ref1> TYPE zctde.

   CLEAR : ls_werks,

           ls_matnr,

           ls_statm,

           ls_grp.

   MOVE : inp_data-werks TO ls_werks,

          inp_data-matnr TO ls_matnr,

          'X'     TO ls_statm.

   TRY.

*"GET BRFPlus Function

       lo_function ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function('001E0B8362C21ED39FCE26B763418104').

*" set BRFlus function context(Input variable)

       lo_context = lo_function->get_process_context( ).

       lo_context->set_value( iv_name = 'MATNR' ia_value = ls_matnr ).

       lo_context->set_value( iv_name = 'STATM' ia_value = ls_statm ).

       lo_context->set_value( iv_name = 'WERKS' ia_value = ls_werks ).

* " Process the BRFplus function

       lo_function->process( EXPORTING io_context    =  lo_context

                             IMPORTING eo_result     =  lo_result ).

       CREATE DATA w_t TYPE STANDARD TABLE OF zctde.

       ASSIGN w_t->* TO <d_ref>.

       lo_result->get_value( IMPORTING er_value = w_t ).

       lo_result->get_value( IMPORTING ea_value = <d_ref> ).

     CATCH cx_fdt INTO lx_fdt.

   ENDTRY.

       lo_function ?= cl_fdt_factory=>if_fdt_factory~get_instance( )->get_function('001E0B8362C21ED39FCE26B763418104').

*" set BRFlus function context(Input variable)

       lo_context = lo_function->get_process_context( ).

       lo_context->set_value( iv_name = 'MATNR' ia_value = ls_matnr ).

       lo_context->set_value( iv_name = 'STATM' ia_value = ls_statm ).

       lo_context->set_value( iv_name = 'WERKS' ia_value = ls_werks ).

* " Process the BRFplus function

       lo_function->process( EXPORTING io_context    =  lo_context

                             IMPORTING eo_result     =  lo_result ).

       CREATE DATA w_t TYPE STANDARD TABLE OF zctde.

       ASSIGN w_t->* TO <d_ref>.

       lo_result->get_value( IMPORTING er_value = w_t ).

       lo_result->get_value( IMPORTING ea_value = <d_ref> ).

     CATCH cx_fdt INTO lx_fdt.

   ENDTRY.

------------------------------------------------------------------------------------------

Now what is happening , the moment i created the BRF function and added the code and executed the porgram then after the execution of  RED highlighted statement , one entry is coming in W_T

I have attached the screenshot of the debugger with the name sucess_run.


But in case i create some other function or test some other function in BRF or i execute the program on next day or after few hours , then the output does not come in the table.


I have noticed one more thing that there is a tab of CODE GERENATION, and it gets cleared whenever i make any change in the function.


For example i have another function and coded in the same way as mentioned above , for that this code generation tab is filled and screensot is attached.


And while i execute this function i could not see any output. but the moment i go and make any change in the BRF function , i can see the output and this tab also get cleared.


And in some cases previous function get stopped working and the recently changed  function only gives the output.


Kindly suggest what is the solution for this problem as the note is already implemented.

Regards,

Khushbu Agarwal

carsten_ziegler
Active Contributor
0 Kudos

Pls try other call with CL_FDT_FUNCTION_PROCESS.

You may use program FDT_TEMPLATE_FUNCTION_PROCESS to generate the code for you. Alternatively you can find the functionality also on the function UI in the BRFplus workbench (>=NW 731).

Former Member
0 Kudos

Hi Carsten,

thank you for your responce.

I have the exactly same issue. However, your proposal is not really a solution. By using the static call the whole ABAP <-> BRF+ data element conversion should be then processed on my side.

That means instead of 10 lines of code (with instance call) it becomes more than 150 lines (static call; example provided by your report).

And this is not really usefull? I am trying to push BRF+ in our project and if I would suggest it, they would directly tag me as insane 😉

I have analysed the issue: the context is always filled correctly after processing. However based on internal value of processing state: mv_simple_state the context is provided correctly or not. (different methods are called)

From my opinion the BRF+ generated class is somehow not correct. Here is the screenshot. The case is somehow not obvious. The underscore before the name makes the problem.

On a newer internal system, there is no such problem and the name in case is also correct. Please compare the second screenshot (in green).

Probably there is a note for it, however I did not found it. The system with the issue is not the newest one (see screenshot System). Do you have an idea.

I hope this helps you, since it seems to be common issue. And with a proper note many things would be solved.

Thanks a lot and best regards,

Rajiv

Former Member
0 Kudos

Hello together,

maybe I have a solution for this issue. I found a quite old note, which is a manual one.

1613448

The reason for problems seems to be the namespace of context elements. Now I have generated new function where context elements do not have namespace and for first testings it seems to work.

Maybe it could also work for other ones.

BR

Rajiv

former_member198721
Participant
0 Kudos

Hi Rajiv,

It seems that finally we got the solution,

Can you share the code which you are using for calling BRF function?

Regards,

Khushbu

Former Member
0 Kudos

Hi Knushbu,

that would be great. Here is the instance call.

Can you provide some feedback? However, for me it seems to be solved (without namespace in context names).

Thanks.

BR

Rajiv

former_member198721
Participant
0 Kudos

Hi Rajiv,

the definition of my BRF function is attached with the name BRF_FUNC,

here result data object is selected as a table ZCTDS_OUTPUT.

Now , for calling this function i have added ABAP code as provided by you.

Basically i have changed below code

  lo_function->process( EXPORTING io_context    =  lo_context

                             IMPORTING eo_result     =  lo_result ).

CREATE DATA w_t TYPE STANDARD TABLE OF zctds.

       ASSIGN w_t->* TO <d_ref>.

       lo_result->get_value(

       EXPORTING

         iv_name = 'ZCTDS_OUTPUT'

       IMPORTING er_value = w_t ).

       lo_result->get_value(

        EXPORTING

         iv_name = 'ZCTDS_OUTPUT'

       IMPORTING ea_value = <d_ref> ).

but i am getting exception that ZCTDS_OUTPUT is not in context .

i have check LO_RESULT , and there is no object under attribute MTS_DATA_OBJECT.

But when i go and change anything in the BRFfunction, i can see the object in MTS_DATA_OBJECT.

Former Member
0 Kudos

Hi Khushubu,

hmm. In my case the function is in Event Mode and for this reason I am using the lo_context and not the lo_result.

I had also the same issue like you (after changing the BRF+ Function everything worked). However, I was always able to see my data in table MTS_DATA_OBJECT.

Does you ZCTDS_OUTPUT have currency or amount fields? Since there always an internal conversion occurs. Maybe this is a possible reason.

At current state I do not have more hints for you. Sorry.

Maybe Carsten will have an idea.

BR

Rajiv

former_member198721
Participant
0 Kudos

hi Rajiv,

My function is also an event mode function, i dont have nay currency or amount field.

i ahve taken screenshot of MTS_DATA_OBJECT before and after making change,

also there is one tab in BRFplus named as code generation, that also get changed.

Former Member
0 Kudos

Hi Khushbu,

Some facts upfront:

1. If you activate a function, the generated class is deleted (since it is not "correct" anymore

2. Next time when you call this Function the next class is generated,

EXCEPT you are locking this function by being in BRF+ Workbench in edit mode.

Then this function is executed in interpreter mode (is slower). For this reason you have probably seen different effects(after activation it worked, since in interpreter mode).

Following hint from my side, I have just cheked you coe once more. Try to call lo_result->get_value without the value id/name. Only with importing parameter.

Maybe it solves your problem. Please provide feedback 😉

BR

Rajiv