cancel
Showing results for 
Search instead for 
Did you mean: 

Modification in the Application code generated by FDT_TEMPLATE_FUNCTION_PROCESS

Former Member
0 Kudos


Hi All,

I have created a BRFPLUS application in BRFPLUS workbench which is a flight booking application as per

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.nw.wpc.runtime.docs/media/streamingmedia/de...

.Then generated the code using the standard report FDT_TEMPLATE_FUNCTION_PROCESS by providing input as the function GUID generated in the BRFPLUS application.In the function the field Customer is the only text field while the other fields like S_CARR_ID,S_DATE,S_FROM-CIT,S_TO_CITY come from table SFLIGHT.

The code generated by the report is FDT_TEMPLATE_FUNCTION_PROCESS is mentioned below.When I try to run the code as it is,no outpur is there.What changes do I need to make in this code.Please guide me

*************************************************************************************************************************************************************

CONSTANTS:lv_function_id TYPE if_fdt_types=>id VALUE '005056910DEC1ED3BDB7813B113B70DB'.

DATA:lv_timestamp TYPE timestamp,

      lt_name_value TYPE abap_parmbind_tab,

      ls_name_value TYPE abap_parmbind,

      lr_data TYPE REF TO data,

      lt_message TYPE if_fdt_types=>t_message,

      lx_fdt TYPE REF TO cx_fdt,

      la_customer TYPE if_fdt_types=>element_text,

      la_s_carr_id TYPE if_fdt_types=>element_text,

      la_s_date TYPE if_fdt_types=>element_timepoint,

      la_s_from_cit TYPE if_fdt_types=>element_text,

      la_s_to_city TYPE if_fdt_types=>element_text.

FIELD-SYMBOLS <la_any> TYPE any.

***************************************************************************************************

All method calls within one processing cycle calling the same function must use the same timestamp.

For subsequent calls of the same function, we recommend to use the same timestamp for all calls.

This is to improve the system performance.

***************************************************************************************************

If you are using structures or tables without DDIC binding, you have to declare the respective types

by yourself. Insert the according data type at the respective source code line.

***************************************************************************************************

GET TIME STAMP FIELD lv_timestamp.

***************************************************************************************************

Process a function without recording trace data, passing context data objects via a name/value table.

***************************************************************************************************

Prepare function processing:

***************************************************************************************************

ls_name_value-name = 'CUSTOMER'.

la_CUSTOMER = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_CUSTOMER INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.

***************************************************************************************************

ls_name_value-name = 'S_CARR_ID'.

la_S_CARR_ID = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_S_CARR_ID INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.

***************************************************************************************************

****************************************************************************************************

* Let BRFplus convert your data into the type BRFplus requires:

* Data object is bound to a DDIC type, so you can improve performance by passing a variable of that type.

* If you pass a variable of this type, you should indicate this by passing "abap_true" for parameter "iv_has_ddic_binding".

****************************************************************************************************

ls_name_value-name = 'S_DATE'.

Available timepoint types:

IF_FDT_CONSTANTS=>GC_TP_DATE   IF_FDT_CONSTANTS=>GC_TP_TIME

IF_FDT_CONSTANTS=>GC_TP_DATETIME   IF_FDT_CONSTANTS=>GC_TP_TIMESTAMP_UTC

la_S_DATE-type = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

la_S_DATE-date = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].

la_S_DATE-time = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].

la_S_DATE-timestamp = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].

GET REFERENCE OF la_S_DATE INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.

**************************************************************************************************

ls_name_value-name = 'S_FROM_CIT'.

la_S_FROM_CIT = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_S_FROM_CIT INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.

**************************************************************************************************

ls_name_value-name = 'S_TO_CITY'.

la_S_TO_CITY = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_S_TO_CITY INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.

**************************************************************************************************

Create the data to store the result value after processing the function

You can skip the following call, if you already have

a variable for the result. Please replace also the parameter

EA_RESULT in the method call CL_FDT_FUNCTION_PROCESS=>PROCESS

with the desired variable.

**************************************************************************************************

cl_fdt_function_process=>get_data_object_reference( EXPORTING iv_function_id      = lv_function_id

                                                               iv_data_object      = '_V_RESULT'

                                                               iv_timestamp        = lv_timestamp

                                                               iv_trace_generation = abap_false

                                                     IMPORTING er_data             = lr_data ).

ASSIGN lr_data->* TO <la_any>.

TRY.

     cl_fdt_function_process=>process( EXPORTING iv_function_id = lv_function_id

                                                 iv_timestamp   = lv_timestamp

                                       IMPORTING ea_result      = <la_any>

                                       CHANGING  ct_name_value  = lt_name_value ).

     CATCH cx_fdt into lx_fdt.

****************************************************************************************************

* You can check CX_FDT->MT_MESSAGE for error handling.

****************************************************************************************************

  ENDTRY.

Thanks in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

ttrapp
Active Contributor
0 Kudos

The result is in field symbol <la_any>. So at the first take the debugger and look at the content. Then you can use WRITE statements for output.

Former Member
0 Kudos

Hi Tobias,

Thanks for the reply.

