This website is not affiliated with, sponsored by, or approved by SAP AG.

BCS: Attaching a custom transaction to UCMON

All postings related to SEM only

Moderators: Snowy, thx4allthefish

BCS: Attaching a custom transaction to UCMON

Postby trinity » Wed Mar 21, 2007 5:30 pm

Hi,

I am a newbie on BCS, an abapper by nature/profession, wanted to know if it is possible to attach a custom report transaction to the BCS monitor (UCMON) and any leads as to how to achieve this.

Thanks!
seek and you shall find ...
don't just request - do some ground work yourself first.
trinity
 
Posts: 341
Joined: Sun Dec 01, 2002 7:06 am
Location: sydney, australia

Postby dans » Thu Mar 22, 2007 6:35 am

Just research Custom Task in SAP Serevice Market Place. There is plenty of info there. Cut and past from an SAP document is below. Screen shots have been omitted.

SEM-BCS
User-defined task/method
Description of modification

SAP AG

Last Change: 2004.03.10,15:56h / Printed: 2003.08.05,18:33h


1 Description
This modification provides the possibility to implement user-defined tasks/methods under these conditions:
• The user-defined task is executed per consolidation unit
• Status for the user-defined task is held per consolidation unit
• The user defined method cannot be assigned to the task per consolidation unit
• The Analysis log can only contain messages

From the BCS user’s point of view it is necessary to define a data transfer method with a specific name (the name can be changed in the code of the modification) and a data transfer task; the method must then be assigned to the task (for all consolidation units, not per consolidation unit).

The name of the method (or the pattern) can be changed in the modification code (highlighted red).
From the developer’s point of view it is necessary to implement the following modification in the method CL_UC_TASK_EXECUTION->EXECUTE and a class, which implements the user exit logic.
2 Description of the modification:
The code modification takes place in the class CL_UC_TASK_EXECUTION in the method EXECUTE.
Context of the modification:
* **status update
ds_dtx_save-task = l_st_task.
ds_dtx_save-o_sel_status = lo_sel_status.
* **data buffer
ds_dtx_save-s_data = ls_data.
ds_dtx_save-o_sel_tx_buf = lo_sel_tx_buf.
ds_dtx_save-o_tx_data_buf = lo_tx_data_buf.
clear ds_dtx_save-f_bw_read. "BW data has not yet been read
* **show overview screen of data transfer task
Deletion:
call method data_tx_execute
exporting
io_sel = io_sel
it_method = <lt_method>.
exit. ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Insertion:
* BEGIN OF MODIFICATION USER-DEFINED TASK/METHOD =====================
data:
lo_change_y type ref to cl_uc_tx_data_change,
ls_tx_data_io type ucd_sx_tx_data_io,
lt_msg type uc0_t_message,
lo_sel_execution type ref to if_uc_sel,
l_tabix like sy-tabix,
lo_method_exit type ref to zcl_uc_method_01,
lt_field_del type uc0_ts_field,
ls_field_del type uc0_s_field,
lt_sel_execution type uc0_ts_sel,
ls_sel_execution type uc0_s_sel.
field-symbols:
<lt_data_hashed> type hashed table,
<lt_data> type standard table,
<ls_data> type data,
<ls_data_char> type data,
<ls_data_kfig> type data,
<l_value> type data,
<l_repunit> type any,
<lt_msg_data_ts> type sorted table,
<lt_msg_data> type standard table,
<ls_msg_data_char> type any,
<l_msg_value> type data,
<ls_msg_data> type any.

