METHOD GLOBAL_END.
FIELD-SYMBOLS:
<RESULT_FIELDS> TYPE _ty_s_TG_1.
DATA: MONITOR_REC TYPE rstmonitor.
* Note the _M class are not considered for DTP execution.
* ABAP Breakpoints must be set in the generated program instead
* ABAP Breakpoints within an ABAP End-Routine must be set
* in the _A class if the transformation runtime is set to SAP HANA!
**** begin of routine - insert your code only below this line ****
LOOP AT result_package ASSIGNING <result_fields>.
<result_fields>-calmonth2 = <result_fields>-fiscper3+1(2).
CONCATENATE <result_fields>-calyear <result_fields>-calmonth2 INTO
<result_fields>-calmonth.
ENDLOOP.
**** end of routine - insert your code only before this line ****
ENDMETHOD.
METHOD GLOBAL_START.
FIELD-SYMBOLS:
<SOURCE_FIELDS> TYPE _ty_s_SC_1.
DATA: MONITOR_REC TYPE rstmonitor.
* Note the _M class are not considered for DTP execution.
* ABAP Breakpoints must be set in the generated program instead
**** begin of routine - insert your code only below this line ****
... "insert your code here
DATA: IT_SOURCE_PACKAGE TYPE STANDARD TABLE OF _TY_S_SC_1,
WA_SOURCE_PACKAGE TYPE _TY_S_SC_1.
**Defining the structure******
TYPES: BEGIN OF PREFIX,
COMP_CODE(4) TYPE C,
SF_CC_PREFIX_A(10) TYPE C,
SF_CC_PREFIX_B(10) TYPE C,
B4_CC_PREFIX(10) TYPE C,
END OF PREFIX.
**Defining internal table and Work area**************
DATA: LT_PREFIX TYPE STANDARD TABLE OF PREFIX,
LS_PREFIX TYPE PREFIX.
***********************************************************
CLEAR : WA_SOURCE_PACKAGE, LT_PREFIX, LS_PREFIX.
REFRESH : IT_SOURCE_PACKAGE.
**Select the data and put into internal table ***************
SELECT COMP_CODE SF_CC_PREFIX_A SF_CC_PREFIX_B B4_CC_PREFIX FROM /BIC/APAMSPDP012
INTO corresponding fields of TABLE LT_PREFIX
FOR ALL ENTRIES IN SOURCE_PACKAGE WHERE comp_code = source_package-company_code.
***********************************************************************
DATA: len_prefix_a type i,
len_prefix_b type i,
len_sf_cc type i,
b4_cc(15) type c,
source_cc_prefix(15) type c.
SORT source_package BY company_code.
LOOP AT SOURCE_PACKAGE INTO WA_SOURCE_PACKAGE.
READ TABLE LT_PREFIX INTO LS_PREFIX
WITH KEY comp_code = WA_SOURCE_PACKAGE-company_code
BINARY SEARCH.
**** Checking if the mapping ADSO PAMSPDP01 contains such a 0comp_code,
**** and b4_cc_perfix is filled there and either sf_cc_prefix_a or sf_cc_prefix_b
is filled.
IF ( SY-SUBRC = 0 and LS_PREFIX-b4_cc_prefix <> 'n/a' ).
SHIFT WA_SOURCE_PACKAGE-cost_center LEFT DELETING LEADING '0'.
len_prefix_a = strlen( LS_PREFIX-sf_cc_prefix_a ).
len_prefix_b = strlen( LS_PREFIX-sf_cc_prefix_b ).
**** Checking if the cost centers from the source ADSO PEHSADU01
**** have a prefix from the mapping ADSO PAMSPDP01 - sf_cc_prefix_a or
sf_cc_prefix_b.
IF LS_PREFIX-sf_cc_prefix_a <> 'n/a' and len_prefix_a <=
strlen( WA_SOURCE_PACKAGE-cost_center ).
IF len_prefix_a = 0.
source_cc_prefix = ''.
ELSE.
source_cc_prefix = WA_SOURCE_PACKAGE-cost_center(len_prefix_a).
ENDIF.
IF source_cc_prefix = LS_PREFIX-sf_cc_prefix_a and len_prefix_a <
strlen( WA_SOURCE_PACKAGE-cost_center ).
len_sf_cc = strlen( WA_SOURCE_PACKAGE-cost_center ) - len_prefix_a.
IF len_prefix_a > 0.
b4_cc = LS_PREFIX-b4_cc_prefix &&
WA_SOURCE_PACKAGE-cost_center+len_prefix_a(len_sf_cc).
ELSE.
b4_cc = LS_PREFIX-b4_cc_prefix && WA_SOURCE_PACKAGE-
cost_center.
ENDIF.
replace all occurrences of '-' in b4_cc with ''.
WA_SOURCE_PACKAGE-cost_center = b4_cc.
APPEND WA_SOURCE_PACKAGE TO IT_SOURCE_PACKAGE.
ELSE.
IF ( len_prefix_b < strlen( WA_SOURCE_PACKAGE-cost_center ) and
LS_PREFIX-sf_cc_prefix_b <> 'n/a' ).
IF len_prefix_b = 0.
source_cc_prefix = ''.
ELSE.
source_cc_prefix = WA_SOURCE_PACKAGE-
cost_center(len_prefix_b).
ENDIF.
IF source_cc_prefix = LS_PREFIX-sf_cc_prefix_b.
len_sf_cc = strlen( WA_SOURCE_PACKAGE-cost_center ) -
len_prefix_b.
IF len_prefix_b > 0.
b4_cc = LS_PREFIX-b4_cc_prefix &&
WA_SOURCE_PACKAGE-
cost_center+len_prefix_b(len_sf_cc).
ELSE.
b4_cc = LS_PREFIX-b4_cc_prefix && WA_SOURCE_PACKAGE-
cost_center.
ENDIF.
replace all occurrences of '-' in b4_cc with ''.
WA_SOURCE_PACKAGE-cost_center = b4_cc.
APPEND WA_SOURCE_PACKAGE TO IT_SOURCE_PACKAGE.
ELSE.
DELETE SOURCE_PACKAGE.
ENDIF.
ELSE.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDIF.
ELSE.
DELETE SOURCE_PACKAGE.
ENDIF.
ELSE.
DELETE SOURCE_PACKAGE.
ENDIF.
ENDLOOP.
REFRESH SOURCE_PACKAGE.
SOURCE_PACKAGE = IT_SOURCE_PACKAGE.
**** end of routine - insert your code only before this line ****
ENDMETHOD.