THis is the generated code from the standard report FDT_TEMPLATE_FUNCTION_PROCES.

Can you please suggest me the code by modfying the same?

THe fields are

Customer - its a string

S_CARRID,S_DATE,S_FROM_CIT,S_TO_CITY all these fiels coming from standard SAP tables.

I tried the codes in the end at the demo that I am using

BRFplus_App_Example_demo

But its not working

Tried another which is at the end of the presentation

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70384d29-b06c-2d10-a583-e7cc8a7d7...

Can you please help me modifying the codes mentioned in the above link to suite my requirement?

Thanks in advance

Former Member
0 Kudos

Hi All,

Tried with this code too,but not working.

Can you please help me make it run?

DATA:lo_admin_data TYPE REF TO if_fdt_admin_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,

      lx_fdt TYPE REF TO cx_fdt,

      S_CARRID TYPE SPFLI-CARRID,

      S_DATE TYPE SFLIGHT-FLDATE,

      S_FROM_CIT TYPE SPFLI-CITYFROM,

      S_CITY_TO TYPE SPFLI-CITYTO,

      lv_discount TYPE if_fdt_types=>element_number.

cl_fdt_factory=>get_instance_generic( EXPORTING iv_id = '005056910DEC1ED3BDB7813B113B70DB'

                                      IMPORTING eo_instance = lo_admin_data ).
lo_function ?= lo_admin_data.
l_sflight_node = wd_context->get_child_node( 'SFLIGHT' ).

loop at lt_sflight ASSIGNING <fs_sflight>.
  CLEAR lv_discount.
lo_context ?= lo_function->get_process_context( ) .

  lo_context->set_value( iv_name = 'CUSTOMER' ia_value = sy-uname ).

  lo_context->set_value( iv_name = 'S_DATE' ia_value = <fs_sflight>-fldate ).

  lo_context->set_value( iv_name = ' S_CARR_ID' ia_value = <fs_sflight>-carrid ).

  lo_context->set_value( iv_name = 'S_FROM_CIT' ia_value = l_cityfrom ).

    lo_context->set_value( iv_name = ' S_CITY_TO' ia_value = l_cityto ).
    TRY.

      lo_function->process( EXPORTING io_context = lo_context

                            IMPORTING eo_result  = lo_result ).

      lo_result->get_value( IMPORTING ea_value   = lv_discount ).
      CATCH cx_fdt INTO lx_fdt.
          ENDTRY.
  
        <fs_sflight>-price = <fs_sflight>-price - <fs_sflight>-price * lv_discount.

ttrapp
Active Contributor
0 Kudos

Are you sure that you didn't introduce further errors?

lo_context->set_value( iv_name = 'S_FROM_CIT' ia_value = l_cityfrom ).

Is it possible that S_FROM_CITY is correct?

By the way: I don't understand what you are doing. Why are you modifying the input parameters (context) if you want to display the result?

Former Member
0 Kudos

Hi Tobias,

I am implemting the application as per this demo

http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/com.sap.nw.wpc.runtime.docs/media/streamingmedia/de...

Its a flight booking demo.I am done with application creation in BRFPLUS workbench.The next step is to call the application in the application code.

I tired it 2 ways

1.Used the standard report FDT_TEMPLATE_FUNCTION_PROCESS to generate code which I pasted in one of the above posts but could not get what to modify in it so that it will work.

2.Tried with the code that could be visible,though may not be complete code in the demo whose URL I have mentioned above.The code that was visible in the demo is

DATA:lo_admin_data TYPE REF TO if_fdt_admin_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,

      lx_fdt TYPE REF TO cx_fdt,

      S_CARRID TYPE SPFLI-CARRID,

      S_DATE TYPE SFLIGHT-FLDATE,

      S_FROM_CIT TYPE SPFLI-CITYFROM,

      S_CITY_TO TYPE SPFLI-CITYTO,

      lv_discount TYPE if_fdt_types=>element_number.

cl_fdt_factory=>get_instance_generic( EXPORTING iv_id = '005056910DEC1ED3BDB7813B113B70DB'

                                      IMPORTING eo_instance = lo_admin_data ).
lo_function ?= lo_admin_data.
l_sflight_node = wd_context->get_child_node( 'SFLIGHT' ).

loop at lt_sflight ASSIGNING <fs_sflight>.
  CLEAR lv_discount.
lo_context ?= lo_function->get_process_context( ) .

  lo_context->set_value( iv_name = 'CUSTOMER' ia_value = sy-uname ).

  lo_context->set_value( iv_name = 'S_DATE' ia_value = <fs_sflight>-fldate ).

  lo_context->set_value( iv_name = ' S_CARR_ID' ia_value = <fs_sflight>-carrid ).

  lo_context->set_value( iv_name = 'S_FROM_CIT' ia_value = l_cityfrom ).

    lo_context->set_value( iv_name = ' S_CITY_TO' ia_value = l_cityto ).
    TRY.

      lo_function->process( EXPORTING io_context = lo_context

                            IMPORTING eo_result  = lo_result ).

      lo_result->get_value( IMPORTING ea_value   = lv_discount ).
      CATCH cx_fdt INTO lx_fdt.
          ENDTRY.
  
        <fs_sflight>-price = <fs_sflight>-price - <fs_sflight>-price * lv_discount

