Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How Read the Data Object From BRF+ Application

former_member445147
Participant
0 Kudos
3,465

Hi

I have situation where i have read the data object  of brf+ application dynamically ,

and tried with below  code but im getting cx_fdt_input. exception

lo_fact = cl_fdt_factory=>get_instance( ).

TRY.

     lo_fact->get_data_object(

     EXPORTING

       iv_id = '52540XXXXXXXXXXXXXXXXXXXXX'

       RECEIVING

         ro_data_object = lo_data_object ).

   CATCH cx_fdt_input.

ENDTRY.


lv_data_object_type = lo_data_object->get_data_object_type( ).

CASE lv_data_object_type.

WHEN if_fdt_constants=>gc_data_object_type_element.

    lv_typename = lo_data_object->get_ddic_binding( ).

    IF lv_typename EQ 'BELNR_D'.

      "your logic to assign type

    ENDIF.

can any one help how to read all data object for the particular id

Thanks

1 ACCEPTED SOLUTION
Read only

former_member445147
Participant
0 Kudos
1,901

Here we have proper code to get data object and data element



PARAMETERS p_brfnme(50)                 TYPE c.

DATA lv_data_object_type                TYPE if_fdt_types=>data_object_type.

DATA lv_id                              TYPE if_fdt_types=>id.

DATA lv_name                            TYPE if_fdt_types=>name.


DATA lo_fact                            TYPE REF TO if_fdt_factory.

DATA lo_data_object                     TYPE REF TO if_fdt_data_object.

DATA lo_instance                        TYPE REF TO if_fdt_admin_data.

DATA lo_query                           TYPE REF TO if_fdt_query.


DATA lt_object_id                       TYPE if_fdt_types=>ts_object_id.

DATA lt_name_of_brf                     TYPE STANDARD TABLE OF if_fdt_types=>name.


DATA ls_name                            LIKE LINE OF lt_name_of_brf.


"get the instance of application for getting brf+ id for name

lo_query ?= cl_fdt_query=>get_instance( iv_object_type = if_fdt_constants=>gc_object_type_expression ).

"get the instance of application to getting data object

lo_fact = cl_fdt_factory=>get_instance( ).

"get the all object for the particular id

lv_name = p_brfnme.

"get the ids for brf+ application name ,

lo_query->get_ids(

   EXPORTING

     iv_name           = lv_name " Beschreibung

   IMPORTING

     ets_object_id     = lt_object_id ).    " Object IDs

"we may have more than one id so always first id is BRF+ application id

READ TABLE lt_object_id INTO lv_id INDEX 1.

"here passing the id and get all objects  of an that application

TRY.

     cl_fdt_application=>get_all_objects(

       EXPORTING

         iv_application_id lv_id   " Application ID

       IMPORTING

         ets_object_id     = lts_object_id   " Contained obejcts

     ).

   CATCH cx_fdt_input.    " FDT: Invalid Input

ENDTRY.

"loop at the object get correct data objects

LOOP AT  lts_object_id INTO ls_object_id.

   TRY.

       lo_fact->get_data_object(

   EXPORTING

     iv_id               = ls_object_id " Universal Unique Identifier

         " Data Object Type

   RECEIVING

     ro_data_object      = lo_data_object    " Data Object

       ).

     CATCH cx_fdt_input.

   ENDTRY.

   "if we get the correct the data object, get the name data element

   IF lo_data_object IS NOT INITIAL.

     lv_name = lo_data_object->if_fdt_admin_data~get_name( ).

     APPEND lv_name TO lt_name_of_brf .

     SORT lt_name_of_brf DESCENDING.

     DELETE ADJACENT DUPLICATES FROM lt_name_of_brf.

ENDIF.

   CLEAR lo_data_object.

ENDLOOP.

22 REPLIES 22
Read only

PeterJonker
Active Contributor
0 Kudos
1,901

You are already catching the error. Catch it in an error object and read the message

Maybe that gives you a clue why the error is there. That is the minimum effort you should perform when using a catch.

