Wrong index being chosen-start routine slow
Hi,
We are uploading 6Million odd records using lookup and aggregation in the start routine of update rules from an ODS into an infocube.
One such lookup is on the source ODS itself and takes the longest. The WHERE clause of the SELECT exactly matches one of the secondary indices 020 but is not used when the datapack size is 50,000 but is used only when the datapacksize is a few 100 records. However, the index that does get used in the case of large datapackages is 030 which only partially matches the fields in the WHERE clause.
I have tried the following modifications of the SELECT as two alternatives but neither works :
1) used the Oracle hint INDEX specifically for index 020
2) removed the FOR ALL ENTRIES IN DATA_PACKAGE clause and used a ranges table for selection in the WHERE clause on certain fields
The index 020 has been 'Analysed' and statistics have been created.
Does someone have ideas on why a particular index will not get used in this specific case ?
Best regards
Anuradha
Message was edited by: anuradha govil
Hi,
could you post the code ?
/manfred
Similar Messages
-
Wrong Indexes being used on Oracle 10.2.0.4
Hi All
We have recently performed a combined Unicode and Upgrade from SAP version 4.7 (running Oracle 10.2.0.2) to ERP 6.0 with Enhancement Pack 4 (running Oracle 10.2.0.4).
During UAT, the users have complained that the performance is slow, (compared to the non-unicode 4.7 system), even though the server the UAT is being done on has double the CPU and memory of the previous 4.7 server (14 CPU and 64GB RAM compared to 6 CPU and 32 GB RAM)
Along with my basis colleagues, we have found that some of the batch jobs that run, are actually using different indexes compared to the 4.7 system. This is also the case for some processing that is done in the foreground.
We have run a stats update on the 10.2.0.4 DB in the exact same way that we have on the 10.2.0.2 one, yet the optimizer seems to be choosing a different index, which is impacting our performance.
Has anybody seen this problem before, and can you advise of a solution.
Thanks
SamHi,
I have this problem all the time
Catch the statement in ST04 or if you already have,
clip it to ST05 and let us have the "explain Plan" output.
Would be a better base to discuss on.
Regards
Volker -
Index used or not for selecting data from ODS in a start routine
Dear friends,
In the start routine of the update rules to a cube, I am reading some data of an ODS in to an internal table .
The ODS is indexed. But, I am not sure if the index is at all used in the Select statement (that gets the data from ODS to the internal table in the start routine) while loading data to the cube.
Any help is highly appreciated.
regards,
atlajHi Atlaj
You can findout this is display execution plan for SQL statement in DB02.
Goto DB02. and under diagnostic, you find explain. Select that and enter your query. Make sure that everything here is in capital format. Below is a sample query which I have entered.
SELECT "CRM_SALORG" "SALESORG" FROM "/BI0/QORGUNIT"
WHERE "SALESORG" = ? AND "OBJVERS" = ? AND "DATETO" >= ?
AND "DATEFROM" <= ?
The select parameters should be inside qoutes and in caps and even the from table. Once you enter your query in this format, click on explain. It will show the index scan if the index is present. the output for my query will be something like
0 SELECT STATEMENT ( Estimated Costs = 1,348E+01 [timerons] )
1 (COOR) RETURN
2 ( 0) TQ
3 ( 0) FETCH /BI0/QORGUNIT
4 ( 0) IXSCAN /BI0/QORGUNIT~Z1
Where my last statement (line 4) is showing index scan and the name of index read is Z1.
Hope this helps.
Please let me know if you have any problems entering the query in the specified format and u get any error.
Regards
Sriram -
Problem started after I unintentionally downloaded some adware 4 days ago. After lots of aggressive ads slowed down my browser I downloaded and ran AdwareMedic which seemed to do the job and browser was back to normal. Then, possibly a coincidence, everything on the computer started running slower. I've backed up everything and have run a EtreCheck report.
When you have the problem, note the exact time: hour, minute, second.
These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad and start typing the name.
The title of the Console window should be All Messages. If it isn't, select
SYSTEM LOG QUERIES ▹ All Messages
from the log list on the left. If you don't see that list, select
View ▹ Show Log List
from the menu bar at the top of the screen.
Each message in the log begins with the date and time when it was entered. Scroll back to the time you noted above.
Select the messages entered from then until the end of the episode, or until they start to repeat, whichever comes first.
Copy the messages to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
The log contains a vast amount of information, almost all of it useless for solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
Please don't indiscriminately dump thousands of lines from the log into this discussion.
Please don't post screenshots of log messages—post the text.
Some private information, such as your name, may appear in the log. Anonymize before posting. -
The field "SOURCE_PACKAGE" is unknown IN THE START ROUTINE?
Hi all,
i am trying to create a start routine in the DTP FROM THE CUBE TO THE OPEN HUB.
But when i check the syntax : it throws me an error message stating.
The field "SOURCE_PACKAGE" is unknown IN THE START ROUTINE?
how come the source package is unknow in the start routine can anyone pls advise me on this!!
DATA: l_tabix TYPE sy-tabix, wa_source_package TYPE tys_sc_1.
LOOP AT SOURCE_PACKAGE INTO wa_source_package.
l_tabix = sy-tabix.
IF wa_source_package-SALES EMP EQ ' '.
DELETE SOURCE_PACKAGE
WHERE SALESEMP EQ ' '.
INDEX l_tabix.
ENDIF.
ENDLOOP.Hi Pooja,
I think that the error comes from the delete statement.
As you already said, the SOURCE_PACKAGE is from BI7.0. That means that the LOOP AT statement cannot be wrong (although I prefer field-symbols)
I would restate you code like below:
DATA: l_tabix TYPE sy-tabix,
wa_source_package TYPE _ty_s_sc_1.
LOOP AT SOURCE_PACKAGE ASSIGNING <source_fields>. "<source_fields> is declared as line from source_package
* l_tabix = sy-tabix.
IF <source_fields>-SALES_EMP IS INITIAL.
DELETE <source_fields> FROM SOURCE_PACKAGE.
* If this line does not work, try to add TABLE after the FROM-statement
*WHERE SALESEMP EQ ' '.
*INDEX l_tabix.
ENDIF.
ENDLOOP.
Hopefully this will help.
Alternatively you can try a single statement, because it is not necessary to do a loop.
DELETE SOURCE_PACKAGE WHERE sales_emp IS INITIAL.
Good luck!
Steven Groot
Edited by: S. Groot on Aug 11, 2010 7:50 AM -
Hi
i need to reload the master data with out FM, i putted the comment on fm and relaod the data, now i having a problem, loading process is slow now as compair to before, when i was using with FM.
i checked the mange on data target, it is show 1123455 in transfer column and 0 in added column below is the start routine,
Please help me to fix that problem
IF NOT DATAPAK[] IS INITIAL.
LOOP AT DATAPAK INTO S_DATAPAK.
CLEAR V_INDEX.
V_INDEX = SY-TABIX.
IF S_DATAPAK-/BIC/ABRETPRI CO ' 0123456789.'.
CLEAR: V_AMOUNT, V_PRC.
V_AMOUNT = S_DATAPAK-/BIC/ABRETPRI.
CALL FUNCTION 'RSAR_CURRENCY_CONVERT'
EXPORTING
I_CURRENCY = S_DATAPAK-CURRENCY
CHANGING
C_AMOUNT = V_AMOUNT.
V_PRC = V_AMOUNT.
S_DATAPAK-/BIC/ABRETPRI = V_PRC.
ENDIF.
IF S_DATAPAK-/BIC/ABBLNKFLG IS INITIAL.
S_DATAPAK-/BIC/ABBLNKFLG = 'N'.
ENDIF.
TRANSLATE S_DATAPAK-/BIC/ABSZRANGE TO UPPER CASE
IF S_DATAPAK-CURRENCY IS INITIAL.
S_DATAPAK-CURRENCY = S_DATAPAK-WHLPRCCURR.
MODIFY DATAPAK FROM S_DATAPAK INDEX V_INDEX TRANSPORTING
/BIC/ABRETPRI /BIC/ABWHLPRCE /BIC/ABBLNKFLG
ENDIF.
*ENDLOOP.
ENDIF
ThanksHi Rob,
Requirement is not clear. please let us know which FM you are commented and why you are using that FM and what is your exact requirement.
Regards,
Ramakrishna kotha. -
Hello,
I am writing a Start Routine in my update rules from an ODS into another ODS. My start routine is basically just restricting some data from being updated into my data target. I am restricting based on 0VYPTE = 20. That is, if a records has 0VTYPE = 20 I am deleting it from the data_package. If I debug through the program, it works correctly with one record but when I throw in about 120K records it doesn't work. Can someone please have a look and tell me what is wrong here?
LOOP AT DATA_PACKAGE.
<b>IF DATA_PACKAGE-VTYPE NE 10.</b>
DELETE DATA_PACKAGE.
CONTINUE.
ELSE.
IF DATA_PACKAGE-/BIC/CASES NE 'CS'.
PERFORM load_mrscube_tables USING DATA_PACKAGE-SOURSYSTEM.
PERFORM BASEUNIT_CONVERT tables
MONITOR
using DATA_PACKAGE-MATERIAL
DATA_PACKAGE-SOURSYSTEM
DATA_PACKAGE-/BIC/CASES
'CS'
DATA_PACKAGE-/BIC/CASES_REV
changing
quant_out.
EXIT.
EXIT.
modify DATA_PACKAGE.
ENDIF.
ENDIF.
ENDLOOP.Hi Nyrvole,
Try to change the code this way and check(debug).
DELETE DATA_PACKAGE WHERE VTYPE NE 10.
LOOP AT DATA_PACKAGE.
IF DATA_PACKAGE-/BIC/CASES NE 'CS'.
PERFORM load_mrscube_tables USING DATA_PACKAGE-SOURSYSTEM.
PERFORM BASEUNIT_CONVERT tables
MONITOR
using DATA_PACKAGE-MATERIAL
DATA_PACKAGE-SOURSYSTEM
DATA_PACKAGE-/BIC/CASES
'CS'
DATA_PACKAGE-/BIC/CASES_REV
changing
quant_out.
EXIT. -- WHY THIS EXIT FOR...??
EXIT. -- WHY THIS EXIT FOR...??
modify DATA_PACKAGE. -- ARE YOU CHANGING ANY RECORDS..??
ENDIF.
ENDLOOP.
Put break-point after end loop and dugug and see the no of records.
Hope it Helps
Srini -
Start routine to filter the duplicate records
Dear Experts
I have two questions regarding the start routine.
1) I have a characteristic InfoObject with transactional InfoSource. Often the 'duplicate records' error happens during the data loading. I'm trying to put a start routine in the update rule to filter out the duplicate records.
After searching the SDN forum and SAPHelp, I use the code as:
DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING KEY1 KEY2 KEY3.
In my case, the InfoObject has 3 keys: SOURSYSTEM, /BIC/InfoObjectname, OBJVERS. My code is:
DELETE ADJACENT DUPLICATES FROM DATA_PACKAGE COMPARING SOURSYSTEM /BIC/InfoObjectname OBJVERS.
When checking the code I got message: 'E:No component exists with the name "OBJVERS".' So I only included the first 2 keys. But the routine does not work. The duplicate error is still happening. What is missing in this start routine?
2) Generally, for a start routine, do I really need to include the data declaration, ITAB or WA, SELECT statement etc.?
Do I have to use the statement below or just simply one line?
LOOP AT DATA_PACKAGE.
IF DATA_PACKAGE.....
ENDIF.
ENDLOOP.
Thanks for your help in advance, JessicaHello Jessica,
if it won't be possible for you to get unique data from the very beginning, there is still another way to manage this problem in a start routine.
Sort ... and delete adjacent ... must remain. Further on build up an internal table of type data_package, but defined with STATICS instead of DATA. This i-tab stays alive for all data-packages of one load. Fill it with the data of the transferred data-packages, and delete from every new data-package all records which already are in the statics i-tab. Alternatively you could do the same with a Z-(or Y-)database-table instead of the statics i-tab.
It will probably cost some performance, but better slow than wrong data.
Regards,
Ernst -
Why did sometimes SAP choose a wrong index for a table?
We were creating reports that takes data from DFKKOP and IST_TDATA tables. These table contains millions of data. E.g. in one month, the table DFKKOP grows from 0 records to 12 millions of records. So index takes very important part here.
We had created additional indexes to improve query performance, but somehow SAP ignores these indexes and use full table scan. We had tried several methods, i.e:
- Fields order in WHERE clause is the same as in the index.
- Using Oracle HINTS INDEX .
- Using Oracle HINTS FIRST_ROWS.
- Update table statistic
- Adjusting the index (SE14)
Sometimes the right index can be chosen by using HINTS INDEX, but sometimes we have to use the FIRST_ROWS hints, and sometimes none can give the right index. In a unique case I have a query with 1-2 records in FOR ALL ENTRIES internal table that SAP can use the right index. But when the internal table in FOR ALL ENTRIES contains 3 or more records, the same query use full table scan which is extremely slow.
We are using ECC 6 and Oracle 10g.
Please help... Is there notes or fix that I should implement?About the last unique problem, here is the code:
data:
begin of it_vkont occurs 100,
gpart like fkkvkp-gpart,
vkont like fkkvkp-vkont,
end of it_vkont,
begin of it_object_id occurs 0,
vkont like ist_tdata-vkont,
object_id like ist_tdata-object_id,
end of it_object_id.
* -- for snote contains 3 records, this query will return 3 records
select distinct vkont object_id into table it_object_id from ist_tdata
where object_id in snotel
%_hints oracle 'FIRST_ROWS'.
if it_object_id[] is initial.
message e000(0k) with 'Phone number does not exist'.
return.
endif.
* -- for snote contains 3 records, this query will also return 3 records
select gpart vkont appending table it_vkont from fkkvkp
for all entries in it_object_id
where vkont = it_object_id-vkont.
if it_vkont[] is initial.
message e000(0k) with 'Contract Account does not exist'.
return.
endif.
* -- for snote contains 3 (or more) records, SAP will choose a wrong index
select distinct gpart vkont opbel opupk
bukrs blart waers budat
bldat betrw hvorg tvorg
into table t_data
from dfkkop
for all entries in it_vkont
where gpart = it_vkont-gpart
and faedn in sfaedn
and waers in swaers
and applk eq 'T'
and bukrs eq '1000'
and augst eq space
and augbl eq space
and ( tvorg ne '0500' or tvorg ne '0420' )
and blart in ('IP', 'IF', 'IN', 'YY')
%_hints oracle 'INDEX(DFKKOP"Z04")'.
sort t_data by gpart vkont opbel opupk.
For workaround I have replaced the last query to a bad query performance practice but works pretty well in our case.
refresh t_data.
loop at it_vkont.
select distinct gpart vkont opbel opupk
bukrs blart waers budat
bldat betrw hvorg tvorg
appending table t_data
from dfkkop
where gpart = it_vkont-gpart
and faedn in sfaedn
and waers in swaers
and applk eq 'T'
and bukrs eq '1000'
and augst eq space
and augbl eq space
and ( tvorg ne '0500' or tvorg ne '0420' )
and blart in ('IP', 'IF', 'IN', 'YY')
%_hints oracle 'INDEX(DFKKOP"Z04")'.
endloop.
sort t_data by gpart vkont opbel opupk.
delete adjacent duplicates from t_data.
The index Z04 in DFKKOP contains these ordered fields :
GPART Business Partner Number
FAEDN Due date for net payment
WAERS Transaction Currency
APPLK Application area
BUKRS Company Code
AUGST Clearing status
AUGBL Clearing Document or Printed Document
TVORG Subtransaction for Document Item
BLART Document Type -
Start routine to set 0CURRENCY value as USD in transformations
Hi All,
I have an amount field which is being extracted from a flat file and I have to set the currency key field; 0CURRENCY to USD in the transformation in BI 7.0. I see that I cannot do that in transformations so I was thinking of hardcoding in start routine. Can anyone please let me know the code I need to put in?
Thanks in advance!Sia,
Please use function module RSW_CURRENCY_TRANSLATION for currency conversion.
Please check this thread:
Re: currency translation
Hope it helps.
Regards,
Mona -
Calculations in Update rules/Start routine/End Routine
Hi Friends,
I have loaded data to a DSO and i have three fields in to it. Lets say Filed1, Filed2 and Field3. Field1 and Field2 are being populated through an update rule in transformation. Aggregation type for these two fields are "Summation".
Now, after the transformation executed, the Field1 and Field2 are filled with values. I want to calculate the value of Field3 as follows:
Field3 = Field1 - Field2
Can anyone tell me where can i do this calculation? I know we can do this in End routine and in Query but i want to know if there is any other place i can do this calculation in transformation? In try to do this calculation in the update rule for Field3 in transformation, i dont see Field1 and Field2 as these are not source fields. I can not write formula also because we can write formula only on source fields not the data target fields.
Your help will be appreciated in terms of points.
Thanks,
manmitHi,
in the start routine in the global section define the two fields:
data: g_amount1 type /bic/oi<your keyfigure name>,
g_amount2 type /bic/oi<your keyfigure name>.
in the routines to your 2 keyfigures store the result in that fields too.
routine for field1.
g_amount1 = result.
routine for field2.
g_amount2 = result.
and in the routine to field3
result = g_amount1 - g_amount2." or whatever calculation/derivation has to be done.
kind regards
Siggi
Message was edited by:
Siegfried Szameitat -
Start Routine not working correctly.
Hi gurus,
I'm having a problem with a start routine in an update rule to one of my cubes. I debug it and it seems to work fine. However, it ends the simulation saying in the error message "No active update rules exist for this infosource." However, I think it's something to do with the logic I have in my start routine. Below is the start routine which I am trying to debug. I'm doing a lookup on an ODS and if no match is found on that ODS by Sales Order and Sales Order Item, I do another lookup on an object that has the same information that I'm looking to append to the transaction record. Any help would be greatly appreciated. I'm thinking the second loop against the internal table might not be working correctly as it seems to just sit on that table.
Thanks in advance,
John
PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: PENDING_QTY LIKE /BIC/AZO_BKLG100-/BIC/ZQTYPEND1,
ABSOLUTE_QTY LIKE /BIC/AZO_BKLG100-/BIC/ZQTYPEND1,
TEN_PERCENT LIKE /BIC/AZO_BKLG100-/BIC/ZQTYPEND1,
TEN_PERCENT_VALUE TYPE P LENGTH 4 DECIMALS 2 VALUE '0.1'.
DATA: ZWEEK LIKE SCAL-WEEK.
$$ 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/CSZO_PMO1_ENHANCED.
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
TABLES : /BIC/AZO_PMI100. "Active PM Invoice ODS
TABLES : /BIC/PZ_CTBWOBJ. "CTBW Order Master
DATA: T_DATA_PAK LIKE DATA_PACKAGE OCCURS 0 WITH HEADER LINE,
T_DATA_PAK1 LIKE DATA_PACKAGE OCCURS 0 WITH HEADER LINE,
IV_INVQTY like /BIC/AZO_PMI100-INV_QTY,
IV_INVVAL like /BIC/AZO_PMI100-NETVAL_INV,
BEGIN OF IT_INVOICES OCCURS 0,
INV_SALES_ORD LIKE /BIC/AZO_PMI100-/BIC/ZSORDDORD,
INV_SALES_ITEM LIKE /BIC/AZO_PMI100-/BIC/ZSORDIORD,
INV_DOC_NUM LIKE /BIC/AZO_PMI100-/BIC/ZBILLDINV,
INV_DOC_ITEM LIKE /BIC/AZO_PMI100-/BIC/ZBILLIINV,
INV_QTY LIKE /BIC/AZO_PMI100-INV_QTY,
NETVAL_INV LIKE /BIC/AZO_PMI100-NETVAL_INV,
ZBRAND LIKE /BIC/AZO_PMI100-/BIC/ZBRAND,
ZBRANDOWN LIKE /BIC/AZO_PMI100-/BIC/ZBRANDOWN,
ZDESGNOWN LIKE /BIC/AZO_PMI100-/BIC/ZDESGNOWN,
ZFLAGBKLG LIKE /BIC/AZO_PMI100-/BIC/ZFLAGBKLG,
ZNOCOLORS LIKE /BIC/AZO_PMI100-/BIC/ZNOCOLORS,
ZNOSPCLRS LIKE /BIC/AZO_PMI100-/BIC/ZNOSPCLRS,
ZOPENFCTY LIKE /BIC/AZO_PMI100-/BIC/ZOPENFCTY,
ZPACKSYST LIKE /BIC/AZO_PMI100-/BIC/ZPACKSYST,
ZPPG LIKE /BIC/AZO_PMI100-/BIC/ZPPG,
ZAPPLICAT LIKE /BIC/AZO_PMI100-/BIC/ZAPPLICAT,
ZPAPERGDE LIKE /BIC/AZO_PMI100-/BIC/ZPAPERGDE,
ZPRINTMTH LIKE /BIC/AZO_PMI100-/BIC/ZPRINTMTH,
ZQUALITY LIKE /BIC/AZO_PMI100-/BIC/ZQUALITY,
ZSHAPE LIKE /BIC/AZO_PMI100-/BIC/ZSHAPE,
ZSIZE LIKE /BIC/AZO_PMI100-/BIC/ZSIZE,
ZVARIANT LIKE /BIC/AZO_PMI100-/BIC/ZVARIANT,
ZVOLUME LIKE /BIC/AZO_PMI100-/BIC/ZVOLUME,
END OF IT_INVOICES,
BEGIN OF IT_CTBW OCCURS 0,
CTBW_SALES_ORD LIKE /BIC/PZ_CTBWOBJ-/BIC/ZSORDDORD,
CTBW_SALES_ITEM LIKE /BIC/PZ_CTBWOBJ-/BIC/ZSORDIORD,
CTBW_BRAND LIKE /BIC/PZ_CTBWOBJ-/BIC/ZBRAND,
CTBW_BRANDOWN LIKE /BIC/PZ_CTBWOBJ-/BIC/ZBRANDOWN,
CTBW_DESGNOWN LIKE /BIC/PZ_CTBWOBJ-/BIC/ZDESGNOWN,
CTBW_NOCOLORS LIKE /BIC/PZ_CTBWOBJ-/BIC/ZNOCOLORS,
CTBW_NOSPCLRS LIKE /BIC/PZ_CTBWOBJ-/BIC/ZNOSPCLRS,
CTBW_C_APM_006 LIKE /BIC/PZ_CTBWOBJ-/BIC/C_APM_006,
CTBW_PACKSYST LIKE /BIC/PZ_CTBWOBJ-/BIC/ZPACKSYST,
CTBW_PAPERGDE LIKE /BIC/PZ_CTBWOBJ-/BIC/ZPAPERGDE,
CTBW_PPG LIKE /BIC/PZ_CTBWOBJ-/BIC/ZPPG,
CTBW_PRINTMTH LIKE /BIC/PZ_CTBWOBJ-/BIC/ZPRINTMTH,
CTBW_QUALITY LIKE /BIC/PZ_CTBWOBJ-/BIC/ZQUALITY,
CTBW_SHAPE LIKE /BIC/PZ_CTBWOBJ-/BIC/ZSHAPE,
CTBW_SIZE LIKE /BIC/PZ_CTBWOBJ-/BIC/ZSIZE,
CTBW_VARIANT LIKE /BIC/PZ_CTBWOBJ-/BIC/ZVARIANT,
CTBW_VOLUME LIKE /BIC/PZ_CTBWOBJ-/BIC/ZVOLUME,
END OF IT_CTBW.
*These deletions are already included in the InfoPackage:
*Keep only PackMat Finished Materials SOrders:
*DELETE DATA_PACKAGE
WHERE MATL_GROUP(5) NE 'PM-FM'.
*Keep only open SOrders:
*DELETE DATA_PACKAGE
where /BIC/ZOSTATUS = 'C'.
*Keep only MC and CF SOrders:
*DELETE DATA_PACKAGE
where DOC_TYPE NE 'ZOR6' AND DOC_TYPE NE 'ZOR9'.
*Keep only non rejected SOrders:
DELETE DATA_PACKAGE
where REASON_REJ IS NOT INITIAL.
Exclude list of statistical Item Categories (not billing
relevant).
DELETE DATA_PACKAGE WHERE
ITEM_CATEG = 'ZPC1' or
ITEM_CATEG = 'ZPC2' or
ITEM_CATEG = 'ZPC3' or
ITEM_CATEG = 'ZPC4' or
ITEM_CATEG = 'ZTAF' or
ITEM_CATEG = 'ZTAE' or
ITEM_CATEG = 'ZTAG' or
ITEM_CATEG = 'ZTSV'.
REFRESH: T_DATA_PAK,T_DATA_PAK1,
IT_INVOICES, IT_CTBW.
T_DATA_PAK[] = DATA_PACKAGE[].
T_DATA_PAK1[] = DATA_PACKAGE[].
DATA : COUNT1 LIKE SY-TABIX.
DESCRIBE TABLE T_DATA_PAK1 LINES COUNT1.
IF NOT COUNT1 IS INITIAL.
Selection for Invoice Items ***********
SORT T_DATA_PAK1 BY /BIC/ZSORDDORD /BIC/ZSORDIORD.
SELECT /BIC/ZSORDDORD /BIC/ZSORDIORD /BIC/ZBILLDINV /BIC/ZBILLIINV
INV_QTY NETVAL_INV
/BIC/ZBRAND /BIC/ZBRANDOWN /BIC/ZDESGNOWN /BIC/ZFLAGBKLG
/BIC/ZNOCOLORS /BIC/ZNOSPCLRS /BIC/ZOPENFCTY /BIC/ZPACKSYST
/BIC/ZPPG /BIC/ZAPPLICAT /BIC/ZPAPERGDE /BIC/ZPRINTMTH
/BIC/ZQUALITY /BIC/ZSHAPE /BIC/ZSIZE /BIC/ZVARIANT
/BIC/ZVOLUME
INTO TABLE IT_INVOICES
FROM /BIC/AZO_PMI100
FOR ALL ENTRIES IN T_DATA_PAK1
WHERE /BIC/ZSORDDORD = T_DATA_PAK1-/BIC/ZSORDDORD AND
/BIC/ZSORDIORD = T_DATA_PAK1-/BIC/ZSORDIORD AND
051114: Exclude pro forma invoices from selection.
( bill_type NE 'ZPF1' AND bill_type NE 'ZPF2' AND
bill_type NE 'ZPF3').
SORT: IT_INVOICES BY INV_SALES_ORD INV_SALES_ITEM.
DELETE IT_INVOICES WHERE ZQUALITY IS INITIAL.
REFRESH: T_DATA_PAK1.
LOOP AT T_DATA_PAK.
CLEAR: T_DATA_PAK1, IV_INVQTY, IV_INVVAL, IT_INVOICES, IT_CTBW.
MOVE-CORRESPONDING T_DATA_PAK TO T_DATA_PAK1.
loop at IT_INVOICES
where INV_SALES_ORD = T_DATA_PAK-/BIC/ZSORDDORD
and INV_SALES_ITEM = T_DATA_PAK-/BIC/ZSORDIORD.
IV_INVQTY = IV_INVQTY + IT_INVOICES-INV_QTY.
IV_INVVAL = IV_INVVAL + IT_INVOICES-NETVAL_INV.
endloop.
Use req. del. date if not conf. del. date is available
Changes being made to use conf. del. date instead of
req. del. date. This is not always filled in.
IF T_DATA_PAK1-/BIC/ZDATESCHL IS INITIAL.
MOVE T_DATA_PAK1-DSDEL_DATE to T_DATA_PAK1-/BIC/ZDATESCHL.
ENDIF.
move:
IV_INVQTY to T_DATA_PAK1-INV_QTY,
IV_INVVAL to T_DATA_PAK1-NETVAL_INV,
IT_INVOICES-ZBRAND to T_DATA_PAK1-/BIC/ZBRAND,
IT_INVOICES-ZBRANDOWN to T_DATA_PAK1-/BIC/ZBRANDOWN,
IT_INVOICES-ZDESGNOWN to T_DATA_PAK1-/BIC/ZDESGNOWN,
IT_INVOICES-ZFLAGBKLG to T_DATA_PAK1-/BIC/ZFLAGBKLG,
IT_INVOICES-ZNOCOLORS to T_DATA_PAK1-/BIC/ZNOCOLORS,
IT_INVOICES-ZNOSPCLRS to T_DATA_PAK1-/BIC/ZNOSPCLRS,
IT_INVOICES-ZOPENFCTY to T_DATA_PAK1-/BIC/ZOPENFCTY,
IT_INVOICES-ZPACKSYST to T_DATA_PAK1-/BIC/ZPACKSYST,
IT_INVOICES-ZPPG to T_DATA_PAK1-/BIC/ZPPG,
IT_INVOICES-ZAPPLICAT to T_DATA_PAK1-/BIC/ZAPPLICAT,
IT_INVOICES-ZPAPERGDE to T_DATA_PAK1-/BIC/ZPAPERGDE,
IT_INVOICES-ZPRINTMTH to T_DATA_PAK1-/BIC/ZPRINTMTH,
IT_INVOICES-ZQUALITY to T_DATA_PAK1-/BIC/ZQUALITY,
IT_INVOICES-ZSHAPE to T_DATA_PAK1-/BIC/ZSHAPE,
IT_INVOICES-ZSIZE to T_DATA_PAK1-/BIC/ZSIZE,
IT_INVOICES-ZVARIANT to T_DATA_PAK1-/BIC/ZVARIANT,
IT_INVOICES-ZVOLUME to T_DATA_PAK1-/BIC/ZVOLUME.
if IT_INVOICES-ZFLAGBKLG is initial.
SELECT /BIC/ZSORDDORD
/BIC/ZSORDIORD
/BIC/ZBRAND
/BIC/ZBRANDOWN
/BIC/ZDESGNOWN
/BIC/ZNOCOLORS
/BIC/ZNOSPCLRS
/BIC/C_APM_006
/BIC/ZPACKSYST
/BIC/ZPAPERGDE
/BIC/ZPPG
/BIC/ZPRINTMTH
/BIC/ZQUALITY
/BIC/ZSHAPE
/BIC/ZSIZE
/BIC/ZVARIANT
/BIC/ZVOLUME
INTO TABLE IT_CTBW
FROM /BIC/PZ_CTBWOBJ
FOR ALL ENTRIES IN T_DATA_PAK1
WHERE /BIC/ZSORDDORD = T_DATA_PAK1-/BIC/ZSORDDORD AND
/BIC/ZSORDIORD = T_DATA_PAK1-/BIC/ZSORDIORD AND
OBJVERS = 'A'.
SORT: IT_CTBW BY CTBW_SALES_ORD CTBW_SALES_ITEM.
DELETE IT_CTBW WHERE CTBW_QUALITY IS INITIAL.
REFRESH: T_DATA_PAK1.
endif.
loop at IT_CTBW
where CTBW_SALES_ORD = T_DATA_PAK-/BIC/ZSORDDORD
and CTBW_SALES_ITEM = T_DATA_PAK-/BIC/ZSORDIORD.
endloop.
move:
IT_CTBW-CTBW_BRAND to T_DATA_PAK1-/BIC/ZBRAND,
IT_CTBW-CTBW_BRANDOWN to T_DATA_PAK1-/BIC/ZBRANDOWN,
IT_CTBW-CTBW_DESGNOWN to T_DATA_PAK1-/BIC/ZDESGNOWN,
IT_CTBW-CTBW_NOCOLORS to T_DATA_PAK1-/BIC/ZNOCOLORS,
IT_CTBW-CTBW_NOSPCLRS to T_DATA_PAK1-/BIC/ZNOSPCLRS,
IT_CTBW-CTBW_PACKSYST to T_DATA_PAK1-/BIC/ZPACKSYST,
IT_CTBW-CTBW_PPG to T_DATA_PAK1-/BIC/ZPPG,
IT_CTBW-CTBW_PAPERGDE to T_DATA_PAK1-/BIC/ZPAPERGDE,
IT_CTBW-CTBW_PRINTMTH to T_DATA_PAK1-/BIC/ZPRINTMTH,
IT_CTBW-CTBW_QUALITY to T_DATA_PAK1-/BIC/ZQUALITY,
IT_CTBW-CTBW_SHAPE to T_DATA_PAK1-/BIC/ZSHAPE,
IT_CTBW-CTBW_SIZE to T_DATA_PAK1-/BIC/ZSIZE,
IT_CTBW-CTBW_VARIANT to T_DATA_PAK1-/BIC/ZVARIANT,
IT_CTBW-CTBW_VOLUME to T_DATA_PAK1-/BIC/ZVOLUME.
if T_DATA_PAK1-MATERIAL+0(1) eq 'A'.
move T_DATA_PAK1-MATERIAL+1(4) to T_DATA_PAK1-/BIC/ZQUALITY.
move T_DATA_PAK1-MATERIAL+5(3) to T_DATA_PAK1-/BIC/ZSIZE.
move T_DATA_PAK1-MATERIAL+8(2) to T_DATA_PAK1-/BIC/ZVARIANT.
endif.
APPEND T_DATA_PAK1.
ENDLOOP.
ENDIF.
IF SY-SUBRC EQ 0.
DATA_PACKAGE[] = T_DATA_PAK1[].
ABORT = 0.
ENDIF.
REFRESH: T_DATA_PAK, T_DATA_PAK1.
REFRESH: IT_INVOICES, IT_CTBW.
FREE: T_DATA_PAK,T_DATA_PAK1.
FREE: IT_INVOICES, IT_CTBW.
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.
Edited by: John Lucky on Jan 25, 2008 10:58 PMHi,
Why is the hard coding of "breakpoint" done.
Try removing it.
Regards
Merlin. -
Urgent : Doubt in writing a code in start routine
Hi all ,
I am BI 7.0 system , I have doubt in writing a code in start routine .
1) i have to extract the data first from a custom table based on one condition and then placing it into internal table .
2) Now i have to loop at source_package for a particular region field say "ASIA". with this result i have to check for the correponding entries in custoom table .
if condition is not true (i.e ) with entries or not matching then delete that particular record from source_package.
i have written a small logic for this . but this is producing any ouput , Please check it and also let me know for modifications .
thanks in advance.
select * from zcsp
into corresponding fields of TABLE itab_T
where
ZBUSINESSUNIT = 'BC'.
loop at SOURCE_PACKAGE into ls_SOURCE_PACKAGE where /BIC/DPREGION = 'XE'.
loop at itab_t into itab_w where zcategory =
ls_source_package-/BIC/DPMAT/BIC/DPCAT.
if sy-subrc ne 0.
delete SOURCE_PACKAGE.
endif.
endloop.
endloop.You're deleting the entire input package. You only want to delete the one row.
DATA: g_tabix TYPE sy-tabix.
SELECT * FROM zscp
INTO CORRESPONDING FIELDS OF TABLE itab_t
WHERE zbusinessunit = 'BC'.
SORT itab_t BY zcategory.
LOOP AT source_package INTO ls_source_package WHERE /bic/dpregion = 'XE'.
g_tabix = sy-tabix.
READ TABLE itab_t WITH KEY zcategory = ls_source_package-/bic/dpmat/bic/dpcat TRANSPORTING NO FIELDS BINARY SEARCH.
IF sy-subrc NE 0.
DELETE source_package INDEX g_tabix.
ENDIF.
ENDLOOP. -
ABAP assistance - start routine logic in update rule
I have used an existing update rule and have based my logic around the same. The purpose of the rule is to look up customer master data and get a subset of customer numbers from the transaction records so that the values for customer number from the transactional data will not be updated if it does not match with existing master data customer numbers.
The loads are full and we drop the data before we load.
I have listed the logic below (the number at the front is to be considered as the line number) and a list of open questions that I have thereafter:
Start routine logic:
1 DATA: l_index LIKE sy-tabix.
2 DATA: BEGIN OF ls_customer,
3 customer TYPE /BI0/OICUSTOMER,
4 objver TYPE RSOBJVERS,
5 END OF ls_customer,
6 lt_customer LIKE TABLE OF ls_customer.
7 REFRESH: lt_customer.
8 LOOP AT DATA_PACKAGE.
all customers from data package
9 ls_customer-custno = DATA_PACKAGE-custid.
10 ls_customer-objver = 'A'
11 APPEND ls_customer TO lt_customer.
12 ENDLOOP.
12 SORT lt_customer.
13 DELETE ADJACENT DUPLICATES FROM lt_customer.
14 IF NOT lt_customer[] IS INITIAL.
15 SELECT /BI0/OICUSTOMER RSOBJVERS
16 FROM /BI0/PCUSTOMER
17 INTO CORRESPONDING FIELDS OF TABLE lt_customer
18 FOR ALL ENTRIES IN lt_customer
19 WHERE ls_customer-custno = DATA_PACKAGE-custid
20 AND ls_customer-objver = 'A'
21 SORT lt_customer BY customer ASCENDING
22 ENDIF.
Questions
Line
1 - what is the purpose of this line? What is it that is being declared
2 - in some code I have seen this line with OCCURS 0 at the end what does this mean with and without the term?
4 - I am using the Data Element name is this correct or should I use the field name?
3 - 5 here I declare an internal structure/table is that correct?
6 - here I declare a work area based on the internal table is that correct?
7 - What would happen if I avoided using the REFRESH statement?
8 - 12 - Is this syntactically correct, I am trying to get a set of data which is the customer numbers which match the master data customers and the master data record is án active version and than appendíng to the work area?
13 - My understanding is this will reduce the number of records in the work area is this correct and needed?
14 - 22 I am trying to identify my required set of data but feel I am repeating myself, could someone advise?
Finally what logic would I actually need to write in the key figure object, could I use something like:
Result = lt_customer.
Thanks
Edited by: Niten Shah on Jun 30, 2008 8:06 PM1. This line is not required
2. OCCURS 0 is the OLD way of defining an internal table with that structure. As it is, it just defines a flat structure.
3. Data element is usually best
3-5 Yes
6. No. Here you are declaring a table of the type of the flat structure. Just as the ABAP says!
7. Nothing. But by putting this in, you ensure that you know the state of the table (empty) before you start looping through the data package
8-12. You can tell if it is syntactically correct by pressing Ctrl-F2 when in the editor. Looks ok.
13. Ensures your list of customers contains no duplicated. The code up to this point is building a list of all the unique customers in the data package.
14-22. Goes to the database and brings back ONLY those customers which are found in the master data. Looks ok.
This is a start routine (that's why you've got a data package). You don't use result. You should update the datapackage. But this you haven't done. Double click on the table name /BIC/PCUSTOMER to get the correct field names.
So you have to loop through the data package again, and check if the customer in the datapackage is lt_customer. If it is, fine, otherwise you blank it and report an error, or set an error message or whatever.
I wouldn't do it like this. I'd do something like this:
STATICS: st_customer TYPE HASHED TABLE OF TYPE /bi0/oicustomer
WITH UNIQUE KEY TABLE_LINE.
* st_customer retains its value between calls, so only populate if empty
* In one run of the infopackage, this will mean you do only one read of
* the master data, so very efficient.
IF st_customer IS INITIAL.
SELECT customer FROM /BI0/PCUSTOMER
INTO TABLE st_customer
WHERE objvers EQ 'A'. " Only active values
ENDIF.
* Go through data package
LOOP AT DATA_PACKAGE.
* Check whether the customer exists.
READ TABLE st_customer TRANSPORTING NO FIELDS
WITH TABLE KEY table_line = DATA_PACKAGE-custid.
CHECK sy-subrc IS NOT INITIAL.
* If you get here, the customer isn't valid. So I'm just setting it blank
CLEAR DATA_PACKAGE-custid.
MODIFY DATA_PACKAGE. " Updates the datapackage record
ENDLOOP.
Even this is not fully optimised, but it's not bad.
I strongly suggest that you get yourself sent on the basic ABAP programming course if you're going to do a lot of this. Otherwise, read the ABAP documentation in the help.sap.com, and, from the editor, get the cursor on each ABAP keyword and press F1 to read the ABAP help.
matt -
How to get the PSA name in a Start Routine in the Update Rules of a Cube.
Hi all.
I have an InfoSource that loads data directly in an Infocube.
In the Start Routine of the Update Rules I need to retrieve the PSA table name for that InfoSource, to access it and check some data.
I can't use the PSA name you seen in the DataFlow because it will change once the update rules are transported to another system.
Please advice.
Thanks!!!Hi,
we do it as follows:
first get the request ID:
DATA: tp_request(30) VALUE 'REQUEST'.
FIELD-SYMBOLS: <wa> TYPE ANY, <tp_req> TYPE ANY, <tp_dtp> TYPE ANY.
READ TABLE datapak ASSIGNING <wa> INDEX 1.
IF sy-subrc <> 0. ABORT = 4. ENDIF.
ASSIGN COMPONENT tp_request OF STRUCTURE <wa> TO <tp_req>.
IF sy-subrc <> 0. ABORT = 4. ENDIF.
requnr = <tp_req>.
then we get the table with
SELECT odsname_tech FROM rstsodspart WHERE request = requnr.
you may need to adjust this code, I've just pasted the relevant parts...
another way is to get this info from RSTSODS where the different versions are maintained...
let me know if you need further detail about this stuff...
hope this helps...
Olivier.
Message was edited by:
Olivier Cora
Maybe you are looking for
-
How can I print to my wireless printer from my iPad?
I have an Epson Artison 710 which is wireless. How do I set up my new iPad to print to it? And a question for Apple...why no USB port for the iPad?...thnx cb
-
According to the help page i was viewing my Late 2011 13' MacBook Pro should support Airplay Mirroring. However the airplay icon does not appear on my menu bar like i says it should and when i go to System prefereneces>Display nothing appears there
-
Scripting shortcut for pencil tool in Acrobat 9 Pro?
Many of the tools in Acrobat 9 Pro have a keyboard shortcut (P=callout box, U=highlight, Z=marquee zoom...) but not the pencil tool. Anyone scripted a shortcut key or be willing to explain the process of writing a script and assigning it to a keystro
-
Commit processing in Forms 10g, what triggers fire etc.
In the oracle documentation there used to be a commit processing flowchart that said exactly what triggers fire on commit. Don't seem to be able to find such a thing online. This started by trying to work out if when-validate-item always fired on com
-
Hi. I recently got a legal version of Microsoft's Office 98 from a friend at work who had no need for it anymore. I'm currently running OS X 10.3.9 so it won't run without classic. I really have no use for classic all together (unless I want to use W