on 06-22-2016 10:20 PM
Hi
I want to make a routine transformation in 0FIGL_C10
The case I have is I want to have a key figure that calculates net profit
As the net profit is (0balance) of specific GL ranges – (0balance) of other GL ranges
I added a new object (KF) which supposed net profit connected with the 0balance
What exactly do I write in the transformation routine to get this calculation??
Thanks
Why would you do it in transformation ? This is something should be done at the query level with Restricted and calculated Key figure .
Does net profit make sense at individual line ?
Anindya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
One Idea could be,
your new Key Figure will have sign based on GL Account ( Cost Element)
Rule could be like below ..
If GL_ACCNT BETWEEN '1000' and '2000' .
RESULT = 0BALANCE .
ELSEIF GL_ACCNT BETWEEN '2001' and '3000' .
RESULT = 0BALANCE * ( -1 ) .
ELSE < Your default case>) .
Based on the characteristic selection at BO end, it would automatically be summed up .
I would prefer to do this at End Routine level , than field routine for better performance
Regards
Anindya
Syntax is not correct. Where should I exactly write this?
In the Result=. ?
PROGRAM trans_routine.
*---------------------------------------------------------------------*
* CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
PUBLIC SECTION.
* Attributs
DATA:
p_check_master_data_exist
TYPE RSODSOCHECKONLY READ-ONLY,
*- Instance for getting request runtime attributs;
* Available information: Refer to methods of
* interface 'if_rsbk_request_admintab_view'
p_r_request
TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
PRIVATE SECTION.
TYPE-POOLS: rsd, rstr.
* Rule specific types
TYPES:
BEGIN OF _ty_s_SC_1,
* InfoObject: 0BALANCE Cumulative Balance.
BALANCE TYPE /BI0/OIBALANCE,
* InfoObject: 0CURRENCY Currency Key.
CURRENCY TYPE /BI0/OICURRENCY,
* Field: RECORD.
RECORD TYPE RSARECORD,
END OF _ty_s_SC_1.
TYPES:
BEGIN OF _ty_s_TG_1,
* InfoObject: ZKFTEST KF TEST.
/BIC/ZKFTEST TYPE /BIC/OIZKFTEST,
END OF _ty_s_TG_1.
*$*$ begin of global - insert your declaration only below this line *-*
... "insert your code here
*$*$ end of global - insert your declaration only before this line *-*
METHODS
compute_ZKFTEST
IMPORTING
request type rsrequest
datapackid type rsdatapid
SOURCE_FIELDS type _ty_s_SC_1
segid type RSBK_SEGID
EXPORTING
RESULT type _ty_s_TG_1-/BIC/ZKFTEST
monitor type rstr_ty_t_monitor
RAISING
cx_rsrout_abort
cx_rsrout_skip_record
cx_rsrout_skip_val
cx_rsbk_errorcount.
METHODS
invert_ZKFTEST
IMPORTING
i_th_fields_outbound TYPE rstran_t_field_inv
i_r_selset_outbound TYPE REF TO cl_rsmds_set
i_is_main_selection TYPE rs_bool
i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
i_r_universe_inbound TYPE REF TO cl_rsmds_universe
CHANGING
c_th_fields_inbound TYPE rstran_t_field_inv
c_r_selset_inbound TYPE REF TO cl_rsmds_set
c_exact TYPE rs_bool.
ENDCLASS. "routine DEFINITION
*$*$ begin of 2nd part global - insert your code only below this line *
... "insert your code here
*$*$ end of 2nd part global - insert your code only before this line *
*---------------------------------------------------------------------*
* CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.
*----------------------------------------------------------------------*
* Method compute_ZKFTEST
*----------------------------------------------------------------------*
* This subroutine allows the mapping from source to target fields
* of a transformation rule using ABAP for application specific
* coding.
*----------------------------------------------------------------------*
* Customer comment:
*----------------------------------------------------------------------*
METHOD compute_ZKFTEST.
* IMPORTING
* request type rsrequest
* datapackid type rsdatapid
* SOURCE_FIELDS-BALANCE TYPE /BI0/OIBALANCE
* SOURCE_FIELDS-CURRENCY TYPE /BI0/OICURRENCY
* EXPORTING
* RESULT type _ty_s_TG_1-/BIC/ZKFTEST
DATA:
MONITOR_REC TYPE rsmonitor.
*$*$ begin of routine - insert your code only below this line *-*
... "insert your code here
*-- fill table "MONITOR" with values of structure "MONITOR_REC"
*- to make monitor entries
... "to cancel the update process
* raise exception type CX_RSROUT_ABORT.
... "to skip a record"
* raise exception type CX_RSROUT_SKIP_RECORD.
... "to clear target fields
* raise exception type CX_RSROUT_SKIP_VAL.
RESULT = .
*$*$ end of routine - insert your code only before this line *-*
ENDMETHOD. "compute_ZKFTEST
*----------------------------------------------------------------------*
* Inverse method invert_ZKFTEST
*----------------------------------------------------------------------*
* This subroutine needs to be implemented only for direct access
* (for better performance) and for the Report/Report Interface
* (drill through).
* The inverse routine should transform a projection and
* a selection for the target to a projection and a selection
* for the source, respectively.
* If the implementation remains empty all fields are filled and
* all values are selected.
*----------------------------------------------------------------------*
* Customer comment:
*----------------------------------------------------------------------*
METHOD invert_ZKFTEST.
* IMPORTING
* i_r_selset_outbound TYPE REF TO cl_rsmds_set
* i_th_fields_outbound TYPE HASHED TABLE
* i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
* i_r_universe_inbound TYPE REF TO cl_rsmds_universe
* CHANGING
* c_r_selset_inbound TYPE REF TO cl_rsmds_set
* c_th_fields_inbound TYPE HASHED TABLE
* c_exact TYPE rs_bool
*$*$ begin of inverse routine - insert your code only below this line*-*
... "insert your code here
*$*$ end of inverse routine - insert your code only before this line *-*
ENDMETHOD. "invert_ZKFTEST
ENDCLASS. "routine IMPLEMENTATION
That was just a pseudo code for field level routine .
Your code would be like below, it is difficult to write exact code . Please follow the instruction.
1. Map both GL_Account( or your source field name for GL Account ) and Balance to your target key figure .
2. Choose Routine . And put something like this
IF SOURCE_FIELDS-GL_ACCOUNT BETWEEN 'XXXXXXX" AND 'YYYYYY' .
RESULT = SOURCE_FIELDS-BALANCE .
ELSEIF SOURCE_FIELDS-GL_ACCOUNT BETWEEN 'AAAAAA" AND 'BBBBBB' .
RESULT = SOURCE_FIELDS-BALANCE * ( -1 ) .
ENDIF.
ENDIF .
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.