read table <lt_method> assigning <ls_method> index 1.
check sy-subrc is initial.
assign component uc00_cs_fld-method
of structure <ls_method> to <l_method>.
if <l_method>(3) = 'ZZR'.
** prepare execution parameters table
loop at do_task->do_model->ds_role-repunit into lr_s_fprop.
ls_field_del-fieldname = lr_s_fprop->fieldname.
insert ls_field_del into table lt_field_del.
endloop.
loop at do_task->do_model->ds_role-repgroup into lr_s_fprop.
ls_field_del-fieldname = lr_s_fprop->fieldname.
insert ls_field_del into table lt_field_del.
endloop.
call method io_sel->create_copy
importing
eo_sel = lo_sel_execution.
call method lo_sel_execution->overwrite_sel_with
exporting
it_field_delete = lt_field_del.
call method lo_sel_execution->get_sel
importing
et_sel = lt_sel_execution.
ls_sel_execution-sign = uc00_cs_ra-sign_i.
ls_sel_execution-option = uc00_cs_ra-option_eq.
loop at lt_st_check_all into ls_st_check where exec = gc_true.
clear l_count.
loop at lt_repug reference into lr_s_repug
where not use_for_xy is initial.
add 1 to l_count.
if l_count = 1.
read table lt_map_sid2exc into ls_map_sid
with table key
fieldname_sid = ls_st_check-x_fieldname_sid
value_sid = ls_st_check-x_value_sid.
ls_sel_execution-fieldname = ls_map_sid-fieldname.
ls_sel_execution-low = ls_map_sid-value.
insert ls_sel_execution into table lt_sel_execution.
else.
read table lt_map_sid2exc into ls_map_sid
with table key
fieldname_sid = ls_st_check-y_fieldname_sid
value_sid = ls_st_check-y_value_sid.
ls_sel_execution-fieldname = ls_map_sid-fieldname.
ls_sel_execution-low = ls_map_sid-value.
insert ls_sel_execution into table lt_sel_execution.
endif.
endloop.
endloop.
call method lo_sel_execution->overwrite_sel_with
exporting
it_sel = lt_sel_execution.
* create tables for totals TX data
read table do_task->do_model->dt_tx_data_io into ls_tx_data_io
with table key
datastreamtype = uc00_cs_datastreamtype-totals.
call method do_task->do_model->create_data_reference
exporting
i_type = do_task->do_model->gc_type_sx_tx_data
io_tx_data_io_type = ls_tx_data_io-o_io_type
importing
er_data = lr.
assign lr->* to <ls_data>.
create data lr like standard table of <ls_data>.
assign lr->* to <lt_data>.
call method do_task->do_model->create_data_reference
exporting
i_type = do_task->do_model->gc_type_th_tx_data
io_tx_data_io_type = ls_tx_data_io-o_io_type
importing
er_data = lr.
assign lr->* to <lt_data_hashed>.
** execution
call method do_task->do_model->create_data_reference
exporting
i_type = gc_type_ts_repunit_value
importing
er_data = lr.
assign lr->* to <lt_msg_data_ts>.
create data lr like line of <lt_msg_data_ts>.
assign lr->* to <ls_msg_data>.
create data lr like standard table of <ls_msg_data>
with default key.
assign lr->* to <lt_msg_data>.
clear lt_message[].
create object lo_method_exit.
call method lo_method_exit->execute
exporting
i_method = <l_method>
it_sel = lt_sel_execution
i_test = d_test
importing
et_data = <lt_data_hashed>
et_message = lt_message
et_msg_data = <lt_msg_data>.
append lines of lt_message to et_message.
* fill transaction data into change object
* read data from totals cube (with PL 00)
clear lt_sel.
ls_sel-sign = uc00_cs_ra-sign_i.
ls_sel-option = uc00_cs_ra-option_eq.
ls_sel-fieldname = do_task->do_model->ds_role-plevel->fieldname.
ls_sel-low = ls_sel-high = uc00_cs_plevel-input.
insert ls_sel into table lt_sel.
call method lo_sel_execution->overwrite_sel_with
EXPORTING
IT_SEL = lt_sel.
clear lt_field_del.
ls_field_del-fieldname = uc00_cs_fld-area.
insert ls_field_del into table lt_field_del.
ls_field_del-fieldname = uc00_cs_fld-databasis.
insert ls_field_del into table lt_field_del.
call method lo_sel_execution->overwrite_sel_with
EXPORTING
IT_field_delete = lt_field_del.
call method lo_tx_data_buf->init
exporting
io_model = do_task->do_model
io_sel = lo_sel_execution
io_io = ls_tx_data_io-o_io_stream.
call method lo_tx_data_buf->read.
* invert data lines
call method lo_tx_data_buf->invert.
* add data lines produced by the customer defined task
call method lo_tx_data_buf->if_uc_tx_data_io~add_data
EXPORTING
IT_DATA = <lt_data_hashed>.
* get data to be posted
refresh <lt_data_hashed>.
call method lo_tx_data_buf->get_data
changing
ct_data = <lt_data_hashed>.
append lines of <lt_data_hashed> to <lt_data>.
* get rid of initial records
assign component do_task->do_model->gc_type_comp_s_kfig
of structure <ls_data> to <ls_data_kfig>.
loop at <lt_data> into <ls_data>.
if <ls_data_kfig> is initial.
delete <lt_data>.
endif.
endloop.
* analyze data and fill correct records into change object
call method lo_change->analyze_and_add_data
exporting
i_analyze = gc_true
importing
et_message = lt_message
changing
ct_data = <lt_data>.
append lines of lt_message to et_message.
* analyze messages from document analyzer
assign component do_task->do_model->gc_type_comp_s_char
of structure <ls_msg_data> to <ls_msg_data_char>.
assign component do_task->do_model->gc_type_comp_s_char
of structure <ls_data> to <ls_data_char>.
loop at lt_message into ls_message where not row is initial.
read table <lt_data> into <ls_data> index ls_message-row.
check sy-subrc is initial.
loop at do_task->do_model->ds_role-repunit into lr_s_fprop.
assign component lr_s_fprop->fieldname of structure
<ls_data_char> to <l_value>.
check sy-subrc is initial.
assign component lr_s_fprop->fieldname of structure
<ls_msg_data_char> to <l_msg_value>.
check sy-subrc is initial.
<l_msg_value> = <l_value>.
endloop.
append <ls_msg_data> to <lt_msg_data>.
ls_message-row = sy-tabix.
collect ls_message into et_message.
endloop.
loop at lt_message into ls_message where row is initial.
collect ls_message into et_message.
endloop.
** analyze messages
* analyse messages for status update of all executed CUs
clear ls_st_update.
loop at et_message into ls_message where row is initial.
if ls_message-msgty ca gc_msgty_severe.
add 1 to ls_st_update-error.
elseif ls_message-msgty ca gc_msgty_warning.
add 1 to ls_st_update-warng.
endif.
endloop.
* fill status update table for all executed repunits
clear lt_st_update[].
loop at lt_st_check_all into ls_st_check
where not exec is initial.
ls_st_update-s_x-value_sid = ls_st_check-x_value_sid.
ls_st_update-s_y-value_sid = ls_st_check-y_value_sid.
insert ls_st_update into table lt_st_update.
endloop.
* analyse messages for status update of single CUs
loop at <lt_msg_data> into <ls_msg_data>.
l_tabix = sy-tabix.
clear ls_st_update_2.
* loop over all messages pointing to the current data row
loop at et_message into ls_message
where row = l_tabix.
if ls_message-msgty ca gc_msgty_severe.
add 1 to ls_st_update_2-error.
elseif ls_message-msgty ca gc_msgty_warning.
add 1 to ls_st_update_2-warng.
endif.
endloop.
check not ls_st_update_2-error is initial
or not ls_st_update_2-warng is initial.
* find current repunit SID
clear l_count.
loop at lt_repug reference into lr_s_repug
where not use_for_xy is initial.
add 1 to l_count.
assign component lr_s_repug->unit_fld of structure
<ls_msg_data> to <l_repunit>.
read table lt_map_exc2sid into ls_map_sid
with table key
fieldname = lr_s_repug->unit_fld
value = <l_repunit>.
if l_count = 1.
ls_st_update_2-value_sid_x = ls_map_sid-value_sid.
else.
ls_st_update_2-value_sid_y = ls_map_sid-value_sid.
endif.
endloop.
* update status update table for the current repunit
read table lt_st_update into ls_st_update from ls_st_update_2.
check sy-subrc is initial.
add ls_st_update_2-error to ls_st_update-error.
add ls_st_update_2-warng to ls_st_update-warng.
modify table lt_st_update from ls_st_update.
endloop.
* get rid of data charges of erroneous CUs
call method check_changes
exporting
i_taskproc = 'U'
it_repug = lt_repug
it_map_exc2sid = lt_map_exc2sid
it_map_grp2sid = lt_map_grp2sid
it_st_check = lt_st_check_all
changing
co_change = lo_change
ct_st_update = lt_st_update
ct_message = et_message.
* post TX data
if d_test is initial.
lo_change_x ?= lo_change.
call method lo_change_x->save_data
* EXPORTING “3.1B
* IO_TOTALS_IO = lo_totals_io. “3.1B
IMPORTING
ET_MESSAGE = lt_message.
append lines of lt_message to et_message.
clear ls_st_update_2.
loop at lt_message into ls_message.
if ls_message-msgty ca gc_msgty_severe.
add 1 to ls_st_update_2-error.
elseif ls_message-msgty ca gc_msgty_warning.
add 1 to ls_st_update_2-warng.
endif.
endloop.
loop at lt_st_update into ls_st_update.
add ls_st_update_2-error to ls_st_update-error.
add ls_st_update_2-warng to ls_st_update-warng.
modify table lt_st_update from ls_st_update.
endloop.
endif.
* issue a dummy message
if et_message is initial.
if 1 = 2.
message s014(ucs0).
* Maßnahme wurde entsprechend den Einschränkungen ausgeführt
endif.
clear ls_message.
ls_message-msgid = 'UCS0'.
ls_message-msgno = '014'.
ls_message-msgty = 'S'.
append ls_message to et_message.
endif.
** update status
if d_test is initial.
* determine xy parameters for status management
clear l_count.
loop at lt_repug reference into lr_s_repug
where not use_for_xy is initial.
add 1 to l_count.
case l_count.
when 1.
l_fieldname_x = lr_s_repug->fieldname.
lo_hry_x = lr_s_repug->o_hry.
when 2.
l_fieldname_y = lr_s_repug->fieldname.
lo_hry_y = lr_s_repug->o_hry.
when others.
message x000(uc0).
endcase.
endloop.
* determine SID for task
lo_task ?= do_task.
call method do_task->do_model->do_sidmap->convert_value_to_sid
exporting
i_fieldname = lo_task->do_char->d_fieldname
it_value = lo_task->dt_value
importing
es_sid = ls_sid.
l_st_task = ls_sid-value_sid.
* update status
call method do_st_management->update_task
exporting
io_sel = lo_sel_status
i_x_fieldname = l_fieldname_x
io_x_hry = lo_hry_x
i_y_fieldname = l_fieldname_y
io_y_hry = lo_hry_y
i_task = l_st_task
it_value_xy = lt_st_update.
RAISE EVENT monitor_refresh.
endif.
* display log
if not d_protocol is initial.
call method fill_log_ffix “3.2 SP9: fill_log_header_end
exporting
io_log = ls_control-o_log
i_test = d_test
i_lorig = d_lorig.
* collect all messages into log
call method ls_control-o_log->set_data
exporting
it_message = et_message.
loop at lt_method_log into ls_method_log
where not o_method_log is initial.
collect ls_method_log-o_method_log into lt_log_cust_data.
endloop.
call method ls_control-o_log->display
exporting
it_log_cust_data = lt_log_cust_data
io_sel_task_orig = io_sel.
endif.
call method cl_uc_stat=>close
exporting
i_node = cl_uc_stat=>gc_node_total.
exit. ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
else.
* following 8(!) lines were originally included ===================
call method data_tx_execute
exporting
io_sel = io_sel
it_method = <lt_method>.
call method cl_uc_stat=>close
exporting
i_node = cl_uc_stat=>gc_node_total.
exit. ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
endif.
* END OF MODIFICATION ===============================================

