You are on page 1of 18

1

SAP BW ABAP

BW ABAP ABAP
BW
R3 SAP BW
ABAP SAP ABAP
R3 R3 BW

ABAP
BW ABAP
SAP R3 BW ABAP
BW
ODS InfoCube
BW R3 BW ABAP

Technical Area
BEx User Exit

key figure
BEx

R/3 User Exit

R3 CMOD
BW

BW Transfer rules

R3 BW BW
InSource

BW Update Rules

ODS InfoCube

BW Start Routines

BW Start routine
data element

R3 BW ABAP
1


ABAP
2

RSO2
ABAP function moduleuser exit

For 1
ABAP

BW
RSA6 Post Processing Datasources
BW R3
R3 BW CMOD BW project
display components F7
BW
User Exit

Description

SAPLRSAU_001

Transactional data user exit

SAPLRSAU_002

Master Data User exit

SAPLRSAU_003

Optional

SAPLRSAU_004

Optional

R3
2LIS_02_ITM
BW SAPLRSAU_001
SAPLRSAU_001 ZZRSAU01

For 2
SE11 View, Z****

development class development class


view

base table
view
view RSO2
RSA3
RSA3 view

select
Not recommended:Select * from /bi0/mcustomer.
Check : soursystem = I2P and objvers = 'A'.
Endselect.

Recommended:Select * from /bi0/mcustomer where soursystem = I2P and objvers = 'A'.


Endselect.

ABAP
Not recommended
Maxamount = 0.
Select * from /bic/mzordods where soursystem = I2P.
Check mzordods-zamount>maxamount.
Maxamount = mzordods-zamount.
Endselect.

select internal table



Not recommended:Refresh : itab_cust_t
select *
from /bi0/tcustomer
into itab_cust_t
append itab_cust_t.
clear itab_cust_t.

Recommended:Refresh : itab_cust_t
select *
from /bi0/tcustomer
into table itab_cust_t

Not Recommended
Read table itab_cust_t with key soursystem=I2P.

Recommended
Read table itab_cust_t with key soursystem=I2P binary search.

append
Not Recommended
Loop at itab_cust_t.

Append itab_cust_t to itab_cust_t1.


EndLoop.

Recommended
Append lines of itab_cust_t to itab_cust_t1.

1 select distinct
2 select ... for update
3 Order by, group by, having clause
4 Joins
FOR ALL Entries outer join
1 select key
2 FOR ALL Entries
3 FOR ALL Entries
Not Recommended
Loop at itab_cust_t.
Select single * from /bi0/mcustomer into itab_cust_m
Where soursystem= itab_cust_t-soursystem.
Append itab_cust_m.
EndLoop.

Recommended:Select * from /bi0/mcustomer appending table itab_cust_m


For all entries in itab_cust_t
Where soursystem= itab_cust_t-soursystem.

where where
ABAP Order By

SE30 ABAP
ST05 SQL

[BW] SAP BW Routine


[]

franklmin

2013-5-7 11:26:13 |

.
ABAP ,. TYPES
.., ABAP .,
:

:.,
, .
.,.
Invertierungsroutine

,:
1. *$*$ ... *$*$ ..., 'CLASS-DA
.,,'DATA'.
,,,,
.

:
,,, 'CLASS,,.,
.
,,'CLASS-DATA' 'DATA'.

2. *$*$... *$*$...,.
SAP COMMIT ABAP COMMIT WORK.
. DB COMMIT DB_COMMIT
3. .
4. .

,.

..
...

REQEUST:
DATAPAKID:

MONITOR: . MONITOR_REC (

SOURCE_PACKAGE:

CX_RSROUT_ABORT: cx rsrout_abort ,
..,.

ERP : (FI_GL_1) FIGL:


,,
1. . (UMSOL) (UMHAB)
(0DEBIT) (0CREDIT).
2. ..
3. ,:
*$*$ - *-*
... "
DELETE SOURCE_PACKAGE UMHAB = 0 UMSOL = 0
*$*$ - *-*
,.
4. .
5. ..

.,
,.'UNIT',
,, 'PC'.,.

REQEUST:
DATAPAKID:

SOURCE_FIELDS:

MONITOR:. MONITOR_REC (
RESULT: RESULT.
CURRENCY (): ,.
UNIT(): ,.

,:
CX_RSROUT_SKIP_RECORD:, cx_rsrou
.
CX_RSROUT_ABORT:, cx_rsrout_abort ,
,..,

:
ERP : (FI_GL_1) FIGL:(
/(0FI_DBCRIND),
1. ,, /(0FI
2. (UMSOL) (UMHAB),
.
3. ..
4. , D C :
*$*$ - *-*
... "
*
if SOURCE_FIELDS-umhab ne 0 and SOURCE_FIELDS-umsol eq 0.
RESULT = 'D'.
elseif SOURCE_FIELDS-umhab eq 0 and SOURCE_FIELDS-umsol ne 0.
RESULT = 'C'.
else.
monitor_rec-msgid = 'ZMESSAGE'.
monitor_rec-msgty = 'E'.
monitor_rec-msgno = '001'.
monitor_rec-msgv1 = 'ERROR, D/C Indicator'.
monitor_rec-msgv2 = SOURCE_FIELDS-umhab.
monitor_rec-msgv3 = SOURCE_FIELDS-umsol.
RAISE EXCEPTION TYPE CX_RSROUT_ABORT.
endif.
*$*$ - *-*
:

, D.
, C.
,,.
5. .
6. ,.

7. .

,.
.,.

REQEUST:
DATAPAKID:

MONITOR: . MONITOR_REC (

RESULT_PACKAGE:

CX_RSROUT_ABORT: cx rsrout_abort ,
..,

ERP : (FI_GL_1) FIGL: (0FIGL


,/ (ZPLACTUAL) .
. 10(), A / (ZPLACTUAL) ;
/(ZPLACTUAL) .
1. ...
2. :
*$*$ begin of routine - insert your code only below this line
... "insert your code here
loop at RESULT_PACKAGE assigning <RESULT_FIELDS>
where vtype eq '010' or vtype eq '020'.
case <RESULT_FIELDS>-vtype.
when '010'.
<RESULT_FIELDS>-/bic/zplactual = 'A'. "Actual
when '010'.
<RESULT_FIELDS>-/bic/zplactual = 'P'. "Plan
endcase.
endloop.
*$*$ end of routine - insert your code only before this line
*-*
result_package , 10 20 .
(ZPLACTUAL) .
3. .
4. ..

()
.,
, .
.,.
(Invertierungsroutine)


SAP

admin 2013-9-1 08:43


:

QQ QQ

franklmin

| 2013-5-7 11:26:33 |

'HERR' 'FRAU' PASSFO


'MR' 'MRS'

*$*$ - *-*
CASE SOURCE_FIELDS-passform.
WHEN 'HERR'. RESULT = 'MR'.
WHEN 'FRAU'. RESULT = 'MRS'.
WHEN OTHERS. RESULT = space.
ENDCASE.
*$*$ - *-*
ENDMETHOD. "compute_0PASSFORM

*$*$ - *-*
DATA l_r_set TYPE REF TO cl_rsmds_set.
IF i_r_selset_outbound->is_universal( ) EQ rsmds_c_boolean-true.
* If query requests all values for characteristic 0PASSNAME
* request also all values from source field PASSNAME

c_r_selset_inbound = cl_rsmds_set=>get_universal_set( ).
c_exact = rs_c_true. "Inversion is exact
ELSE.
TRY.
IF me->p_r_set_mrs IS INITIAL.
* Create set for condition PASSFORM = 'FRAU'
me->p_r_set_mrs =i_r_universe_inbound->create_set_from_string( 'PASSFORM = ''FRA
ENDIF.
IF me->p_r_set_mr IS INITIAL.
* Create set for condition PASSFORM = 'HERR'
me->p_r_set_mr =i_r_universe_inbound->create_set_from_string( 'PASSFORM = ''HER
ENDIF.
IF me->p_r_set_space IS INITIAL.
* Create set for condition NOT ( PASSFORM = 'FRAU' OR PASSFORM= 'HERR' )
l_r_set = me->p_r_set_mr->unite( me- >p_r_set_mrs).
me->p_r_set_space = l_r_set->complement( ).
ENDIF.
*
c_r_selset_inbound = cl_rsmds_set=>get_empty_set( ).
* 'MR'
IF i_r_selset_outbound->contains( 'MR' ) EQrsmds_c_boolean-true.
c_r_selset_inbound = c_r_selset_inbound->unite(me>p_r_set_mr ).
ENDIF.
* 'MRS'
IF i_r_selset_outbound->contains( 'MRS' ) EQrsmds_c_boolean-true.
c_r_selset_inbound = c_r_selset_inbound->unite(me>p_r_set_mrs ).
ENDIF.
*
IF i_r_selset_outbound->contains( space ) EQrsmds_c_boolean-true.
c_r_selset_inbound = c_r_selset_inbound->unite(me>p_r_set_space ).
ENDIF.
c_exact = rs_c_true. "Inversion is exact
CATCH cx_rsmds_dimension_unknown
cx_rsmds_input_invalid
cx_rsmds_sets_not_compatible
cx_rsmds_syntax_error.
* Normally, this should not occur
* If the exception occurs request all values from source
* for this routine to be on the save side
c_r_selset_inbound = cl_rsmds_set=>get_universal_set( ).
c_exact = rs_c_false. "Inversion is no longer exact
ENDTRY.
ENDIF.
*
* 0PASSFORM PASSFORM
READ TABLE i_th_fields_outbound
WITH TABLE KEY segid = 1 "Primary segment
fieldname = 'PASSFORM'
TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.

* Characteristic 0PASSFORM is needed


* ==> request (only) field PASSFORM from the source for this routine
DELETE c_th_fields_inbound
WHERE NOT ( segid EQ 1 OR
fieldname EQ 'PASSFORM' ).
ELSE.
* Characteristic 0PASSFORM is not needed
* ==> don't request any field from source for this routine
CLEAR c_th_fields_inbound.
ENDIF.
*$*$ - *-*

BW:Start Routine
Start Routine 3.x Start Routine 7.0 End Routine
PSA Target
3.X 7.0

Start Routine

Class CLASS - DEFINITION CLASS - IMPLEMENTATION


DEFINITION
CLASS class DEFINITION [ [class_options].
[PUBLIC SECTION.
[components]]
[PROTECTED SECTION.
[components]]
[PRIVATE SECTION.
[components]]

ENDCLASS.
PublicPrivateProtected
IMPLEMENTATION Method Method
CLASS class IMPLEMENTATION.
...
METHOD ...
...
ENDMETHOD.
...
ENDCLASS.
Method

PS
FIELD-SYMBOLS:
<SOURCE_FIELDS>

TYPE _ty_s_SC_1.

key
Loop Select
DATA:
Z_TEMP TYPE /BIC/OIZMAT3,
Z_DATA TYPE _ty_s_SC_1.
LOOP AT SOURCE_PACKAGE INTO Z_DATA.
SELECT SINGLE /BIC/ZMAT3
INTO Z_TEMP
FROM /BI0/PMATERIAL
WHERE OBJVERS = 'A' AND /BIC/ZMAT3 = Z_DATA-KEY1.
IF SY-SUBRC <> 0.

DELETE SOURCE_PACKAGE WHERE KEY1 = Z_DATA-KEY1.


ENDIF.
ENDLOOP.
BUG
KEY1 '0901'/BI0/PMATERIAL key'09'
/BIC/ZMAT3 CHAR2 KEY1 SUBRC 0...
SAP Java A.equal(B)~
/BIC/ZMAT3 EQ Z_DATA-KEY1 ...
PS/BIC/ZMAT3 KEY1 Select
BW ABAP Loop
DATA:
Z_SIGN TYPE CHAR1,
Z_TABLE TYPE TABLE OF /BI0/PMATERIAL,
Z_TEMP1 TYPE /BI0/PMATERIAL,
Z_TEMP2 TYPE /BI0/PMATERIAL,
Z_DATA TYPE _ty_s_SC_1.
SELECT *
INTO Z_TEMP1
FROM /BI0/PMATERIAL
WHERE OBJVERS = 'A'.
APPEND Z_TEMP1 TO Z_TABLE.
ENDSELECT.
LOOP AT SOURCE_PACKAGE INTO Z_DATA.
Z_SIGN = 'F'.
LOOP AT Z_TABLE INTO Z_TEMP2 WHERE /BIC/ZMAT3 = Z_DATA-KEY1.
Z_SIGN = 'T'.
ENDLOOP.
IF Z_SIGN <> 'T'.
DELETE SOURCE_PACKAGE WHERE KEY1 = Z_DATA-KEY1.
ENDIF.
ENDLOOP.

Loop...
Select Loop at where Select where
Start Routine
PSA SOURCE_PACKAGE
SOURCE_PACKAGE TR

1
End Routine

4
Routines in SD

Routines in SAP SD
Any Business requirement can be met through Standard Configuration or any customized
development.
Customized requirements in SD consists of Program, Routines, Exits, BAPI & BADI etc..

Following is the process of creation of Routines:


Routines in Sales & Distribution plays a vital role. Business Requirements can be met by
creating and configuring in required applications i.e. it can be a Copy control Routine
or any Pricing Requirement Routine or any Out Put Requirement Routine.
Step by Step Process:VOFM is the Transaction, where we can create New Routine.
1. Go to VOFM Transaction Code
2. On the Menu Select required Application i.e. Requirements -Pricing
3. Enter any Number in between 600 to 999 for Custom Developments.
4. On entering Pop Screen appears ask for Access Key (We have to remember that Every New
Routine needs an Access Key)
5. We have to send the Object number and installation details to the BASIS
6. BASIS will provide the Access Key
7. Once the Access Key is received we can do modification with the help of Technical
Consultant.

8. Enter the Routine Number, description and insert the Access Key
9. Now the ABAP Editor will open and required code can be copied from Standard SAP
Routine and Custom Code Can be developed.
10. Once the coding is completed we have to Activate the Routine
11. Select the Routine and Go to Edit - Activate
12. Ensure that Active check box is ticked upon Activation of the Routine.
13. Double click on the routine will enter into ABAP Editor, we have to generate the
Routine
14. Go to Program and select Generate
16 A screen pops up with the related Main Programs i.e.SAPLV61A and select all required
main programs wherever the Routine is being called.
17 Once the Routine is Generated and Activated, We can configure the Routine in the
config.
18 Configure the Routine in required applications and do the Testing
19 We have to transport the Workbench Request i.e. Routine first ,then only we have to
transport customizing request
20 We have to Activate and Generate the Routine in each and every client it got
transported.
http://sapdocs.info/2008/12/24/routines-in-sd/

SD Routines

SAP SD Routines

SD RoutineBAPI BADI

Routine
Routine
Routine Routine
Routine

VOFM Routine ()
1. VOFM
2. -
3. 600 999 Routine

4. Routine

5. BASIS
6. BASIS
7.
8. Routine
9. ABAP SAP Routine

10. Routine
11. Routine
12. Routine
13. Routine ABAP Routine
14.
16. SAPLV61A
Routine
17. Routine Routine
18. Routine
19. Routine
20. Client Routine

You might also like