2016 Jan 25 10:27 AM
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
2016 Feb 02 4:47 AM
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.
2016 Jan 25 10:40 AM
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' ).
2016 Jan 25 11:39 AM
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
2016 Jan 25 12:50 PM
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
2016 Jan 27 5:43 AM
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
2016 Jan 27 7:52 AM
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
2016 Jan 27 8:23 AM
Did you try searching for a data object with that universal unique identifier in the BRF+ Workbench?
2016 Jan 27 9:13 AM
2016 Jan 27 9:21 AM
2016 Jan 27 9:32 AM
Hi Kumar
yes for universal unique identifier you get the data object ,
try with above code you ll get the data object
Regards
Harish
2016 Jan 27 9:35 AM
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.
2016 Jan 27 10:15 AM
Hi kumar
Ya i got data object instance but using that instance im trying read the data element
but im getting blank values
2016 Jan 27 10:28 AM
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.
2016 Jan 28 9:12 AM
2016 Jan 28 9:17 AM
2016 Jan 28 9:22 AM
than using that object how could i read all element from application
2016 Jan 28 9:33 AM
I thought you wanted to read the element's data element which you were already doing using GET_DDIC_BINDING method.
2016 Jan 28 9:36 AM
2016 Jan 28 10:00 AM
Then you should be using a method of CL_FDT_APPLICATION. Maybe GET_DATA_OBJECT_TYPES.
2016 Jan 28 10:20 AM
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 ???
2016 Jan 28 11:09 AM
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.
2016 Feb 01 5:34 AM
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
2016 Feb 02 4:47 AM
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.