data: lx_fdt_input type ref to cx_fdt_input,

ls_message type string.

catch cx_fdt_input into lx_fdt_input.

ls_message = lx_fdt_input->IF_MESSAGE~GET_TEXT( ).

or

ls_message = lx_fdt_input-> if_message~get_longtext( preserve_newlines = 'X' ).

Read only

0 Kudos
1,901

Hi peter Jonker

Thanks for the suggestion,

Im getting the ID 52540XXXXXXXXXXXXXXXXXXXXX is initial, unknown, or it does not have the correct object type message as exception .

i have doubt weather its right class to get the Data Object ????

weather we some other way to get Data object ?

Thanks

Read only

RaymondGiuseppi
Active Contributor
0 Kudos
1,901

Try to actually do something in your CATCH statements, at least display error message.


DATA : lt_message TYPE if_fdt_types=>t_message,

       lx_fdt     TYPE REF TO cx_fdt.

FIELD-SYMBOLS:

     <ls_message>  TYPE if_fdt_types=>s_message.

TRY.

    lo_fact->get_data_object(

    EXPORTING

      iv_id = '52540XXXXXXXXXXXXXXXXXXXXX'

      RECEIVING

        ro_data_object = lo_data_object ).

  CATCH cx_fdt INTO lx_fdt.

    WRITE : / 'Get object failed with exception'.           "#EC NOTEXT

    LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.

      WRITE :/ <ls_message>-text.

    ENDLOOP.

ENDTRY.

Don't hesitate to use any method of cx_fdt as GET_OBJECT_NAME, TYPE_TEXT orDESCRIPTION...

Else did you try a CL_FDT_FACTORY=>IF_FDT_FACTORY~GET_INSTANCE then ->GET_QUERY, also browse the FDT_ADMN_0000* tabes for check.

Regards,

Raymond

Read only

0 Kudos
1,901

Hi Raymond

Even if use CL_FDT_FACTORY=>IF_FDT_FACTORY~GET_INSTANCE then ->GET_QUERY, 

im not getting the any Data Object for the particular ID

Regards

Harish

Read only

former_member445147
Participant
0 Kudos
1,901

DATA lo_fact                     TYPE REF TO   if_fdt_factory.

DATA lo_data_object          TYPE REF TO if_fdt_data_object.

DATA lv_data_object_type  TYPE if_fdt_types=>data_object_type.



lo_fact = cl_fdt_factory=>if_fdt_factory~get_instance( ).

try.

lo_fact->get_data_object(

   EXPORTING

     iv_id               = '5254006E0D6Exxxxxxxxxxxxxxxxxxxxxx'   " Universal Unique Identifier

   RECEIVING

    ro_data_object      =   lo_data_object   " Data Object

).


catch cx_fdt_input into lx_fdt_input.

ls_message = lx_fdt_input->IF_MESSAGE~GET_TEXT( ).

endtry.

lv_data_object_type = lo_data_object->get_data_object_type( ).


CASE lv_data_object_type.

   WHEN if_fdt_constants=>gc_data_object_type_element.


"write your logic


endcase.



"Note i got exception for some the Universal Unique Identifier number ,i dont why its giving

if any got  exception ,change Universal Unique Identifier number and check

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,901

Did you try searching for a data object with that universal unique identifier in the BRF+ Workbench?

Read only

0 Kudos
1,901

Hi Kumar

yes

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,901

And you were able to find a data object?

Read only

0 Kudos
1,901

Hi Kumar

yes for universal unique identifier you get the data object ,

try with above code you ll get the data object

Regards

Harish

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

I don't want to get the data object. I was just trying to help resolve your problem which I thought wasn't resolved yet.

Read only

former_member445147
Participant
0 Kudos
1,899

Hi kumar

Ya i got data object instance but using that instance im trying read the data element

but im getting blank values

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

When I am executing your code in my system, I am able to successfully read the data element to which the data object is bound.

Read only

0 Kudos
1,899

im getting this object ({O:4*\CLASS=CL_FDT_ELEMENT} )

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

