Professional Documents
Culture Documents
Enhancements in
SAP BW
Essential Guide for a BW developer
1 COPYRIGHT
NOTICE
Go to RSO2.
Enter name of your custom data source
Ex: ZDS_SALES01
Click on Create button.
Enter Application Component eg. 0CRM
Enter Descriptions
Click on Extraction by FM button.
Enter your FM name and your extract
structure name and finally save it.
Select required fields as selection fields
to filter the records in future and save
the Data source. Ex. Only two fields
VBELN and ERDAT are selected as
Selection Fields.
4.5 PREPARING CODE IN
EXTRACTION FUNCTION
MODULE TO EXTRACT DATA
FROM DATABASE TABLES INTO
DATASOURCE BASED ON THE
SELECTION FIELDS DATA-
Goto SE37.
Open your FM -
RSAX_BIW_GET_DATA_SALES01 in
change mode.
Go to its ‘Tables’ tab and provide the
name of Extract structure as associated
type for the table parameter E_T_DATA.
Ignore any errors occurred by pushing
the Enter key.
Go to Source code tab of the function
module, and enter the following code.
STATICS C1 TYPE CURSOR.
RANGES R_VBELN FOR VBAK-
VBELN.
RANGES R_ERDAT FOR VBAK-
ERDAT.
IF I_INITFLAG = SPACE.
IF C1 IS INITIAL.
“Select Sales order numbers
LOOP AT I_T_SELECT WHERE
FIELDNM = ‘VBELN’.
R_VBELN-SIGN = I_T_SELECT-
SIGN.
R_VBELN-OPTION =
I_T_SELECT-OPTION.
R_VBELN-HIGH = I_T_SELECT-
HIGH.
R_VBELN-LOW = I_T_SELECT-
LOW.
DATA_TRANSFORM and
HIER_TRANSFORM
When the existing Data Sources are not
providing the complete data according to
the current requirement, extra data fields
can be added to the existing fields and
data can be fetched for those fields by
Enhancement Process.
For Data source Enhancement, SAP has
provided two techniques.
1. Enhancement by Customer exits
2. Enhancement by BADIs
The repository object for Customer Exit
is called as Enhancement Object and its
name is RSAP0001. Its components can
be observed using the tcode SMOD.
They can be implemented using the tcode
CMOD.
The repository object for BADI
enhancements is called as BADI
definition and its name is RSU5-
SAPI_BADI. Its components can be
observed using the tcode SE18. They
can implemented using the tcode SE19.
Customer Exit can be implemented only
once, whereas BADIs can be
implemented multiple times and those
Implementation are independent of each
other.
7 STEPS FOR
CUSTOMER EXIT
ENHANCEMENT
7.1 ADDING EXTRA FIELDS
OF THE EXTRACT STRUCTURE
FUNCTION ZRSAX_BIW_GET_DATA_SALES0
*"---------------------------------------------------
-------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SBIWA_S_INTE
REQUNR
*" VALUE(I_ISOURCE) TYPE SBIWA_S_INTE
ISOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SBIWA_S_INTE
MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SBIWA_S_INT
INITFLAG OPTIONAL
*" VALUE(I_UPDMODE) TYPE SBIWA_S_IN
UPDMODE OPTIONAL
*" VALUE(I_DATAPAKID) TYPE SBIWA_S_IN
DATAPAKID OPTIONAL
*" VALUE(I_PRIVATE_MODE) OPTIONAL
*" VALUE(I_CALLMODE) LIKE ROARCHD2
CALLMODE OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_F
*" TABLES
*" I_T_SELECT TYPE SBIWA_T_SELECT OP
*" I_T_FIELDS TYPE SBIWA_T_FIELDS OP
*" E_T_DATA STRUCTURE ZES_SALES01 O
*" E_T_SOURCE_STRUCTURE_NAME OPT
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
*"---------------------------------------------------
-------------------
STATICS C1 TYPE CURSOR.
RANGES R_VBELN FOR VBAK-
VBELN.
RANGES R_ERDAT FOR VBAK-
ERDAT.
RANGES R_KUNNR FOR VBAK-
KUNNR.
DATA K(10) TYPE N.
DATA TS1 TYPE TZNTSTMPS.
DATA STARTDATE TYPE D.
DATA STARTTIME TYPE T.
DATA ENDDATE TYPE D.
DATA ENDTIME TYPE T.
IF I_INITFLAG = SPACE.
IF C1 IS INITIAL.
“Select Sales order numbers
LOOP AT I_T_SELECT WHERE
FIELDNM = ‘VBELN’.
R_VBELN-SIGN = I_T_SELECT-
SIGN.
R_VBELN-OPTION =
I_T_SELECT-OPTION.
“for adding leading zeroes to the
sales order number VBELN
CALL FUNCTION
‘NUMERIC_CHECK’
EXPORTING
STRING_IN = I_T_SELECT-
LOW
IMPORTING
STRING_OUT = R_VBELN-
LOW.
CALL FUNCTION
‘NUMERIC_CHECK’
EXPORTING
STRING_IN = I_T_SELECT-
HIGH
IMPORTING
STRING_OUT = R_VBELN-
HIGH.
APPEND R_VBELN.
CLEAR R_VBELN.
ENDLOOP.
“Select sales organization
LOOP AT I_T_SELECT WHERE
FIELDNM = ‘VKORG’.
R_VKORG-SIGN =
I_T_SELECT-SIGN.
R_ VKORG-OPTION =
I_T_SELECT-OPTION.
CALL FUNCTION
‘NUMERIC_CHECK’ “for
adding leading zeroes
EXPORTING
STRING_IN = I_T_SELECT-
LOW
IMPORTING
STRING_OUT = R_VKORG-
LOW.
CALL FUNCTION
‘NUMERIC_CHECK’
EXPORTING
STRING_IN = I_T_SELECT-
HIGH
IMPORTING
STRING_OUT = R_VKORG-
HIGH.
APPEND R_VKORG.
CLEAR R_VKORG.
ENDLOOP.
LOOP AT I_T_SELECT WHERE
FIELDNM = ‘KUNNR’.
R_VKORG-SIGN =
I_T_SELECT-SIGN.
R_ VKORG-OPTION =
I_T_SELECT-OPTION.
CALL FUNCTION
‘NUMERIC_CHECK’ “for
adding leading zeroes
EXPORTING
STRING_IN = I_T_SELECT-
LOW
IMPORTING
STRING_OUT = R_KUNNR-
LOW.
CALL FUNCTION
‘NUMERIC_CHECK’
EXPORTING
STRING_IN = I_T_SELECT-
HIGH
IMPORTING
STRING_OUT = R_KUNNR-
HIGH.
APPEND R_KUNNR.
CLEAR R_KUNNR.
ENDLOOP.
LOOP AT I_T_SELECT WHERE
FIELDNM =
‘TIMSTMP’. “Time
stamp field
TS1 = I_T_SELECT-LOW.
ENDLOOP.
IF TS1 IS INITIAL. “1st time
perform full load
OPEN CURSOR WITH HOLD C1
FOR
SELECT VBELN
VKORG
KUNNR
NETWR
WAERK
FROM VBAK
WHERE VBELN IN
R_VBELN AND
VKORG IN
R_VKORG AND
KUNNR IN
R_KUNNR.
ELSE. “2nd time perform delta
load
CONVERT TIME STAMP TS1
TIME ZONE SY-ZONLO
INTO DATA STARTDATE
TIME STARTTIME.
OPEN CURSOR WITH HOLD C1
FOR
SELECT VBELN
VKORG
KUNNR
NETWR
WAERK
FROM VBAK
WHERE VBELN IN
R_VBELN AND
VKORG IN
R_VKORG AND
KUNNR IN
R_KUNNR AND
( ( ERDAT >=
STARTDATE AND ERZET >=
STARTTIME ) OR (AEDAT >=
STARTDATE).
ENDIF.
ENDIF.
FETCH NEXT CURSOR C1
INTO CORRESPONDING FIELDS
OF TABLE E_T_DATA
PACKAGE SIZE I_MAZSIZE.
IF SY-SUBRC <> 0.
CLOSE CURSOR C1.
RAISE NO_MORE_DATA.
ENDIF.
ENDIF.
ENDFUNCTION.
Save and activate your function module.
This is an optional step: To test the
function module go to SE37 and call it
two times in succession- one call for
initialization and the second to read
data. This is actually no necessary but
it’s a good way to check.
9.5 STEP 5: GO TO
TRANSACTION RSA3 TO TEST
THE DATA SOURCE