问题链接:reading masterdata of attribute in BI 7.0
因为我最近就这个问题有所总结。在我的SAP BW 350的课程中,我详细讲述了Transformation的一些应用场景。其中大概有8-10个小节讲述Transformation的内容。基本上涵盖了SAP BW中写Transformation中的Start routine和Transfer routine和End routine的各种场景。既有比较官方的内容讲述,也有来自于一些How-to文档的内容讲述,也有3个来自项目场景的内容提炼、精减后内容总结。其中SAPBI350_U和SAPBI350_V两个小节讲述了如下内容:
1. How to read externel table such as master date table or DSO table in start routine. |
![]() |
SDN上的回答内容如下:
The scenrio is simplied based on CVS file, our real scenrios are logistical data models which date are from shipping item, order itme data source.
We have a infoobject named material which has a attribute material type. its data like this:
Material Material_Type
MAT001 ZDIE
MAT002 ZIFG
MAT003 ZDIE
MAT004 ZIFG
We hava a another DSO named delivery ODS which data like below:
Material DeliveryDoc DeliveryItem DeliveryDate
MAT001 12345678 1 20070501
MAT002 12345679 1 20070502
MAT003 12000000 1 20070503
MAT004 12000001 1 20070504
We have a another DSO named invoice ODS which data like below:
Material InvoiceDoc InvoiceItem Billingdate ReferedDeliveryDoc ReferedDeliveryItem
MAT001 30000000 1 20080101 12345678 1
MAT002 30000001 1 20080102 12345679 1
MAT003 30000002 1 20080103 12000000 1
MAT004 30000003 1 20080104 12000001 1
Our business requirements is:
1. Need to create the third DSO which will merge data from the above two DSOs.
2. the third DSO name “Deliveried sales order info DSO” which has the following model:
Material InvoiceDoc InvoiceItem DeliveryDoc DeliveryItem Act_Goods_Issue_DATE
3. The Act_Goods_Issue_DATE will be filled from delivery ODS or invoice ODS, the rule is if material type is “ZDIE” which means it is a non-physical product (service product), the Act_Goods_Issue_DATE should be filled from Billingdate of invoice ODS. if the material type is “ZIFG” that means it is a physical product. the the Act_Goods_Issue_DATE should be filled from the DeliveryDate of delivery ODS.
Implement mothod:
1. We create a transformation from delivery ODS to “Deliveried sales order info DSO”, most infoobjects were mapped directly.
2. we create a transformation from invoice ODS to “Deliveried sales order info DSO”. we create a start routine for Act_Goods_Issue_DATE. the main code is like below.
*$*$ begin of global – insert your declaration only below this line *-*
DATA: G_MATERIAL TYPE TABLE OF /BIC/PIO_MATG.
DATA: G_DSO_DELI TYPE TABLE OF /BIC/AZ_ODS200.
*$*$ end of global – insert your declaration only before this line *-*
*$*$ 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.
* Get material master date into the internal table G_MATERIAL
SELECT * INTO TABLE G_MATERIAL
FROM /BIC/PIO_MATG
FOR ALL ENTRIES IN SOURCE_PACKAGE
WHERE /BIC/IO_MATG = SOURCE_PACKAGE-/BIC/IO_MATG.
SORT G_MATERIAL BY /BIC/IO_MATG.
* Get delivery DSO active table data into the internal table G_DSO_DELI
SELECT * INTO TABLE G_DSO_DELI
FROM /BIC/AZ_ODS200
FOR ALL ENTRIES IN SOURCE_PACKAGE
WHERE /BIC/ZDOC002 = SOURCE_PACKAGE-/BIC/ZDOC001
AND /BIC/ZITEM02 = SOURCE_PACKAGE-/BIC/ZITEM0001.
SORT G_DSO_DELI BY /BIC/ZDOC002 /BIC/ZITEM02.
*$*$ end of routine – insert your code only before this line *-*
3. Then add the fields Material,Billingdate,ReferedDeliveryDoc,and ReferedDeliveryItem as input for the infoobject Act_Goods_Issue_DATE and write transfer routine like below:
*$*$ 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.
* result value of the routine
DATA : W_MATERIAL TYPE /BIC/PIO_MATG.
DATA : W_DELIVERY TYPE /BIC/AZ_ODS200.
READ TABLE G_MATERIAL INTO W_MATERIAL WITH KEY /BIC/IO_MATG =
SOURCE_FIELDS-/BIC/IO_MATG
BINARY SEARCH.
IF SY-SUBRC EQ 0.
IF W_MATERIAL-/BIC/IO_MATTY = ‘ZDIE’.
* if the material is a service product.
RESULT = SOURCE_FIELDS-/BIC/ZDATE01.
ELSE.
* if the material is a non service product, then search internal table G_DSO_DELI to get DeliveryDate.
READ TABLE G_DSO_DELI INTO W_DELIVERY WITH KEY
/BIC/ZDOC002 = SOURCE_FIELDS-/BIC/ZDOC001
/BIC/ZITEM02 = SOURCE_FIELDS-/BIC/ZITEM0001
BINARY SEARCH.
IF SY-SUBRC EQ 0.
* Assign DeliveryDate “/BIC/ZDATE02″ to result.
RESULT = W_DELIVERY-/BIC/ZDATE02.
ENDIF.
ENDIF.
ENDIF.
*$*$ end of routine – insert your code only before this line *-*
- 本文固定链接: http://www.yitaiedu.com/blog/?p=162
- 转载请注明: yitai 于 益泰 发表