3 Description of the interface of the user exit method:
It is necessary to implement a class with a public method EXECUTE. The name of the class has to be defined in the modification code of CL_UC_TASK_EXECUTION->EXECUTE (highlighted green). The parameters of the EXECUTE method are as follows:
• I_METHOD
o Importing parameter
o Type UC_METHOD
o Name if the consolidation method
• IT_SEL
o Importing parameter
o Type UC0_TS_SEL
o Fixed parameters
o Example (content of it_sel at runtime):

• I_TEST
o Importing parameter
o Type UC_FLG
o ‘X’ = task executed in test run
• ET_DATA
o Exporting parameter
o Type HASHED TABLE
o Hashed table of transactional data (totals records) to be posted into the SEM-BCS infocube
• ET_MESSAGE
o Exporting parameter
o Type UC0_T_MESSAGE
o Table of messages
o Structure: message ID, message number, message type, variable 1-4, row
o ROW parameter points into ET_MSG_DATA
o Messages which have ROW=0 are relevant for all consolidation units
o Example (content of et_message at runtime):

• ET_MSG_DATA
o Exporting parameter
o Type INDEX TABLE
o Assignment of messages to consolidation units
o Example (content of et_msg_data at runtime); at this example messages in ET_MESSAGE, which have ROW=1, are relevant for consolidation unit JSU:

o Example of the status for the above listed et_message and et_msg_data (in the second task column):

4 Description of the implementation of the user exit method:
4.1 Scenario
Following example implementation aims at integration between R/3 and SEM-BCS. In order to get transaction data from R/3 into the SEM-BCS infocube, following steps have to take place in each closing period:
• Start extraction of FI data into the standard FI infocube via infopackage. (The administrator of the BW has to connect the infosource 0FI_GL_1 with the datasource 0FI_GL_1 the R/3 source system, create the update rules for the infocube 0FIGL_C01 from the infosource 0FI_GL_1 and create an infopackage for datasource 0FI_GL_1).
• Start the customer-defined task from the BCS monitor. This customer-defined task will copy transaction data from the standard infocube into the SEM-BCS infocube. Some parts of the data copy process have to be specified by the customer in the user exit:
o Data structure for reading data from the FI infocube. Characteristics and key figures, which are to be filled by the extractor, have to be part of the data structure, which is hard-coded in the user exit.
o Selection for reading data from the FI infocube. The selection table IT_SEL, passed by SEM-BCS contains the consolidation area, values of characteristics fixed in the consolidation area, version characteristics, consolidation unit characteristics, group currency key and time characteristics. This selection has to be transformed and enhanced in the user exit in order to get the required data from the standard infocube.
o Mapping of FI transaction data into SEM-BCS reported financial data. Data extracted from the FI infocube have to be mapped and enhanced in the user exit in order to fulfill requirements of the SEM-BCS breakdown check.
In a future release there will be a standard copy function and a flexible upload from an infocube available. Moreover, a customer-defined task will be available in the SEM-BCS standard.
4.2 Implementation
In this example a data copy from the standard FI infocube into the SEM-BCS infocube is implemented. According to this example first report UG_BW_REG_CUBE_IOBJ has to be executed in the SEM-BCS system in order to register infoobjects from the source infocube for SEM-BCS usage and to get the technical fieldnames for each infoobject.

