cancel
Showing results for 
Search instead for 
Did you mean: 

The Program getting. Dump, code which i build is Combination Both Application & Rule.

SowmyaSurekha
Explorer
0 Kudos

HI SCN People,
What's the problem is I written the code seprately for both Application & Rule,
but next target is to write in combination Application + Rule In One Program so that code will create application as well as rules in it.


The code which i written,

DATA: loactory TYPE REF TO if_fdt_factory,
lo_rule TYPE REF TO if_fdt_rule,
lo_application TYPE REF TO if_fdt_application,
lo_function TYPE REF TO if_fdt_function,
lo_result TYPE REF TO if_fdt_result,
lo_context TYPE REF TO if_fdt_context,
lo_admin_data TYPE REF TO if_fdt_admin_data,
lo_actn_msg_log TYPE REF TO if_fdt_actn_message_log,
lr_data TYPE REF TO data,
lo_data_object TYPE REF TO if_fdt_data_object,
lt_messages TYPE if_fdt_types=>t_message,
ls_messages TYPE if_fdt_types=>s_message,
lv_boolean TYPE abap_bool,
lv_condition_id TYPE if_fdt_types=>id,
lts_context_id TYPE if_fdt_types=>ts_object_id,
lv_actv_failed TYPE abap_bool,
lt_actn_msg_log_par TYPE if_fdt_actn_message_log=>ts_message,
ls_actn_msg_log_par TYPE if_fdt_actn_message_log=>s_message,
lv_demo_appl_id TYPE if_fdt_types=>id,
logobj TYPE balobj_d VALUE 'FDT',
logsub TYPE balsubobj VALUE 'FDT_MSG_ACTION',
lv_id TYPE if_fdt_types=>id.

FIELD-SYMBOLS:
<lt_rslt_table> TYPE table,
<lt_rslt_struct> TYPE any.

PARAMETERS: pv_actn TYPE abap_bool DEFAULT abap_true,
pv_lcl TYPE abap_bool RADIOBUTTON GROUP r00 DEFAULT 'X',
pv_mstr TYPE abap_bool RADIOBUTTON GROUP r00.

lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance( ).

* =============================================================
* definition of the new application:

lo_application = lo_factory->get_application( ).
lo_application->if_fdt_transaction~enqueue( ).

* set values for the application, especially the name is important


lo_application->set_software_component('HOME').
lo_application->set_development_package( 'z1013522_sosu' ).
lo_application->if_fdt_admin_data~set_name( cl_fdt_services=>get_unique_name( ) ).

*
IF pv_lcl EQ abap_true.
lo_application->create_local_application( ).
ELSEIF pv_mstr EQ abap_true.
lo_application->create_masterdata_application( ).
ENDIF.

lo_application->if_fdt_transaction~activate(
IMPORTING et_message = lt_messages
ev_activation_failed = lv_boolean ).

IF lv_boolean EQ abap_true.

lo_application->if_fdt_transaction~dequeue( ).
ELSE.
lo_application->if_fdt_transaction~save( ).
lo_application->if_fdt_transaction~dequeue( ).

lv_demo_appl_id = lo_application->mv_id.
ENDIF.
WRITE: 'The ID of the application created is: ', lv_demo_appl_id.

START-OF-SELECTION.
* Get an instance of the FDT factory.
lo_factory = cl_fdt_factory=>if_fdt_factory~get_instance(
'lv_demo_appl_id').

cl_fdt_convenience=>create_element( EXPORTING iv_name = 'zso_ele_demo'
iv_application_id = 'lv_demo_appl_id'
iv_element_type = if_fdt_constants=>gc_element_type_boolean
iv_activate = abap_false
IMPORTING ev_element_id = lv_condition_id ).
INSERT lv_condition_id INTO TABLE lts_context_id.

* Create a rule expression and set some attributes to it.
lo_rule ?= lo_factory->get_expression(
iv_expression_type_id = if_fdt_constants=>gc_exty_rule ).
lo_rule->if_fdt_transaction~enqueue( ).
lo_rule->if_fdt_admin_data~set_name( 'zso_rule_demo' ).
* Rule Condition has to be a boolean value
lo_rule->set_condition( lv_condition_id ).
* Create an action message to set as the false action and set some attributes.
lo_actn_msg_log ?= lo_factory->get_expression(
iv_expression_type_id = if_fdt_actn_message_log=>gc_exty_message_log ).
lo_actn_msg_log->if_fdt_transaction~enqueue( ).
lo_actn_msg_log->if_fdt_admin_data~set_name( 'zso_msg_demo' ).
lo_actn_msg_log->set_application_log_object( EXPORTING iv_log_object = logobj
iv_log_subobject = logsub ).
lo_actn_msg_log->set_persistency_settings( abap_false ).
ls_actn_msg_log_par-msgid = 'ZSO_MSG_DEMO'.
ls_actn_msg_log_par-msgno = '002'.
ls_actn_msg_log_par-msgty = 'I'.
INSERT ls_actn_msg_log_par INTO TABLE lt_actn_msg_log_par.
lo_actn_msg_log->set_messages( lt_actn_msg_log_par ).
* Set the false action of the rule
lo_rule->set_false_action( lo_actn_msg_log->if_fdt_admin_data~mv_id ).
*Create an action message to set as the True action and set some attributes.
CLEAR: ls_actn_msg_log_par, lt_actn_msg_log_par.
lo_actn_msg_log ?= lo_factory->get_expression(
iv_expression_type_id = if_fdt_actn_message_log=>gc_exty_message_log ).
lo_actn_msg_log->if_fdt_transaction~enqueue( ).
lo_actn_msg_log->if_fdt_admin_data~set_name( 'zso_msg_log' ).
lo_actn_msg_log->set_application_log_object( EXPORTING iv_log_object = logobj
iv_log_subobject = logsub ).

