Code in update rule
Hi Guru's
Can anyone explain in detail the meaning of the code blow in update rule.
<b>tmpwk TYPE /bic/cs8ismactp-calweek,
botwk TYPE /bic/cs8ismactp-calweek,
first_rec VALUE 'T',
var_maxline TYPE i,
var_country(2) TYPE c,
ret_code TYPE i,
out_value TYPE /bic/cs8ismactp-/bic/g_pivpri.</b>
Thanks in Advance
Regards
K Kumar
Hi Sam,
the code is below
<b>result value of the routine
IF COMM_STRUCTURE-/BIC/G_NOFAC = COMM_STRUCTURE-/BIC/G_RENOF.
RESULT = 1.
ELSE.
RESULT = 0.
ENDIF.
if abort is not equal zero, the update process will be canceled
ABORT = 0.</b>
Regards
Venkat
Similar Messages
-
ABAP code in update rules to convert the date
Hi,
Could any one send me the ABAP code that is written in the update rules to convert the date (DD/MM/YYYY -- lenght 10) to YYYYMMDD --- length 8 format.
Also please let me know where I should write this code; while creating update rules or while creating infosource.
Thanks,Hi Bharath,
Hi Bharath,
I suggest you do the conversion of dates in the transfer rules. Here is the correct code you need:
* Assuming the source data field is called MYDATE
* Place the ff. in the routine in the transfer rules:
concatenate tran_structure-mydate+6(4) tran_structure-mydate+3(2) tran_structure-mydate(2) into result.
replace MYDATE with the name of the source field (10 chars) in the transfer structure. Hope this helps. -
URGENT !!! - ABAP code in update rule
Friends,
With my limited knowledge in ABAP, I need some help from the forum.
I need to create a routine in update rule to capture 'date of last GR against a PO delivery schedule'. Let's say
PO # 1234
IT # 10
SCL # 1
There are multiple partial deliveries against SCL # 1 above and I have to capture the last delivery date and subsequently the last invoice date. If I try to set the rule to capture the 'posting date' based of 'transfer type' - the GR date field gets overwritten by the last invoice date (the date of last activity). My requirement is to separate the two i.e.
1) Date of last GR against PO - Item - SCL line
2) Date of lasr INV against PO - Item - SCL line
Can any one help me with the code ???
Thanks,
AKHi,
check the following link, gives an example of an update routine.
http://help.sap.com/saphelp_nw70/helpdata/en/80/1a64fae07211d2acb80000e829fbfe/frameset.htm -
Sample code in Update Rule to restrict data selection?
We used to restrict data selection in InfoPackage data selection, e.g., for company code range when loading data from a source system (e.g. EBP which is similar to R3), but somehow the company code range we set in InfoPackage data selection not working and we found actually it occurs on the source system side when running RSA3 on EBP side and input the company code range in RSA3 selection section, but still it extracts data beyond the company code range. We don't understand why EBP data selection doesn't work, then we consider in update rule on BW to set the company code range. We know in update rule, we can select Start Routine, formula, or routine to set the company code range. But we would be appreciated if experts here can recommend which one is the most efficient to load data fast for data load performance reason and would be appreicated if you can let us know the sample code!
Thanks in advance!hi Hari,
I copy the whole code of the start routine below:
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: ...
Includes to update generic objects
INCLUDE rsbctgn_top .
INCLUDE rsbctgn_update_rules .
INCLUDE rsbctbbp_generic_objects.
The following section is prepared for you if you compound
the business partner 0BPARTNER with the
Source System 0BBP_SYS_BP or if you compound the organizational
Unit 0ORGUNIT with the source System 0BBP_SYS_BP
TYPE-POOLS: RRSV.
Data: L_HLP_CHAVL_CMP TYPE RSCHAVL.
DATA:
L_S_DEP TYPE RRSV_S_DEP,
L_T_DEP TYPE RRSV_T_DEP.
End of compound
DATA: l_s_errorlog TYPE rssm_s_errorlog_int,
l_hlp_chavl TYPE rschavl.
$$ end of global - insert your declaration only before this line -
The follow definition is new in the BW3.x
TYPES:
BEGIN OF DATA_PACKAGE_STRUCTURE.
INCLUDE STRUCTURE /BIC/CS0BBP_CONF_TD_1.
TYPES:
RECNO LIKE sy-tabix,
END OF DATA_PACKAGE_STRUCTURE.
DATA:
DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
FORM startup
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n
DATA_PACKAGE STRUCTURE DATA_PACKAGE
USING RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
to make monitor entries
delete data_package where 0comp_code < 'X300' OR 0comp_code > 'X6ZZ'.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
ENDFORM. -
Comment out code in Update Rule
Hello,
Quick question.
How do I comment out code in the update rule? I need to comment out a large amount of code for testing purposes.
Thanks,
SheilaHi Sheila
Go to Update rule code (routine) ->> select the code you want to comment out with mouse ->> then go to top menu Utilities -> Block/Buffer-> Insert Comment *
This will comment out the code that you had selected.
Regards
Pradip
(don't forget points) -
Update Rule Routine: Compare system date
Can anyone help me with regards to writing some ABAP code in update rule?
I would like to check if the value of a date characteristics is equal to system date in data source. If its value is equal to system date, assign '0' value to another numeric characteristics. Otherwise, it will get the difference between system date and the date characteristics. I have rewritten the routine as follows. But there is no effects on the result. Am I correct?
if COMM_STRUCTURE-<date characteristics> = SYST-DATUM.
RESULT = '0'.
else.
RESULT = COMM_STRUCTURE-<numeric characteristics>.
endif.
Many thanks in advance.I have rewritten the code as follows. ZLASTPURD is a numeric characteristics. The code is written in the routine of ZLASTPURD in update rule. But it takes no effect. The case "COMM_STRUCTURE-/BIC/ZLASTPURD ='0'" means another date characteristics is equal to system date, the value of ZLASTPURD is blank after modifying the code. However, the code is workable for "RESULT = COMM_STRUCTURE-/BIC/ZLASTPURD.". Is there anything wrong?
data lastpurdays type I.
lastpurdays = '1'.
if COMM_STRUCTURE-/BIC/ZLASTPURD = '0'.
RESULT = lastpurdays.
else.
RESULT = COMM_STRUCTURE-/BIC/ZLASTPURD.
endif.
Many thanks in advance. -
Function Module where-used list does not find update rule programs
We have function modules called in update rules. The where-used list in the function builder does not find the update rule programs.
For example, function DATE_GET_WEEK is called in an update rule to InfoCube YCUBE001. The activated program name for this update rule is GP3PWI6PKM5Y3K75A370DIS8I77. When I goto SE37, enter the function DATE_GET_WEEK, click the where-used button, check the programs option and search. The system does not find the program GP3PWI6PKM5Y3K75A370DIS8I77.
Without this search capability it is difficult to do an impact analysis of changing function modules. Does anyone know of a solution?hi,
i think the reason is the code of update rules' generated program are stored line by line in table(rsaabap), update rules program itself stored in table rsupdrout, link with field codeid, another useful table is rsupdinfo which store infocube, infosource related. other info may stored in some other rs* and rsa* tables.
try to create following program in your system, and run, type in the function module name, and will display out the update rules program id, with additional useful info : which infoprovider, infosource, and detail info of the routine and infoobject in the update rule that using that function module. you may modify the program to have better display out list.
hope this helps.
REPORT Z_FM_UPDRUL_WHEREUSED.
data : lv_sfm,
lv_line type string,
lv_where type string.
tables : rsaabap,RSUPDROUT,rsupdinfo.
select-options:
s_fm for rsaabap-LINE.
start-of-selection.
loop at s_fm.
concatenate s_fm-low ' ' into lv_sfm.
concatenate '%' s_fm-low into lv_line.
concatenate lv_line '%' into lv_line.
write : / 'function module', 'update rule id', 'routine id', 'infoobject', 'infocube', 'infosource'.
select * from rsaabap
where line like lv_line and objvers = 'A'.
select * from rsupdrout
where codeid = rsaabap-codeid and objvers = 'A'.
select single * from rsupdinfo
where updid = rsupdrout-updid and objvers = 'A'.
write: / lv_sfm, rsupdrout-updid, rsaabap-codeid,
rsupdrout-iciobjnm, rsupdinfo-infocube,
rsupdinfo-isource.
endselect.
endselect.
endloop. -
Is it possible to have an update rule that, when loading data from the PSA into my ODS, will create multiple entries in the ODS?
For example; I'm loading a flat file with some sales data. In the flat file is a PERIOD and an indicator for period TYPE (ie: Monthly or Quarterly). If the period is flagged as 'monthly' then I want the record to be loaded exactly as it is into the ODS. If the period is flagged as 'quarterly' then I want to create 2 more records on the fly and divide the sales amount into the 3 total records. Is this possible using update rules to create multiple records instead of simply one-to-one?
Thanks!Hi Patrick,
This is very much possible, You can write code in update rules start routine.
Sample Code:
Data : Lt_data_package like Data_Package accours 0 with header line.
Loop at Data_Package into lt_data_package where indicator = Month.
Endloop.
--> Now you are having all Monthl indicator records in Lt_data_package. Now delete from Data_Package.
Delete data_package where indicator = month.
-->Now process the remaining records in data_package.
Loop at data_pacakge.
-->> here you have to derive months from quater.
lt_data_package-<Total> = data_package-<Total>/3
lt_data_package-<month> = data_package-<Month 3>.
Append lt_data_package.
lt_data_package-<Total> = data_package-<Total>/3
lt_data_package-<month> = data_package-<Month 3>.
Append lt_data_package.
lt_data_package-<Total> = data_package-<total>/3
lt_data_package-<month> = data_package-<Month 3>.
Append lt_data_package.
Endloop.
-->>Now clear the contents of Data_Package.
Refresh data_package.
-->> Pust records form lt_data_package to data_package.
Insert lt_data_package from line 1 to data_package.
Hope it Helps
Srini -
Hi experts,
What are the types of update rules?
Regards,
SivaHi......
Yes either you can say what are the different update types.........that Praveen has already ansered..............or you can say.........
You can say what are the diffrent types of update routines...then the answer is :
1) Start Routine in Transfer Rules
2) Transfer Routine in Transfer Rules.
3)Start Routine in Update Rules
4)Update Routine in Update Rules.
The routines that you write in transfer rules are applicable to all the Data targets that get the data from that particular Infosource, when you are going to write some code in Transfer rules, you have to understand that you are going to manupilate the data that is going to get into BW .
If you are going to write in Update Rules , then that logic is going to apply only for that particular Data target .
Eg : Let suppose I have a Flat file that gets data from 3 countries, US, Canada and Mexico.
Now I have prepared the data source for the same . But I dont want to have the data of Mexico in to BW itself.
So I will write a Start routine at TR to eliminate the data of Mexico.
My Next step is I want the data of US into one ODS and Canada data in to another ODS.
For this I handle the dataflow at Start routine in Update rules, to eliminate Canada data for US ODS and Vice Versa.
start routine in transfer rules
Look up to load master data
excluding
Start Routine in Transfer Rules
Sample code in Update Rule to restrict data selection?
Append Datapak - transfer start routine
Excluding Blank field in Infopackage Filter
Trans Routine ABAP help ..
transfer routine
Date key figure: Convert DATS format to DEC format
Date Conversion in Flat File
Transfer Routine ABAP
conversion exit
Date Conversion
Problem with conversion char to numc in transference rules
conversion routine..?
update routine
How to call a function in Update Rules to reverse a key figure sign
Need Sample Code for Update Rules
Date calculation
Difference between data in PSA and Data in Infocube
No RETURNCODE <> 0 allowed in update routines in transfer mode
the diffrerece between DEC and (yyyymmdd) 8 char in Time defination
Access master data in update rules
Date key figure: Convert DATS format to DEC format
start routine in update rules
Is it possible to read a third ODS in update rules between two ODS?
update rule coding while loading data from ODS to CUBE
Start Routine in Update Rules to populate additional fields from ODS
Coding in Update Rules accessing a Z-Table
Start routine
Regards,
Debjani........... -
Start routine and update rules
Hi,
What is accessed first:-
Start Routines or Update Rules?
What is the use of global variables in start routine?
Please reply.
Thanks.Hi......
You have different types of Routines in BW .
1) Start Routine in Transfer Rules
2) Transfer Routine in Transfer Rules.
3)Start Routine in Update Rules
4)Update Routine in Update Rules.
The routines that you write in transfer rules are applicable to all the Data targets that get the data from that particular Infosource, when you are going to write some code in Transfer rules, you have to understand that you are going to manupilate the data that is going to get into BW .
If you are going to write in Update Rules , then that logic is going to apply only for that particular Data target .
Eg : Let suppose I have a Flat file that gets data from 3 countries, US, Canada and Mexico.
Now I have prepared the data source for the same . But I dont want to have the data of Mexico in to BW itself.
So I will write a Start routine at TR to eliminate the data of Mexico.
My Next step is I want the data of US into one ODS and Canada data in to another ODS.
For this I handle the dataflow at Start routine in Update rules, to eliminate Canada data for US ODS and Vice Versa.
Global variables in Start routine
You can have global variables, internal tables populated by the
startup routine. This data will be available to the field
routines. Create yourself a start routine, declare some
variables in the global section, and then create a field
routine. You will be able to use the globally declared objects
in the field routine
Please check below help link for routines in sap netweaver 2004s
http://help.sap.com/saphelp_sem60/helpdata/en/e3/732c42be6fde2ce10000000a1550b0/frameset.htm
How to guide "How to transformations routines".Please check the below link:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/dc1d9990-0201-0010-16aa-db3c4eb8b642
start routine in transfer rules
Look up to load master data
excluding
Start Routine in Transfer Rules
Sample code in Update Rule to restrict data selection?
Append Datapak - transfer start routine
Excluding Blank field in Infopackage Filter
Trans Routine ABAP help ..
transfer routine
Date key figure: Convert DATS format to DEC format
Date Conversion in Flat File
Transfer Routine ABAP
conversion exit
Date Conversion
Problem with conversion char to numc in transference rules
conversion routine..?
update routine
How to call a function in Update Rules to reverse a key figure sign
Need Sample Code for Update Rules
Date calculation
Difference between data in PSA and Data in Infocube
No RETURNCODE <> 0 allowed in update routines in transfer mode
the diffrerece between DEC and (yyyymmdd) 8 char in Time defination
Access master data in update rules
Date key figure: Convert DATS format to DEC format
start routine in update rules
Is it possible to read a third ODS in update rules between two ODS?
update rule coding while loading data from ODS to CUBE
Start Routine in Update Rules to populate additional fields from ODS
Coding in Update Rules accessing a Z-Table
Start routine
Hope this helps you..........
Regards,
Debjani.........
Edited by: Debjani Mukherjee on Oct 1, 2008 4:58 PM -
UoM Conversion in Update Rule -
Dear Experts,
We are trying to do UoM Conversion during data loading by writing a code in Update Rules that would do conversion based on conversion factors maintained in 0MAT_UNIT. We are following the "How-To" paper by SAP.
The SAP "How-To" paper does not refer to Table T006 for UoM Conversions. It checks for conversion factor only in 0MAT_UNIT master data. However when we define a new UoM Conversion type in T-code RSUOM, we can select an option by which system refers to Table T006 for conversion.
I am not sure if there would be consistency in conversions at the time of data loading and reporting. Because our update rules would not check Table T006 while reports might refer to T006 for UoM Conversion.
Can someone please fill up the gap?
Regards
XHi Abhijith,
Check here......
Re: UOM Conversion
Quantity Conversion Function Module
"UNIT" in Transformation
Re: How to write conversion routines in bw
about conversion routines
Re: how to write routine for unit conversion
Regards,
Vijay. -
How can I view the code for a routine in an update rule
on loading data for 0PLANT_ATTR, I am getting an error for No Local Currency found in Plant 1000 and SAles Org 6000.
in looking at the update rules for this, I see that there is a routine for the update of the local currency:
Perform GET_LOCCURRCY_FOR_PLANT
USING COMM_STRUCTURE-PLANT
COMM_STRUCTURE-SALESORG
CHANGING hlp_monitor
RESULT
hlp_subrc.
How do I see the code behind this? I want to make sure that I understand everything that needs to be populated in Master Data so that I can ask my functional consultant to update all the necessary fields.
Thanks
JPHi Riccardo,
When I double click on it, I get a message at the bottom that says program reindexed.
After looking again, I found that when I double clicked on the comm structure, then the routine, I was able to see it.
Thanks
JP -
Inserting code in final steps of Update Rule transformation
Hi,
I am extracting data into a cube from an ODS and doing some aggregation in the process. E.g 3 records in the ODS might become 1 in the cube.
This is fine for some things like Quantity, but not ideal for things like unit price. One work around is for the ODS to have a counter.
e.g
MATERIAL QUANITITY UNIT_PRICE COUNTER
1234 13 $1.50 1
1234 21 $1.50 1
1234 45 $1.50 1
This comes across into a cube like
MATERIAL QUANITITY UNIT_PRICE COUNTER
1234 79 $4.50 3
- unit price can then be calculated by dividing unit price by counter - however it needs to be done within the query.
I thought perhaps we could perform this calculation when populating the cube, if the items were firstly collected within an interim table before being passed to the return_table.
i.e
1. Define key figure using ABAP routine and return table.
2. Append INTERIM_TABLE within update rules for each read of the ODS
3. Once all ODS records have been read and inserted at an aggregate level within INTERIM_TABLE, loop through INTERIM_TABLE, perform calculation and append RETURN_TABLE.
My question is: Is there a simple way to determine that all ODS items have been read (like an "at last" statement) and if so, where can this code be inserted? Can it be simply placed in the update rules routine if I have the appropriate logic to determine that all items have been read?
Thanks
AdrianHi Adrian,
Why cant you use Addition, minimum or maximum in update rules...?? Here you can use Maximum option for Unit Price.
http://help.sap.com/saphelp_nw04/helpdata/en/3f/0e503c3c0d563de10000000a114084/content.htm
Hope it Helps
Srini -
Convert ABAP code in start routine/update rule to transform. start routine
Dear BW ABAPers,
I have created a custom purchasing info cube (YCP_PURC1) based on 0CP_PURC1 standard cube. I would like to convert this new data flow to BI7 (from 3.x), and convert the standard update rule to transformation. I would need to rewrite the below start routine from the standard update rule to a start routine ABAP code in the newly created transformation / start routine. My ABAP knowledge is limited. Will you please help?
*this is the start routine from the update rule. As a side note, the data source is 2LIS_02_SCL.
LOOP AT SOURCE_PACKAGE.
IF ( SOURCE_PACKAGE-cppvlc EQ 0
AND SOURCE_PACKAGE-cppvoc EQ 0
AND SOURCE_PACKAGE-cpquaou EQ 0 ).
DELETE SOURCE_PACKAGE.
CONTINUE.
ENDIF.
no_scl is initial ( e.g. for good receipts, billing)
value has to be set depending on storno
IF SOURCE_PACKAGE-no_scl IS INITIAL.
IF SOURCE_PACKAGE-storno = 'X'.
SOURCE_PACKAGE-no_scl = -1.
ELSE.
SOURCE_PACKAGE-no_scl = 1.
ENDIF.
MODIFY SOURCE_PACKAGE.
ENDIF.
ENDLOOP.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
Many thanks and look forward to your kind feedback.
Kind regards,
CsabaDear All, Durgesh,
thanks to you all for your valuable input. Mainly the ABAP part was more interesting for me.
Durgesh, thanks for your input, it was useful. I just had to change the info objects to data source fields and add the lines before the loop:
DATA: I_PACKAGE TYPE TYT_SC_1.
FIELD-SYMBOLS <i_package> TYPE tys_sc_1.
I_PACKAGE[] = SOURCE_PACKAGE[].
LOOP AT SOURCE_PACKAGE assigning <i_package>.
IF ( <i_package>-BWGEO EQ 0
AND <i_package>-BWGEOO EQ 0
AND <i_package>-BWMNG EQ 0 ).
DELETE SOURCE_PACKAGE index sy-tabix.
CONTINUE.
ENDIF.
no_scl is initial ( e.g. for good receipts, billing)
value has to be set depending on storno
IF <i_package>-NOSCL IS INITIAL.
IF <i_package>-ROCANCEL = 'X'.
<i_package>-NOSCL = -1.
ELSE.
<i_package>-NOSCL = 1.
ENDIF.
ENDIF.
ENDLOOP.
Points have been assigned accordingly.
Thanks,
Csaba -
How to Code "AND" logic in Update Rule?
Hi:
I have minimal ABAP knowledge and need some help....
I have to use the Query logic and code in my Update rule... (i.e. multiple conditions have to be met)
IF (COMM_STRUCTURE-Sales_Org = '100' AND COMM_Structure-Division = 'LA' AND COMM_STRUCTURE-Acct_Grp = '0120')
RESULT = COMM_STRUCTURE-Credit_Amoutn (I want to assign a specific KF)
ELSE
RESULT = 0 (I want to assign Zero)
ENDIF
I attempted this logic, but I keep getting an error with 'AND' statement. I am not sure what is the syntax.
Can someone please help me out with the logic/sytax
Thanks..... LeeHi:
I responded without checking the logic.... assuming it would work...!~
Unfortunately it gives me error:
QUOTE
E:Incorrect logical expression: ")" must be followed by "AND" or "OR" . .
UNQUOTE
Can anyone help me resolving this please....!!!!
Thanks... lee
Maybe you are looking for
-
HT1237 EFI Update 2.8 doesn't install
Where can I see if the EFI update 2.8 for my MBP 2008 works properly? after I manualy installed the update 2.8 there is stil version 1.8 visible and the display stil flickering.
-
HP Touchsmart 600 PC blue screen and video problems
Hi, Just a quick bit about me before I get started. I am A+, Network+ and Security+ certified and have been working on computers for years. But this time I've run into something I haven't been able to diagnose and my friend doesn't want to format a
-
Hi We want to park invoice in background but could not find the right solution : Batch input is not working for MIR7. BAPI_INCOMINGINVOICE_PARK is not working if the PO involves return lines. I will appreciate your help Doron
-
See an edited picture unedited in finder
Hello guys and girls. I really need to see an edited picture unedited in finder. I have seen it before with my own eyes on my own computer that it works. I saw an edited picture in this view in finder: http://img413.imageshack.us/img413/5781/lolfzf.p
-
IPrint Printer Policy - default printer
ZCM 11.2.3a I seem to be getting some quirky reactions to my printer policy. I created a policy with 4 iPrint printers and assigned it to a number of workstations. I did not set a default printer because I want to leave that up to the user. For some