Advice on abap routine in update rule
Hello Experts,
I have written a routine in update for replacing some 'not allowed characters' with space.
The abap code is correctly working as a standalone program as is giving the correct results.However,
when i write the same code in update routine, no change takes place in data, i.e. 'not allowed characters ' are still there in my data.
Please advice if there is any special change that is to be made while writing the code in update routine.
if STRLEN( CHECK_TEXT ) <> 0.
ALLOWED_SPECIAL_CHARACTERS = ' &()*+,-.:;<>=?!@$%~'.
ALLOWED_CHARACTERS = 'ABCDEFGHIJKLNMOPQRSTUVWXYZ_0123456789'.
TRANSLATE CHECK_TEXT TO UPPER CASE.
strl = strlen( CHECK_TEXT ).
IF CHECK_TEXT CN ALLOWED_CHARACTERS.
WHILE len1 LE strl.
IF CHECK_TEXT+len1(1) CN ALLOWED_CHARACTERS.
CHECK_TEXT+len1(1) = '.'.
ENDIF.
add 1 to len1.
ENDWHILE.
ENDIF.
Regards
Priyanka
Thanx a lot for a quick reply .
The main problem that we are facing is this simple code is working fine if it is executed as a report program but if no changes takes place when i move this same code to my update routine.
(1) According to you i should write this routine in the start routine instead of update rotuine ??
(2) how would function module help in my case...kindly elaborate a it.
Here is the complete update rotuine.
data:
len1 TYPE i value 0
R_TEXT(60),
CHECK_TEXT(60),
R_TEXT = COMM_STRUCTURE-/BIC/ZC_NTXT1.
if STRLEN( R_TEXT ) <> 0.
ALLOWED_SPECIAL_CHARACTERS = ' &()*+,-.:;<>=?!@$%~'.
CONCATENATE 'ABCDEFGHIJKLNMOPQRSTUVWXYZ_0123456789/'
ALLOWED_SPECIAL_CHARACTERS
INTO ALLOWED_CHARACTERS.
CHECK_TEXT = R_TEXT.
TRANSLATE CHECK_TEXT TO UPPER CASE.
strl = strlen( R_TEXT ).
IF CHECK_TEXT CN ALLOWED_CHARACTERS.
WHILE len1 LE strl.
subs2 = CHECK_TEXT+len1(1).
IF subs2 CN ALLOWED_CHARACTERS.
CHECK_TEXT+len1(1) = '.'.
ENDIF.
ENDWHILE.
endif.
ENDIF.
RESULT = CHECK_TEXT.
Similar Messages
-
Deleting rows with missing values in field in start routine of update rule
Hello experts,
how can I delet rows with missing values in a specific field in the start routine of update rules?
I think ABAP code should look something like this:
delete ... from DATA_PACKAGE where Z_NO = ''.
thanks in advance for any suggestions!
hizaWrite:
delete data_package where field = value.
Hope it helps.
Regards -
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 -
Diff between the Start routine and Update rules?
Hi Gurus
Diff between the Start routine and Update rules?
Thanks in advance
RajHi,
Routines are like conditions or business rules that could be applied to filter the data while entering the BW system or could be used to apply certain conditions on the info objects itself.Update rule level you manipulate your data and write your start routine.
There are 4 types of routines
1. Start routine- Could be used at two levels (transfer rule level and the Update rule level)
This Start routine written at the transfer rule level helps filter the necessary data coming from the source system.
For Example: If you decide to extract data that contain only quantity greater than 500 , then you could specify the Start rouitne to achieve this.
The Start routine at the Update rule level provides similar functionality but at this point it helps direct specific data to
different data targets. For Example: If there 3 data targets being fed from the Infosource, you may want to apply some condition to each data target, like send year 2000 data ti Data target1, 2001 to data target 2 and so on. This can be achieved by using Start routine at the Update rule level
2. Transfer Routine: This feature is available at the transfer rule levels
While performing the transfer rules operation, there are 4 features available to the developers to create business rules on top pf the Infoobjects.
1. You could do a one to one mappping of the Infoobject
2. Provide a constant value
3. Include a formula
4. Write an ABAP routine.
These 4 options refers to the transfer routine
3. Update Routine:
The limitations of just having 4 options in the transfer routine is overcome at the update rule level. There are various other
sophisticated features avaialable apart from the 4 options mentioned above. These business rules could be specified pertaining to each data target.
4. Conversion Routine: It provides functionality to do Currency and unit conversion.
Regards. -
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 -
Key figure routine in update rules
I have a Cube (X) that gets data from a ODS (A) but one of the key figures gets the data from another ODS (B) with a routine in update rules and I want to change it to ODS (C)
A (All objects except one) - X (All objects except one)
B (0DEB_CRE_LC) - X (0DEB_CRE_LC)
select sum( DEB_CRE_LC )
into RESULT
from /BIC/AZDOC_SUB00
where OI_EBELN EQ COMM_STRUCTURE-OI_EBELN
and OI_EBELP EQ COMM_STRUCTURE-OI_EBELP
and /BIC/ZCLASC_ID EQ COMM_STRUCTURE-/BIC/ZCLASC_ID
and PSTNG_DATE LE l_datafim
and PSTNG_DATE GE l_datainicio
and /BIC/ZTPOPER = '9'.
My problem is that my ODS (C) doesn't have 0DEB_CRE_LC and the values are divided in 2 key figures (D) & (E), I want to sum both key figures into 0DEB_CRE_LC of the cube.
I tried a tip from a friend but didn't work, I'm lost (newbie), and apreciated some tips, it doesn't seem to sum anything
data: result1 type /BIC/AZPUR_S0100-/BIC/ZSLIQ_VAL,
result2 type /BIC/AZPUR_S0100-/BIC/ZSIVA_VAL.
select sum( /BIC/ZSLIQ_VAL ) sum( /BIC/ZSIVA_VAL )
into (RESULT1, RESULT2)
from /BIC/AZPUR_S0100
where OI_EBELN EQ COMM_STRUCTURE-OI_EBELN
and OI_EBELP EQ COMM_STRUCTURE-OI_EBELP
and /BIC/ZCLASC_ID EQ COMM_STRUCTURE-/BIC/ZCLASC_ID
and PSTNG_DATE LE l_datafim
and PSTNG_DATE GE l_datainicio.
write result1.
write result2.
Many thankxdata: result1 type /BIC/AZPUR_S0100-/BIC/ZSLIQ_VAL,
result2 type /BIC/AZPUR_S0100-/BIC/ZSIVA_VAL.
select sum( /BIC/ZSLIQ_VAL ) sum( /BIC/ZSIVA_VAL )
into (RESULT1, RESULT2)
from /BIC/AZPUR_S0100
where OI_EBELN EQ COMM_STRUCTURE-OI_EBELN
and OI_EBELP EQ COMM_STRUCTURE-OI_EBELP
and /BIC/ZCLASC_ID EQ COMM_STRUCTURE-/BIC/ZCLASC_ID
and PSTNG_DATE LE l_datafim
and PSTNG_DATE GE l_datainicio.
write result1.
write result2.
<u>RESULT = result1 + result2</u>
I still have to test it, first i was getting syntax errors because I didn't put spaces right sorry -
Urgent: ABAP routine in transfer rules
Hi,
when i am loading master data from R/3 into BW, i need to filter some records based on material type. there is no option in RSA6 (on R/3) or in Infopackage (BW) to make it available for filter.
So i assume i need to write ABAP routine in transfer rules. can some one help me with ABAP. i need to load the records only when MTART field(material type) in MARA is "FINI" or "RAW" and skip other records.
what is difference between deleting the whole data packet and deleting the record.
Thank you very much in advance
Regards
EmilHi
Write the below code in the start routine of your transfer rules.
Regards
Prakash
DATA: IT_DATA TYPE STANDARD TABLE OF TRANSFER_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
DATA: S_DATA, T_DATA TYPE TRANSFER_STRUCTURE.
LOOP AT DATAPAK INTO S_DATA.
IF S_DATA-MTART EQ 'A' OR S_DATA-MTART EQ 'B'.
MOVE S_DATA TO T_DATA.
DELETE S_DATA.
ELSE.
DELETE S_DATA.
ENDIF.
APPEND T_DATA TO IT_DATA.
ENDLOOP.
CLEAR T_DATA.
DATAPAK[] = IT_DATA[].
Assigning points is a way of saying thanks on SDN!! -
Transport routine in update rule
Dear All,
I have new routine in update rule, after development test is ok,
I transported to quality environment, but return with error code: 8.
The new routine and changed update rule are in same request number.
I think maybe I must separate and transport the routine first,
before I transport the update rule.
Now, how transport this routine?
I also confused to find the routine generated number because there are a lot of routine
in this update rule.
I already triggered by update the routine again (to prompt request window),
transported the request and I have the same result.
Any help will be appreciated. Thanks.
Regards,
Steph.Hi ,
Pls check below threads , may be it helpful to you.
https://forums.sdn.sap.com/click.jspa?searchID=21044655&messageID=6432928
https://forums.sdn.sap.com/click.jspa?searchID=21044655&messageID=6427473
https://forums.sdn.sap.com/click.jspa?searchID=21044655&messageID=6855315
Thanks & Regards,
Ramnaresh .P. -
Routine for Update rule in cube
Hi Friends,
I have added a field to a cube, now i need to populate the same during the data is loading from the DSO to Cube. Inupdate rule since we will get only te key figures, is it possible to access the dimensions in the routine. Please help me in giving some coadings for the routine for update rule.
Thanks
PremHi,
one more suggestion..
create a end routine and update the key figures based on ur dimension values by useing resuly_package.
sample code:
[Transformation end routine|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/203eb778-461d-2c10-60b3-8a94ee91cbfc]
thnks. -
ABAP Help at start routine of Update rule
Good After Noon All,
My requirement is that cube ZAPO_C24M theres an UPDR flowing from 8ZAPO_C24M back to itself so to speak.The request is to change the data in the cube from Fiscal Year Variant Z3 to Z4.
But in start routine i have to take the existing record and reverse all of the key figures, and also change the RECORDMODE of the record to indicate it is a reversal record. This for specific Country KR and for these country the Fiscal variant is Z3. Again in the start routine, create a new record identical to the existing record that has Fiscal Year Variant Z4 instead of Z3.
So the idea is wed load from the cube and send back to the cube one record that reverses out the existing data, and another record that contains the same data but with Fiscal Variant Z4 instead of Z3.
Please Help me.
Points will be awarded for the right answerHi Vaishali,
In the start routine copy the DATA_PACKAGE to a local table.
Select the records where the specific country is KR.
Delete all other records.
Then read the records in loop, Keep one record same and just change the fiscal year variant.
And for the same multiply all the key figures by -1.
Transfer the content of the local table back to DATA_PACKAGE.
maintain one to one mapping in the update rule.
I am sure it will update, but you need to be sure that if you change Fiscal year variant then probably your fiscal period value should change. In that case you have to update it accordingly in the start routine.
Regards. -
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. -
ABAP Help on Update Rule Needed
Hello. I am trying to write a routine on an key figure in an update rule. Basically, I am trying to load a custom key figure with either a 1 or a 0.
Here is the pseudocode:
IF
(((GI_DATE - ACT_GI_DTE) < 0) OR
((GI_DATE - ACT_GI_DTE) > 3)
THEN
NEW_KEY_FIGURE = 1
ELSE
NEW_KEY_FIGURE = 0
ENDIF.
Here is the code I currently have in the routine. Any ideas on where I am going wrong here? I am not an ABAP developer so please keep this in mind when responding.
result value of the routine
CLEAR RESULT.
if the returncode is not equal zero, the result will not be updated
IF COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE < 0 OR
COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE > 3.
COMM_STRUCTURE-NEW_KEY_FIGURE = 1.
ELSE.
COMM_STRUCTURE-NEW_KEY_FIGURE = 0.
ENDIF.
RESULT = COMM_STRUCTURE-NEW_KEY_FIGURE.
RETURNCODE = 0.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
Thanks for any help you can give.Hi,
I think you can not put "-" in if command, so code should be like this:
data: datediff type n.
result value of the routine
CLEAR RESULT.
clear datediff.
detediff = COMM_STRUCTURE-GI_DATE - COMM_STRUCTURE-ACT_GI_DTE.
IF datediff < 0 OR datediff > 3.
Result = 1.
ELSE.
Result = 0.
ENDIF.
RETURNCODE = 0.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
Regards,
Andrzej -
I want to replace all '# ' values showing up in a report with space. For this I plan to write a Start Routine in the Update Rules which should scan all the data coming in into the cube and replace all null or '' with space.
What is the best way to write this routine. It should check all data in all the fields of the data load coming in.
ThanksHi,
The space is shown as # in the BW Reports, to confirm check the value in the cube for this field, so
you need to change that to some other character like X or Y or explain your end users that SAP
designates a space as # and it will be displayed that way in the reports.
Regards,
Raj -
How to debug start routines of update rules from ODS to InfoCube
Dear gurus,
I have an update rule from ODS to InfoCube. I wrote a start routine in the update rule. Now I want to debug it. I went to monitor and simulate update the data package and only got the prompt "No data exists in the corresponding PSA table". So how can I debug this start routine?
Thanks in advance.
Jin MingJin,
In order to use PSA between ODS and InfoCube, you may have to use an exclusive InfoPackage and load separately. In that InfoPackage, choose the radio button to use a PSA.
I think you are currently updating the InfoCube directly without using a separate InfoPackage.
Look for an InfoSource under DataMarts (search for 8<ODS Technical name>) and create your InfoPackage there.
Good luck. -
Unit calculation at routine in update rule
Hello,
Can anybody explain me how to calculate unit in update rule routine.
In update rule routine how to access infocube keyfigure like we access communication structure as comm_structure.
Is there any sample code?
Please help me out.
Thanks,
Regards,
SteveHi,
You can find out the no of routines with standard Update rules.
one of them is :
<i>for 'Net weight in kilograms' 2LIS_13_VDITM-->0SD_C03</i>
IF COMM_STRUCTURE-UNIT_OF_WT NE 'KG'.
WEIGHT = COMM_STRUCTURE-GRS_WGT_DL.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = COMM_STRUCTURE-GRS_WGT_DL
UNIT_IN = COMM_STRUCTURE-UNIT_OF_WT
UNIT_OUT = 'KG'
IMPORTING
OUTPUT = WEIGHT
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
DIVISION_BY_ZERO = 2
INPUT_INVALID = 3
OUTPUT_INVALID = 4
OVERFLOW = 5
TYPE_INVALID = 6
UNITS_MISSING = 7
UNIT_IN_NOT_FOUND = 8
UNIT_OUT_NOT_FOUND = 9
OTHERS = 10.
IF SY-SUBRC NE 0.
CLEAR MONITOR.
MONITOR-msgno = '009'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-UNIT_OF_WT.
append MONITOR.
RETURNCODE = 4.
WEIGHT = 0.
ELSE.
RESULT = WEIGHT.
RETURNCODE = 0.
ENDIF.
ELSE.
RESULT = COMM_STRUCTURE-GRS_WGT_DL.
RETURNCODE = 0.
ENDIF.
With rgds,
Anil Kumar Sharma .P
Maybe you are looking for
-
Apple tech so far hasn't helped except to advise me to get manuals online that Sony doesn't post on its website. I've sent off an inquiry to Sony but don't expect an answer. Apple assumes my devices are bluetooth but the iPad2 hasn't figured out ho
-
Forcing a component to lose focus
Hi all! How do you make sure that a component (such as a JButton) never gets keyboard focus? If you're asking why I need this, I'm making a small program in which a button moves away from the cursor and I need to make sure that the user doesn't cheat
-
Creating test data for a problem
Hi, I've been using this forum for a few months and it has been extremely useful. The problem is that I actually have no idea how to create test data for a specific problem. I've tried googling but to no avail. I have had other users create test data
-
I have a HP Pavilion 6000 series, actual model number dv6928us which came with a 250GB Serial ATA 9.5mm, 2.5in hard drive. Can I use the 320GB unit I found on line which has the same specs but has the larger capacity? Thank you for your help
-
Insert an existing Item in the Overview of an BO Extension
Hi Guys, My Problem: I wanna to insert existing Fields in the Overview but how: I have this Opportunity with the external Parties: I wanna to add those Party Role, Name and Adress in the Overview of the Opportunities: Has anyone an Idea or a Solution