Further information about the source data is available using transaction rsdcube for the source infocube and its infoobjects.

Using this information, the public instance method EXECUTE in a local class (in our example created as ZCL_UC_METHOD_01) can be implemented as follows e.g. (variable coding part is highlighted green):

method execute .

types:
begin of s_key,
fieldname type ug_fieldname,
end of s_key,
t_key type standard table of s_key,

* get type information from source infocube
* using transaction 'rsdcube' in the source BW
* get fieldnames executing report 'UG_BW_REG_CUBE_IOBJ'

* all fields to be read without key figures should be part of this
* type:
begin of s_char,
fiscvarnt type /bi0/oifiscvarnt,
fiscyear type /bi0/oifiscyear,
fiscperiod type /bi0/oifiscper3,
currency type /bi0/oicurrency,
/1fb/comp_code type /bi0/oicomp_code,
/1fb/comp_code__001 type /bi0/oicompany,
/1fb/bus_area type /bi0/oibus_area,
/1fb/chrt_accts type /bi0/oichrt_accts,
/1fb/gl_account type /bi0/oigl_account,
/1fb/gl_account__001 type /bi0/oibal_flag,
/1fb/gl_account__002 type /bi0/oiincst_flag,
/1fb/gl_account__003 type /bi0/oisem_posit,
/1fb/version type /bi0/oiversion,
/1fb/vtype type /bi0/oivtype,
/1fb/curtype type /bi0/oicurtype,
end of s_char,

* all key figures to be read should be part of this type:
begin of s_kfig,
/1fb/debit type /bi0/oidebit,
/1fb/credit type /bi0/oicredit,
/1fb/balance type /bi0/oibalance,
end of s_kfig.

types: begin of s_data.
include type s_char.
include type s_kfig.
types: end of s_data.


data:
* workareas for source data
ls_data_char type s_char,
ls_data_kfig type s_kfig,
ls_data type s_data,
* workarea for message-handling
ls_message type uc0_s_message,
* rfc-destination / source infocube
l_rfcdest type rfcdest,
l_rsinfocube type rsinfocube,
* workarea of sel_tab parameter it_sel
ls_sel type uc0_s_sel,
* object reference used for reading data from source infocube
lo_tx_data_handler type ref to if_ug_bw_tx_data,
* reference to create workarea of output table et_data
lr_s_data_out type ref to data,
* reference to create hashed table <lt_data> used for reading data
* from source infocube
lr_t_data type ref to data,
* workarea / keytab for table <lt_data>
* (include all fields of s_infocube, except key figures)
ls_key type s_key,
lt_key type t_key,
* sel_tab used for reading data from source infocube
ls_sel_ugbw type ugbw_s_sel,
lt_sel type ugbw_ts_sel,
* fields to be read from source infocube
* (inclcude all fields needed, except key figures)
ls_field type ugbw_s_field,
lt_field type ugbw_ts_field,
* key figures to be read from source infocube
ls_kfig type ugbw_s_kfig,
lt_kfig type ugbw_ts_kfig,
* reference to get structure description at runtime
lo_structdescr type ref to cl_abap_structdescr.

field-symbols:
* field-symbols used for a data record in BCS
<ls_data_out> type data,
* field-symbols used for reading data from source infocube
<lt_data> type hashed table,
* workarea for structure descritpion at runtime
<comp_wa> type abap_compdescr,
* field-symbols used for mapping data from source infocube to SEM-BCS
* where fieldnames are equal
<s_char> type data,
<s_kfig> type data,
* field-symbols used for mapping data from source infocube to SEM-BCS where
* fieldnames are different or for setting data unknown in source infocube
<cs_dimen> type data,
<cs_chart> type data,
<cs_curkey_gc> type data,
<cs_plevel> type data,
<cs_version> type data,
<cs_unit> type data,
<cs_item> type data,
<cs_trn_lc> type data.
* more data objects with names different to SEM-BCS
* declare here e.g.:
* <cs_curkey_lc> type data,
* <cs_partner> type data,