lo_actn_msg_log->set_persistency_settings( abap_false ).
ls_actn_msg_log_par-msgid = 'ZSO_MSG_DEMO'.
ls_actn_msg_log_par-msgno = '001'.
ls_actn_msg_log_par-msgty = 'I'.
INSERT ls_actn_msg_log_par INTO TABLE lt_actn_msg_log_par.
lo_actn_msg_log->set_messages( lt_actn_msg_log_par ).
* Set the True action of the rule
lo_rule->set_true_action( lo_actn_msg_log->if_fdt_admin_data~mv_id ).


* Create a function instance using factory.
lo_function ?= lo_factory->get_function( ).
* Setting some attributes of the function
lo_function->if_fdt_transaction~enqueue( ).
lo_function->if_fdt_admin_data~set_name( cl_fdt_services=>get_unique_name( ) ).
lo_function->set_context_data_objects( lts_context_id ).
lo_function->set_result_data_object( if_fdt_action=>gc_dobj_action_table ).
lo_function->set_expression( lo_rule->if_fdt_admin_data~mv_id ).

** Perform deep activation & saving.
DATA : lt_message TYPE if_fdt_types=>t_message,
lv_message TYPE string,
lx_fdt TYPE REF TO cx_fdt.

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

* Activate the function deep so that all the objects associated with
* the function also get activated. Only activated changes are relevant
* for processing; however, active memory states can also be processed
* without a need to save to DB
lo_function->if_fdt_transaction~activate(
EXPORTING iv_deep = abap_true
IMPORTING et_message = lt_message
ev_activation_failed = lv_actv_failed ).

* If the activation is successful, save all object and release all locks.
* Else, only release the locks.
IF lv_actv_failed EQ abap_true.
lo_function->if_fdt_transaction~dequeue(
EXPORTING iv_deep = abap_true ).
WRITE : / 'Deep activation failed'. "#EC NOTEXT
LOOP AT lt_message ASSIGNING <ls_message>.
MESSAGE ID <ls_message>-msgid TYPE <ls_message>-msgty NUMBER <ls_message>-msgno
WITH <ls_message>-msgv1 <ls_message>-msgv2 <ls_message>-msgv3 <ls_message>-msgv4
INTO lv_message.
WRITE: / 'Reason : -',lv_message. "#EC NOTEXT
ENDLOOP.
ELSE.
TRY.
lo_function->if_fdt_transaction~save(
EXPORTING iv_deep = abap_true ).
CATCH cx_fdt INTO lx_fdt.
WRITE : / 'Save failed with exception'. "#EC NOTEXT
LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.
WRITE 😕 <ls_message>-text.
ENDLOOP.
ENDTRY.

lo_function->if_fdt_transaction~dequeue(
EXPORTING iv_deep = abap_true ).
ENDIF.

*====================================================================================
* run-time
* Process the function on successful activation and display result .
* Catch exception if any.
IF lv_actv_failed NE abap_true.
* Using the context of the function.
lo_context = lo_function->get_process_context( ).
lo_context->set_value( iv_id = lv_condition_id ia_value = pv_actn ).

TRY.
lo_function->process( EXPORTING io_context = lo_context
IMPORTING eo_result = lo_result ).
CATCH cx_fdt INTO lx_fdt.
LOOP AT lx_fdt->mt_message ASSIGNING <ls_message>.
WRITE 😕 <ls_message>-text.
ENDLOOP.
ENDTRY.
ENDIF.

IF lo_result IS BOUND.
lo_data_object = lo_result->get_data_object( ).
lo_data_object->create_data_reference( IMPORTING er_data = lr_data ).
ASSIGN lr_data->* TO <lt_rslt_table>.
lo_result->get_value( IMPORTING ea_value = <lt_rslt_table> ).
LOOP AT <lt_rslt_table> ASSIGNING <lt_rslt_struct>.
lv_id = <lt_rslt_struct>.
cl_fdt_factory=>get_instance_generic( EXPORTING iv_id = lv_id
IMPORTING eo_instance = lo_admin_data ).
lo_actn_msg_log ?= lo_admin_data.
lt_actn_msg_log_par = lo_actn_msg_log->get_messages( ).
LOOP AT lt_actn_msg_log_par INTO ls_actn_msg_log_par.
MESSAGE ID ls_actn_msg_log_par-msgid TYPE ls_actn_msg_log_par-msgty NUMBER ls_actn_msg_log_par-msgno.
ENDLOOP.
ENDLOOP.
  ENDIf. 

Getting Error Code Place - In pic 
<br>
0 Kudos

Check the content of lx_fdt->mt_message whether there is some meaningfull error reported

Accepted Solutions (0)

Answers (0)