10
ABAP in BW

ABAP in BW

Embed Size (px)

Citation preview

Page 1: ABAP in BW

ABAP in BW

Page 2: ABAP in BW

ABAP in BW

• Where can we write ABAP routines that are BW Relevant?

• User Exits (Data Source Enhancements).

• Update/Transfer Routines. (Start routines & Info Object Routines)

• InfoPackage Routines.

• Customer Exits (Variable Exits).

Page 3: ABAP in BW

ABAP in BW

Sample Code for User Exits (Data Source Enhancements)

data: l_s_icctrcst like icctrcst, l_tabix like sy-tabix. case i_isource. when '0CO_OM_CCA_1'. loop at c_t_data into l_s_icctrcst. l_tabix = sy-tabix. select single * from z0001 where kokrs = l_s_icctrcst-kokrs and kostl = l_s_icctrcst-kostl. if sy-subrc = 0. l_s_icctrcst-zfield1 = z0001-zfield1. l_s_icctrcst-zfield2 = z0001-zfield2. modify c_t_data from l_s_icctrcst index l_tabix. endif. endloop. when others. exit. endcase. Go through the below attachment on how to enhance the data source.

Enhancements

Page 4: ABAP in BW

ABAP in BW

Sample Code for Update/Transfer Routines.

Update Rules Start Routines:

DELETE DATA_PACKAGE WHERE /BIC/YSRECTY = '4' OR /BIC/YSRECTY = '5' OR /BIC/YSRECTY = '6' OR /BIC/YSRECTY = '7' OR /BIC/YSRECTY = '11' OR /BIC/YSRECTY = '12'.LOOP AT DATA_PACKAGE .*--Standard Price SELECT SINGLE price_std FROM /bi0/pmat_plant INTO DATA_PACKAGE-/bic/zfor_cogs WHERE mat_plant = DATA_PACKAGE-mat_plant.*-- Salesman , Sales rep SELECT SINGLE /bic/zsalesman /bic/zsalesrep FROM /bi0/pcustomer INTO (DATA_PACKAGE-/bic/zsalesman,DATA_PACKAGE-/bic/zsalesrep) WHERE customer = DATA_PACKAGE-customer.MODIFY DATA_PACKAGE .ENDLOOP.

Page 5: ABAP in BW

ABAP in BW

Update Rules:

CASE COMM_STRUCTURE-/BIC/YSRECTY. WHEN '62' OR '63' OR '64' OR '65'. RESULT = 0. WHEN OTHERS. RESULT = COMM_STRUCTURE-/BIC/YSOPQTY1. ENDCASE. OR

RESULT = COMM_STRUCTURE -PLANPERIOD(4).

Transfer Rules: DATA: S_DATA TYPE TRANSFER_STRUCTURE .LOOP AT DATAPAK INTO S_DATA .<Insert your Transformations here>MODIFY DATAPAK FROM S_DATA.ENDLOOP.

OR RESULT = TRAN_STRUCTURE-PLANPERIOD(4).

Page 6: ABAP in BW

ABAP in BW

Sample Code for InfoPackage Routines.

data: l_idx like sy-tabix.read table l_t_range with keyfieldname = 'CALDAY'.l_idx = sy-tabix.*....l_t_range-low = sy-datum.l_t_range-high = sy-datum + 1.l_t_range-sign = 'I'.l_t_range-option = 'BT'.

modify l_t_range index l_idx.p_subrc = 0.

Page 7: ABAP in BW

ABAP in BW

Sample Code for Customer Exits (Variable Exits).

CASE i_vnam.

WHEN 'ZSYSDATE' .

IF i_step = 1.

l_s_range-low = sy-datum.l_s_range-sign = 'I'.l_s_range-opt = 'EQ'.APPEND l_s_range TO e_t_range.

ENDIF.

Page 8: ABAP in BW

ABAP in BW

WHEN 'ZCWGE'.

IF I_STEP = 2.CLEAR L_S_RANGE.READ TABLE I_T_VAR_RANGE WITH KEY VNAM = ' ZSYSDATE 'INTO W_I_T_VAR_RANGE.IF SY-SUBRC = 0.V_DAT = W_I_T_VAR_RANGE-LOW.CALL FUNCTION 'DATE_GET_WEEK'EXPORTINGDATE = V_DATIMPORTINGWEEK = V_CW.L_S_RANGE-LOW = V_CW.L_S_RANGE-SIGN = 'I'.L_S_RANGE-OPT = 'EQ'.APPEND L_S_RANGE TO E_T_RANGE.EXIT.ENDIF.ENDIF.

WHEN OTHERS.endcase.

Page 9: ABAP in BW

ABAP in BW

Go through the below document explains more about the ABAP in BW

ABAP in BI

Page 10: ABAP in BW

ABAP in BW

For any queries mail me at [email protected]

Questions?