And that is correct.

Read only

0 Kudos
1,899

than using that object how could i read all element from application

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

I thought you wanted to read the element's data element which you were already doing using GET_DDIC_BINDING method.

Read only

0 Kudos
1,899

No i have to read all Data Object elements .

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

Then you should be using a method of CL_FDT_APPLICATION. Maybe GET_DATA_OBJECT_TYPES.

Read only

0 Kudos
1,899

yes that method will give data element not names ,

i need all data element names ,

weather we any API for reading the data elements names ???

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Kudos
1,899

I can't seem to find a direct API to do that but you can do the following:

1. Using method CL_FDT_APPLICATION=>GET_ALL_OBJECTS, get all objects in the application.

2. Loop over the objects retrieved in step 1 and within a TRY-CATCH block, call method IF_FDT_FACTORY->GET_DATA_OBJECT. Here, in the TRY-CATCH block, you can just add an empty CATCH CX_FDT_INPUT so as to skip objects that are not elements. For the other objects (i.e. for elements), call method GET_DDIC_BINDING to get the data element name.

Read only

0 Kudos
1,899

Hi Kumar

thanks for answer

Get_ddic_binding it wont give the data element name but get_name it will the name .

thanks

Regards

Harish

Read only

former_member445147
Participant
0 Kudos
1,902

Here we have proper code to get data object and data element



PARAMETERS p_brfnme(50)                 TYPE c.

DATA lv_data_object_type                TYPE if_fdt_types=>data_object_type.

DATA lv_id                              TYPE if_fdt_types=>id.

DATA lv_name                            TYPE if_fdt_types=>name.


DATA lo_fact                            TYPE REF TO if_fdt_factory.

DATA lo_data_object                     TYPE REF TO if_fdt_data_object.

DATA lo_instance                        TYPE REF TO if_fdt_admin_data.

DATA lo_query                           TYPE REF TO if_fdt_query.


DATA lt_object_id                       TYPE if_fdt_types=>ts_object_id.

DATA lt_name_of_brf                     TYPE STANDARD TABLE OF if_fdt_types=>name.


DATA ls_name                            LIKE LINE OF lt_name_of_brf.


"get the instance of application for getting brf+ id for name

lo_query ?= cl_fdt_query=>get_instance( iv_object_type = if_fdt_constants=>gc_object_type_expression ).

"get the instance of application to getting data object

lo_fact = cl_fdt_factory=>get_instance( ).

"get the all object for the particular id

lv_name = p_brfnme.

"get the ids for brf+ application name ,

lo_query->get_ids(

   EXPORTING

     iv_name           = lv_name " Beschreibung

   IMPORTING

     ets_object_id     = lt_object_id ).    " Object IDs

"we may have more than one id so always first id is BRF+ application id

READ TABLE lt_object_id INTO lv_id INDEX 1.

"here passing the id and get all objects  of an that application

TRY.

     cl_fdt_application=>get_all_objects(

       EXPORTING

         iv_application_id lv_id   " Application ID

       IMPORTING

         ets_object_id     = lts_object_id   " Contained obejcts

     ).

   CATCH cx_fdt_input.    " FDT: Invalid Input

ENDTRY.

"loop at the object get correct data objects

LOOP AT  lts_object_id INTO ls_object_id.

   TRY.

       lo_fact->get_data_object(

   EXPORTING

     iv_id               = ls_object_id " Universal Unique Identifier

         " Data Object Type

   RECEIVING

     ro_data_object      = lo_data_object    " Data Object

       ).

     CATCH cx_fdt_input.

   ENDTRY.

   "if we get the correct the data object, get the name data element

   IF lo_data_object IS NOT INITIAL.

     lv_name = lo_data_object->if_fdt_admin_data~get_name( ).

     APPEND lv_name TO lt_name_of_brf .

     SORT lt_name_of_brf DESCENDING.

     DELETE ADJACENT DUPLICATES FROM lt_name_of_brf.

ENDIF.

   CLEAR lo_data_object.

ENDLOOP.