* reset exporting parameters
clear: et_data,
et_message,
et_msg_data.

* set RFC-Destination here
l_rfcdest = 'BC9CLNT000'.
* set source-infocube here
l_rsinfocube = '0FIGL_C01'.

* get instance of data_handler_object
call method cl_ug_bw_factory=>get_tx_data_instance
exporting
i_rfcdest = l_rfcdest
i_infocube = l_rsinfocube
receiving
eo_tx_data_handler = lo_tx_data_handler
exceptions
communication_failure_ = 1
system_failure_ = 2
others = 3.

if sy-subrc <> 0.
* message-handling e.g.
ls_message-msgid = sy-msgid.
ls_message-msgty = sy-msgty.
ls_message-msgno = sy-msgno.
ls_message-msgv1 = sy-msgv1.
ls_message-msgv2 = sy-msgv2.
ls_message-msgv3 = sy-msgv3.
ls_message-msgv4 = sy-msgv4.
append ls_message to et_message.
return.
endif.


* get description for type s_char
lo_structdescr ?=
cl_abap_typedescr=>describe_by_data( ls_data_char ).

loop at lo_structdescr->components assigning <comp_wa>.
* fill key tab
ls_key-fieldname = <comp_wa>-name.
insert ls_key into table lt_key.
* fill fields to be read into field-tab
ls_field-fieldname = <comp_wa>-name.
insert ls_field into table lt_field.
endloop.

lo_structdescr ?=
cl_abap_typedescr=>describe_by_data( ls_data_kfig ).

* get description for type s_kfig
loop at lo_structdescr->components assigning <comp_wa>.
* fill key figures to be read into kfig-tab
ls_kfig-fieldname = <comp_wa>-name.
insert ls_kfig into table lt_kfig.
endloop.

* create hashed table for reading data from source infocube
create data lr_t_data type hashed table of s_data
with unique key (lt_key).

assign lr_t_data->* to <lt_data>.


* fill seltab from it_sel for corresponding fields (map if necessary)
loop at it_sel into ls_sel.
move-corresponding ls_sel to ls_sel_ugbw.
read table lt_key with table key
fieldname = ls_sel-fieldname transporting no fields.
if sy-subrc <> 0.
if ls_sel-sign = 'I' and
ls_sel-option = 'EQ'.
case ls_sel-fieldname.
when '/1FB/CS_UNIT'.
* company code
ls_sel_ugbw-fieldname = '/1FB/COMP_CODE'.
case ls_sel-low.
when 'C4000'. ls_sel_ugbw-low = '1000'.
when 'C7000'. ls_sel_ugbw-low = '2000'.
* ...
when others. continue.
endcase.
when '/1FB/CS_VERSION'.
* version
ls_sel_ugbw-fieldname = '/1FB/VERSION'.
case ls_sel-low.
when '100'. ls_sel_ugbw-low = '001'.
* ...
endcase.
when others.
* restriction unknown in source infocube
continue.
endcase.
endif.
endif.
insert ls_sel_ugbw into table lt_sel.
endloop.

* read data from source infocube
call method lo_tx_data_handler->read_data_from_infoprov
exporting
i_comp_s_field = space
i_comp_s_kfig = space
it_field = lt_field
it_kfig = lt_kfig
it_sel = lt_sel
i_authority_check = space
changing
ct_data = <lt_data>
exceptions
communication_failure_ = 1
system_failure_ = 2
no_authorization = 3
others = 4.

if sy-subrc <> 0.
* message 'reading from InfoCube failed' e.g.
ls_message-msgid = sy-msgid.
ls_message-msgty = sy-msgty.
ls_message-msgno = sy-msgno.
ls_message-msgv1 = sy-msgv1.
ls_message-msgv2 = sy-msgv2.
ls_message-msgv3 = sy-msgv3.
ls_message-msgv4 = sy-msgv4.
append ls_message to et_message.
return.
endif.

* create workarea for et_data
create data lr_s_data_out like line of et_data.
assign lr_s_data_out->* to <ls_data_out>.
* assign substructure
assign component 'S_CHAR' of structure <ls_data_out> to <s_char>.
assign component 'S_KFIG' of structure <ls_data_out> to <s_kfig>.

* assign components with different names
assign component:
'/1FB/CS_VERSION' of structure <s_char> to <cs_version>,
'/1FB/CS_UNIT' of structure <s_char> to <cs_unit>,
'/1FB/CS_ITEM' of structure <s_char> to <cs_item>,
'/1FB/CS_TRN_LC' of structure <s_kfig> to <cs_trn_lc>.