What should be modified in this code to make it work?Or can you please suggest me a piece of code that can be used for this demo?

Thanks in advance.

Former Member
0 Kudos


Hi ,

Can you please tell me how can this code be used

DATA: ls_name_value TYPE abap_parmbind,

lt_name_value TYPE abap_parmbind_tab,

gv_customer TYPE if_fdt_types=>element_text,

gv_item TYPE if_fdt_types=>element_text,

gv_price_in_eur TYPE if_fdt_types=>element_number,

gv_promotion TYPE if_fdt_types=>element_text,

gv_final_price_in_eur TYPE if_fdt_types=>element_number.

ls_name_value-name = 'CUSTOMER'.

GET REFERENCE OF gv_customer INTO ls_name_value-value.

INSERT ls_name_value INTO TABLE lt_name_value.

ls_name_value-name = 'ITEM'.

GET REFERENCE OF gv_item INTO ls_name_value-value.

INSERT ls_name_value INTO TABLE lt_name_value.

ls_name_value-name = 'PRICE_IN_EUR'.

GET REFERENCE OF gv_price_in_eur INTO ls_name_value-value.

INSERT ls_name_value INTO TABLE lt_name_value.

ls_name_value-name = 'PROMOTION'.

GET REFERENCE OF gv_promotion INTO ls_name_value-value.

INSERT ls_name_value INTO TABLE lt_name_value.

TRY.

cl_fdt_function_process=>process(

EXPORTING iv_function_id = gv_function_id

iv_timestamp = gv_timestamp

IMPORTING ea_result = gv_final_price_in_eur

CHANGING ct_name_value = lt_name_value ).

CATCH cx_fdt .

ENDTRY.

Former Member
0 Kudos

Hi All,

I derived one code which is not giving error

CONSTANTS:lv_function_id TYPE if_fdt_types=>id VALUE '005056910DEC1ED3BDB7813B113B70DB'.

DATA:lv_timestamp TYPE timestamp,

      lt_name_value TYPE abap_parmbind_tab,

      ls_name_value TYPE abap_parmbind,

      lr_data TYPE REF TO data,

      lt_message TYPE if_fdt_types=>t_message,

      lx_fdt TYPE REF TO cx_fdt,

      la_customer TYPE if_fdt_types=>element_text,

      la_s_carr_id TYPE if_fdt_types=>element_text,

      la_s_date TYPE if_fdt_types=>element_timepoint,

      la_s_from_cit TYPE if_fdt_types=>element_text,

      la_s_to_city TYPE if_fdt_types=>element_text.

FIELD-SYMBOLS <la_any> TYPE any.



ls_name_value-name = 'CUSTOMER'.

* la_CUSTOMER = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_CUSTOMER INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.



ls_name_value-name = 'S_CARR_ID'.

* GET REFERENCE OF la_S_CARR_ID INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.



ls_name_value-name = 'S_DATE'.

*Available timepoint types:

*IF_FDT_CONSTANTS=>GC_TP_DATE   IF_FDT_CONSTANTS=>GC_TP_TIME

*IF_FDT_CONSTANTS=>GC_TP_DATETIME   IF_FDT_CONSTANTS=>GC_TP_TIMESTAMP_UTC

*la_S_DATE-type = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

*la_S_DATE-date = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].

*la_S_DATE-time = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].

*la_S_DATE-timestamp = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE DEPENDING ON YOUR TIMEPOINT TYPE].





GET REFERENCE OF la_S_DATE INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.





ls_name_value-name = 'S_FROM_CIT'.

*la_S_FROM_CIT = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_S_FROM_CIT INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.



ls_name_value-name = 'S_TO_CITY'.

*la_S_TO_CITY = [INSERT CONTEXT VALUE HERE OR DELETE THE LINE].

GET REFERENCE OF la_S_TO_CITY INTO lr_data.

ls_name_value-value = lr_data.

INSERT ls_name_value INTO TABLE lt_name_value.





cl_fdt_function_process=>get_data_object_reference( EXPORTING iv_function_id      = lv_function_id

                                                               iv_data_object      = '_V_RESULT'

                                                               iv_timestamp        = lv_timestamp

                                                               iv_trace_generation = abap_false

                                                     IMPORTING er_data             = lr_data ).

ASSIGN lr_data->* TO <la_any>.

TRY.

     cl_fdt_function_process=>process( EXPORTING iv_function_id = lv_function_id

                                                 iv_timestamp   = lv_timestamp

                                       IMPORTING ea_result      = <la_any>

                                       CHANGING  ct_name_value  = lt_name_value ).

     CATCH cx_fdt into lx_fdt.

       ENDTRY.

now but how t odo the following

Need the input parametes as S_FROM_CIT ,S_TO_CITY,S_DATE as input parameters

And based on these inputs the relevant data should be displayed.

All these GUI are to be doen in Web Service Navigator.Where is the URL for it is generated?

Can you please guide me?

Thanks in advance