* more components set here:
* partner e.g.
* assign component '.....' of structure <s_char> to <cs_partner>
* investee e.g.
* assign component '.....' of structure <s_char> to <cs_investee>

* assign BCS components with fix values (unknown in source infocube)
assign component:
'/1FB/CS_DIMEN' of structure <s_char> to <cs_dimen>,
'/1FB/CS_CHART' of structure <s_char> to <cs_chart>,
'/1FB/CURKEY_GC' of structure <s_char> to <cs_curkey_gc>,
'CS_PLEVEL' of structure <s_char> to <cs_plevel>.


* move source data to target: et_data
loop at <lt_data> into ls_data.

clear <ls_data_out>.

* set values fore fields with same names in SEM-BCS
move-corresponding ls_data to <ls_data_out>.

* set values for fields with names different to SEM-BCS
* (derive BCS values from source values)
* fix values in BCS
<cs_dimen> = '01'. "value fixed in cons area
<cs_chart> = '01'. "value fixed in cons area
<cs_curkey_gc> = 'USD'. "group currency of cons area
<cs_plevel> = '00'. "posting level of reported financial data
* cons version
case ls_data-/1fb/version.
when '001'. <cs_version> = '100'.
* ...
endcase.
* cons unit
case ls_data-/1fb/comp_code.
when '1000'.
<cs_unit> = 'C4000'.
* ...
when others. continue.
endcase.
* f/s item
case ls_data-/1fb/gl_account.
* ...
* when others. <cs_item> = ls_data-/1fb/gl_account.
endcase.
* value in local currncy
<cs_trn_lc> = ls_data-/1fb/balance.

* e.g.: more values set here:
* <cs_partner> = ls_data-....
* <cs_investee> = ls_data-...

insert <ls_data_out> into table et_data.

endloop.

endmethod.

4.3 Description of variable coding parts

* all fields to be read without key figures should be part of this
* type:
begin of s_char,
fiscvarnt type /bi0/oifiscvarnt,
fiscyear type /bi0/oifiscyear,
fiscperiod type /bi0/oifiscper3,
currency type /bi0/oicurrency,
/1fb/comp_code type /bi0/oicomp_code,
/1fb/comp_code__001 type /bi0/oicompany,
/1fb/bus_area type /bi0/oibus_area,
/1fb/chrt_accts type /bi0/oichrt_accts,
/1fb/gl_account type /bi0/oigl_account,
/1fb/gl_account__001 type /bi0/oibal_flag,
/1fb/gl_account__002 type /bi0/oiincst_flag,
/1fb/gl_account__003 type /bi0/oisem_posit,
/1fb/version type /bi0/oiversion,
/1fb/vtype type /bi0/oivtype,
/1fb/curtype type /bi0/oicurtype,
end of s_char,

* all key figures to be read should be part of this type:
begin of s_kfig,
/1fb/debit type /bi0/oidebit,
/1fb/credit type /bi0/oicredit,
/1fb/balance type /bi0/oibalance,
end of s_kfig.

The technical fieldnames used in the types ‘s-char’ and ‘s_kfig’ have to be equal to the fieldnames listed by report UG_BW_REG_CUBE_IOBJ (second column of the output list, see below). All fields listed without the key figure flag should be part of the ‘s_char’ type, fields where the key figure flag is set, should be part of the ‘s_kfig’ type.

Field symbols must be declared in order to enable data mapping and setting fixed values for fields unknown in the source infocube but obligatory for the SEM-BCS (for example group currency as ‘<cs_curkey_gc>’):

* field-symbols used for mapping data from source infocube to SEM-BCS where
* fieldnames are different or setting data unknown in source infocube
<cs_dimen> type data,
<cs_chart> type data,
<cs_curkey_gc> type data,
<cs_plevel> type data,
<cs_version> type data,
<cs_unit> type data,
<cs_item> type data,
<cs_trn_lc> type data.
* more data objects with names different to SEM-BCS
* declare here e.g.:
* <cs_curkey_lc> type data,
* <cs_partner> type data,


RFC-destination and source infocube have to be set:

* set RFC-Destination here
l_rfcdest = 'BC9CLNT000'.
* set source-infocube here
l_rsinfocube = '0FIGL_C01'.

The user-defined task will be executed using the selection parameter table it_sel. It is set by SEM-BCS. This selection has to be transformed into the table lt_sel, which is used to read the data from the source infocube.
In most cases technical fieldnames passed in the table it_sel have different names than the technical fieldnames of the source infocube (registered and listed by report UG_BW_REG_CUBE_IOBJ). It is necessary to map these fieldnames to fields of ‘s_char’.
In our example the company code with technical fieldname ‘/1FB/CS_UNIT’ in SEM-BCS, has to be mapped to ‘/1FB/COMP_CODE’ of ‘s_char’. For company code ‘C4000’ (in the selection table it_sel, passed by SEM-BCS) the value ‘1000’ (corresponding to ‘C4000’ in the source infocube) must be set. The selection condition for version is mapped, too. In our example there is no mapping necessary for the fiscal year and period, because these fields are named equally.

* fill seltab from it_sel for corresponding fields (map if necessary)
loop at it_sel into ls_sel.
move-corresponding ls_sel to ls_sel_ugbw.
read table lt_key with table key
fieldname = ls_sel-fieldname transporting no fields.
if sy-subrc <> 0.
if ls_sel-sign = 'I' and
ls_sel-option = 'EQ'.
case ls_sel-fieldname.
when '/1FB/CS_UNIT'.
* company code
ls_sel_ugbw-fieldname = '/1FB/COMP_CODE'.
case ls_sel-low.
when 'C4000'. ls_sel_ugbw-low = '1000'.
when 'C7000'. ls_sel_ugbw-low = '2000'.
* ...
when others. continue.
endcase.
when '/1FB/CS_VERSION'.
* version
ls_sel_ugbw-fieldname = '/1FB/VERSION'.
case ls_sel-low.
when '100'. ls_sel_ugbw-low = '001'.
* ...
endcase.
when others.
* restriction unknown in source infocube
continue.
endcase.
endif.
endif.
insert ls_sel_ugbw into table lt_sel.
endloop.
The technical SEM-BCS fieldnames are available via SEM-BCS Workbench: Data Model->Cons Area, in the context menu choose ‘Display’ on the consolidation area corresponding to the customer defined task:

After pressing the button ‘Technical Names’, the technical fieldnames used in SEM-BCS are listed:

All fields unknown in the source infocube, but required in SEM-BCS or named differently to SEM-BCS must be filled in the transaction data table et_data. Otherwise the data will not successfully pass the breakdown check and will not be posted into the SEM-BCS infocube.

* assign components with different names
assign component:
'/1FB/CS_VERSION' of structure <s_char> to <cs_version>,
'/1FB/CS_UNIT' of structure <s_char> to <cs_unit>,
'/1FB/CS_ITEM' of structure <s_char> to <cs_item>,
'/1FB/CS_TRN_LC' of structure <s_kfig> to <cs_trn_lc>.

* more components set here:
* partner e.g.
* assign component '.....' of structure <s_char> to <cs_partner>
* investee e.g.
* assign component '.....' of structure <s_char> to <cs_investee>

* assign BCS components with fix values (unknown in source infocube)
assign component:
'/1FB/CS_DIMEN' of structure <s_char> to <cs_dimen>,
'/1FB/CS_CHART' of structure <s_char> to <cs_chart>,
'/1FB/CURKEY_GC' of structure <s_char> to <cs_curkey_gc>,
'CS_PLEVEL' of structure <s_char> to <cs_plevel>.

Finally the output transaction data table et_data has to be filled with the data selected from source infocube. Again, mapping might be necessary at this point. Fields unknown in the source infocube but required in SEM-BCS must be filled.
In our example:
Dimension, chart, group currency and posting level are set; version and company code are mapped (as in the mapping of it_sel entries into lt_sel):

* move source data to target: et_data
loop at <lt_data> into ls_data.

clear <ls_data_out>.

* set values fore fields with same names in SEM-BCS
move-corresponding ls_data to <s_char>.

* set values for fields with names different to SEM-BCS
* (derive BCS values from source values)
* fix values in BCS
<cs_dimen> = '01'. "value fixed in cons area
<cs_chart> = '01'. "value fixed in cons area
<cs_curkey_gc> = 'USD'. "group currency of cons area
<cs_plevel> = '00'. "posting level of reported financial data
* cons version
case ls_data-/1fb/version.
when '001'. <cs_version> = '100'.
* ...
endcase.
* cons unit
case ls_data-/1fb/comp_code.
when '1000'.
<cs_unit> = 'C4000'.
* ...
when others. continue.
endcase.
* f/s item
case ls_data-/1fb/gl_account.
* ...
* when others. <cs_item> = ls_data-/1fb/gl_account.
endcase.
* value in local currncy
<cs_trn_lc> = ls_data-/1fb/balance.

* e.g.: more values set here:
* <cs_partner> = ls_data-....
* <cs_investee> = ls_data-...

insert <ls_data_out> into table et_data.

endloop.[/img]
dans
 
Posts: 197
Joined: Fri Mar 07, 2003 10:26 am


Return to SEM

Who is online

Users browsing this forum: No registered users and 9 guests





This website is not affiliated with, sponsored by, or approved by SAP AG.