Key Figure calculation in Abap is not working correctly - Overlooping

Hi,
I wrote a logic to calculate the ratio of key figure but it is not working correctly
For example I have a requirement to split 1 Product into Several new Products and also the Net Amount will be splitted to these several new products as well. The total Amount of the new product will be equivalent to the Net Amount.
So far my Logic is splitting the product to several new products but the amount is incorrect as the calculation is over looping.
Sample
A PRODUCT has Net Amount 1000. And this product needs to be splitted into 3 new products. Each of this new product is assigned a ratio of 0.3, 0.2 and 0.7 respectively. total sum of the ratio is 1.
PRODUCT1 0.3 = 1000 * 0.3 = 300
PRODUCT2 0.2 = 1000 * 0.2 = 200
PRODUCT3 0.7 = 1000 * 0.7 = 700
The total amount of this new products is 1000.
Now my logic is working this way.
PRODUCT1 0.3 = 1000 * 0.3 = 300
PRODUCT2 0.2 = 1000 * 0.2 * 0.3 = 60
PRODUCT3 0.7 = 1000 * 0.2 * 0.3 * 0.7 = 42
Only the PRODUCT1 is working correctly and there is overlooping for the remaining products
Logic used
DATA: t_data TYPE data_package_structure OCCURS 0 WITH HEADER LINE.
DATA: t_newdso LIKE /bic/newdso OCCURS 0 WITH HEADER LINE.
DATA: t_olddso LIKE /bic/olddso OCCURS 0 WITH HEADER LINE.
DATA: amount LIKE data_package-netamount.
DATA: zidx LIKE sy-tabix.
REFRESH t_data.
LOOP AT data_package.
  zidx = sy-tabix.
  MOVE-CORRESPONDING data_package TO t_data.
  REFRESH t_newdso.
  SELECT * FROM newdso INTO TABLE t_newdso WHERE prod =
  data_package-prod.
  SORT t_newdso BY prod.
*LOOP AT T_NEWDSO.
  READ TABLE t_newdso WITH KEY prodh4 = t_data-prod.
  IF sy-subrc EQ 0.
    LOOP AT t_newdso.
      t_data-prod = t_newdso-/bic/znew_mp.
      t_data-material = t_newdso-material.
*T_DATA-NETAMOUNT = T_DATA NETAMOUNT * T_NEWDSO-/BIC/ZSP_RATIO.*
      APPEND t_data.
    ENDLOOP.
  ELSE.
    REFRESH t_olddso.
    SELECT * FROM olddso INTO TABLE t_olddso WHERE prod =
    data_package-prod.
    SORT t_olddso BY prod.
    READ TABLE t_olddso WITH KEY prodh4 = t_data-prod.
    t_data-prod = t_olddso-prod.
    t_data-material = t_olddso-material.
    APPEND t_data.
  ENDIF.
  MODIFY data_package INDEX zidx.
ENDLOOP.
REFRESH data_package.
data_package[] = t_data[].
thanks
Edited by: Matt on Sep 27, 2010 2:25 PM - added  tags

Hi,
I am not really good at debugging Abap code since I am a newbie. however  I have tried to add CLEAR T_DATA before the first loop.
REFRESH T_DATA.
LOOP AT DATA_PACKAGE.
ZIDX = SY-TABIX.
MOVE-CORRESPONDING DATA_PACKAGE TO T_DATA.
and before the second loop and select statement and at the end of the loop.
REFRESH T_NEWDSO.
SELECT * FROM NEWDSO INTO table T_NEWDSO WHERE PROD =
DATA_PACKAGE-PROD.
SORT T_NEWDSO BY PROD.
READ TABLE T_NEWDSO WITH KEY PROD = T_DATA-PROD.
IF sy-subrc EQ 0.
LOOP AT T_NEWDSO.
but then not all data are being fetched.
thanks
Edited by: Bhat Vaidya on Sep 28, 2010 8:33 AM

Similar Messages

  • The intellisence fuctionality in ABAP editor not working correctly

    I have an issue getting the intellisence to work correctly.  It will sense the word and show it but when I hit enter for it to copy it just goes to the next line.  I tried changing the keyboard settings but htis doens't do anything either.

    Tab works for me too.  Enter does not. SAPGUI 7.10 patch 19.
    But there appears to be several areas to look for changes:
    1) Tweak SAP GUI
    2) In the bottom right corner of the editor, there's a small icon that looks like a page. Press it, and a new screen will open.
    Select "Keyboard", and scroll down to Edit.Autocomplete and experiment with settings.
    3) Change an xml setting by editing file (depending on operating system):
        a) c:\Documents and Settings\[user]\SapWorkDir\ab4_data\settings.xml.
        b) look for the section "Code_Completion"
        c) change value from 0 to 1 in 1{/CodeHintAgreeByReturn}
    Hope one of these helps.

  • Z10 Calculator - percent function does not work correctly

    my Z10 STL-1 model suddenly gets turned off. but battery before turning off shows around 40% charged.
    whats the reason? how can i fix it?

    What is happening is that your on-device battery meter is off-sync with the actual battery charge. Connect to your OEM wall outlet battery charger and while still connected and powered on, remove the battery a minute to reboot. After reboot leave to fully charge to 100%.
    Thus will reset the false charge reading. You may need to do perform this procedure 2-3 times.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • I had to get a new keyboard and now the keys in the upper row are not working appropriately. How can I fix this problem?

    My keyboard stopped working so I went to the apple store to replace it with another one. Now I am back home and the keys at the very top are not working correctly (volumn  F12 shows the dashboard, F11 takes the screen up and away, F8 pause button shows spaces, etc.). What should I do to correct this problem - I assume I probably need to download some type of softwear but what? I have a Mac OS X  Version 10.5.8 desktop - 2.66 GHz Intel Core 2 Duo processor.

    All new keyboards need Snow Leopard 10.6.8 and above for full functionality.
    Rather short-sighted of Apple perhaps, but that seems to be a trend these days.
    I'm afraid the only fix is to upgrade to SL. Personaly, I'd take it back and get a refund and seek an older keyboard or a third-party one elsewhere.

  • Function keys are not working correctly

    I've been looking all over the various threads and I can't find an answer that solves my problem.
    Here are the details:
    I bought the computer in the U.S. where I live.
    I have a iMac 2.4GHz intel Core 2 Duo  EMC 2133 with a 20" screen. Bought it new in February 2008.
    I have Mac OS X 10.5.8  (I am waiting for my order for OS Snow Leopard to come in!!)
    I have been using a wireless mouse and Keyboard (Love not having cords!)
    Recently, my wireless keyboard got a short and quit working. I went down to the apple store and got a new wireless keyboard.
    I had the computer with me at the genius bar so, yes, the apple employee saw exactly what I have.
    I took it all home got the thing all put back together and got the new keyboard paired up and working with the computer.
    Here are the problems:
    Went to go use the function keys while using iTunes and found they weren't working properly. The F10, F11 and F12 do not control the volume of sound as the keyboard indicates they would, they instead activate dashboard, spaces, and application windows. 
    Following the advice of other threads, I looked over in the system preferences and made sure the "Use all F1, F2 etc." box was unchecked (it was unchecked), things still didn't work.
    I tried the fn key but it appears to not work at all it has no effect on the functioning of the function keys.
    I went under keyboard shortcuts in system preferences and found the F10, F11 and F12 keys, it confirms that those keys control spaces, dashboard and application windows as they are performing but shows no options to either reassign to volume control (as marked on the keyboard) or make the fn key work.
    I've gone back and forth trying various combinations of checked and unchecked boxes to see if anything would work, so far I've come up with nothing.
    A couple more important or interesting facts:
    Yes I have turned off and taken the batteries out of the old keyboard. My bluetooth connection currently shows it as disconnected.
    I have restarted the computer.
    One thing I find odd; when I go under preferences and go to Keyboard and Mouse when I go under the section "Bluetooth" it shows Bluetooth mouse with the name of the mouse and the battery level. BUT nothing is showing up under bluetooth Keyboard, I can't figure out how to change this and don't know if it is contributing to the problem.
    When I go under the bluetooth logo on the top bar I find the mouse and both keyboards referenced, the old keyboard is shown as disconnected and the other two are connected. I have tried to update the device's name but it doesn't seem to let me.
    I have double clicked on the device under bluetooth and it shows the new keyboard as discoverable, paired and connected. Hence, I am using the new keyboard to write this inquiry.
    Please, any assistance would be of great help. I have tried to be thorough in order help narrow the possible problem. Thanks!!

    Hendry
    Just thought I'd let you know.  Our suspicions were correct, it was the OS. After I installed Snow Leopard (10.6.8) all the problems were corrected.  I also updated the RAM from 1 gb to 6 gb. The mac is working all around better. Sorry it took so long to get back to everyone. My superdrive had pooped out. Rather than replace it I got an external drive from OWC connected with firewire 800.  So far everything is running very well, as far as I can tell this external drive is better than the original superdrive. My superdrive has always acted funny, infact I returned the first mac I got after a week because its superdrive was also malfunctioning. Anyway, all that to say everything seems to be fully functioning again.
    Roy
    Re: Function keys are not working correctly 

  • Key figures with Heirarchy in Bexquery not showing up in Snapshot/ Explorer

    Hi,
    I am taking a snapshot of a multiprovider in Explorer using T-code RSDDV.
    In the related bex query I have a few calculated Key figure which I want to get it into the explorer tab / Key- figures. The idea here is to use these as measures within the Explorer portal.
    The problem I am running into is if any of these key figures use Hierarchies I am not able to bring it in but without the hierarchies I have no issue.
    Has someone come across this?
    If you need more clarification please feel free to ask.
    Thanks
    bob

    You have a beautiful example in the Oracle By Example Series here :
    http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html#t2s7
    If you follow the instruction on the Channels Detail_Key in this example, you will succeed
    Success
    Nico

  • Is prompted filter not working correctly with calculated items

    Hello,
    I am working on OBIEE 11.1.1.3 and having problem problem linking 2 analisys with action link
    The test case is:
    I have 2 attribute columns on a dimension
    1. Conto 1 Code
    2. Conto 1 Dsc (in RPD i set up the property Descritor ID of -> Conto 1 Code)
    3. Conto 2 Code
    4. Conto 2 Dsc (in RPD i set up the property Descritor ID of -> Conto 2 Code)
    5. Conto Detail
    and 1 measure on the fact table
    1. Revenue (defined on RPD as simple sum)
    On presentation layer i have the analisys:
    1.
    The First one using as Criteria: Conto 1 Dsc | Conto 2 Dsc | Revenue
    The layout is a table with sub-total on Conto 1 Dsc
    On Revenue i created an action link to the second analisys containing
    2.
    Criteria: Conto 1 Dsc | Conto 2 Dsc | Conto Detail | Revenue
    Filters: Conto 1 Code (is prompted) | Conto 2 Code (is prompted)
    This pair of analisys are working fine.
    Then i created a second pair of analisys as:
    1.
    Criteria: Conto 2 Dsc | Revenue
    Using Calculated group \ Items i created a numerous set of sub-totals
    On Revenue i created an action link to the second analisys containing
    2.
    Criteria: Conto 2 Dsc | Conto Detail | Revenue
    Filters: Conto 2 Code (is prompted)
    This pair of analisys are not working correctly. When i drill from first analisys to second one the Conto 2 Code filter is not used.
    Replacing in the second analisys Conto 2 Code (is prompted) with Conto 2 Dsc (is prompted) a filter is being generated on the drill but it's using the Conto 2 Code value and the analisys ends with no results.
    Thanks,
    Jonni

    Try adding Conto 2 code to the first analysis and keep the filter on the second analysis as Conto 2 code is prompted.
    -Amith.

  • The "A" key on my macbook pro is not working Can I fix it myself?

    The "A" key on my macbook pro will not work.  How can I fix it?
          -----Earnie---------

    Don't use any cleaning spray. Wipe with a moist but not wet microfiber cloth.
    1. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own"
    2.Reset PRAM. http://support.apple.com/kb/PH4405

  • One of the key on my macbook pro is not working properly, can it be fixed by a cleaning spray or something. there is lot of dust in where I live and thought that might be the culprit. thanks Jason

    one of the key on my macbook pro is not working properly, can it be fixed by a cleaning spray or something. there is lot of dust in where I live and thought that might be the culprit. thanks Jason

    Don't use any cleaning spray. Wipe with a moist but not wet microfiber cloth.
    1. Reset SMC.     http://support.apple.com/kb/HT3964
        Choose the method for:
        "Resetting SMC on portables with a battery you should not remove on your own"
    2.Reset PRAM. http://support.apple.com/kb/PH4405

  • F# keys on Apple Wireless Keyboard not working correctly.

    Hello everyone,
    Today I bought a brand new Apple Wireless Keyboard (the small ones who resemble laptop keyboards), which I'm very glad I bought as some keys on my older keyboard started not working anymore.
    I configured the keyboard with bluetooth and it's working just fine, except for one thing:
    The F# keys don't work as their respective icons indicate (i.e. If I press F10, F11 and/or F12, the volume isn't affected as it normally should, but instead the keys don't seem to respond, as if I weren't pressing them).
    In the Keyboard & Mouse panel in System Preferences, under the Keyboard Shortcuts, I managed to reset the F1 to F4 keys so they work as their respective icons indicate, though I didn't find and don't know how to create any shortcuts to make the volume keys (F10, F11 & F12) work again.
    Also, I would appreciate if you could help me out to reset the F7, F8 & F9 keys, which don't work either.
    I tried checking and un-checking the "Use the keys F1, F2 and so on, as standard function keys." option under the Keyboard tab, and pressing the "fn" key while pressing the F# keys, but none of those attempts seem to change anything to how the F# keys work.
    I don't know what else to do anymore and I would really appreciate some help now.
    Thanks in advance for your responses,
    Oscar.

    Shutdown your macbook.After thats done , switch the wireless keyboard off. Press Shift + Ctrl + Option  + Power Key (all together ) and then release together. Start up the macbook and once that's up start up the keyboard.Try now.The keys should work fine.

  • I need to re-download Lion and install it. Holding the Option key while clicking on "purchases" does not work.

    I need to re-download Lion and install it, after re-formatting my hard-drive to "journaled" as requested. Holding the Option key while clicking on "purchases" does not work.

    Thanks Smokemonster. I found that the Lion install app was in in my applications folder already. Worked fine.

  • Assigned F key to play an action does not work. Why? Using cs6  iMac and wireless key board

    Assigned F key to play an action does not work to play the action on an image. When the F key is selected it seams to control computer attributes rather than the play action assigned in photoshop. Why? Using cs6  iMac and wireless key board.
    Is this a possible preference setting in mac or is it a setting in cs6 photoshop ? Help and knowledge will be appreciated.

    *** Moderator Action ***
    This networking question has been moved from the Solaris 10 discussion space,
    to the Solaris Networking discussion space, for closer topic alignment.
    Whereas there may be IPV6 nuances specific to your Solaris 10 environment and to the hardware, this appears to be a discussion that may be more global in effect.

  • I buy macbook pro occsaion ; i download osx 10.8.2 and reintal osx , after 2 days  my keyboard is not working correctly ( i mean when i touch the keys ,i see the symles , icant get letters when i type .  i try externel keyboard but is work

    i buy macbook pro occsaion ; i download osx 10.8.2 from internet  and reintal osx , after 2 days  my keyboard is not working correctly ( i mean when i touch the keys ,i see the symles , i cant get letters when i type .  i try with externel keyboard but is work

    Thanks for the reply but there is no option tab or wake for administration use in mountain lion 10.8.2, I only have the wake for network access which is on, I didnt used to have this problem before snow leopard now I have to manually re-login after computer wakes and then access remotely ........

  • Sleep not working correctly

    Since updating my Late 2010 iMac to Moutain Lion the sleep function does not work correctly. They system keep waking up for no reason. The monitor comes comes day or night. I cannot figure out a fix or work around. Any ideas?

    Please read this whole message before doing anything. This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it. Step 1 The purpose of this step is to determine whether the problem is localized to your user account. Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up guest users” (without the quotes) in the search box. Don't use the Safari-only “Guest User” login created by “Find My Mac.” While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin. Test while logged in as Guest. Same problem(s)? After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it. *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing. Step 2 The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login. Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows: 
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
     Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs. The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. *Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. Test while in safe mode. Same problem(s)? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • If statement within a view is not working correctly ?

    Hi all,
    maybe i am wrong but i think the if statement within a view is not working correctly. See code down below.
    I would like to use the Hallo World depending on the page attribute isFrame with or without all the neccessary html tags. Therefore i have embedded the htmlb tags in an if statement. But for any reason if isframe is initial it isn't working. It would be great if anybody could help me.
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <% if not isframe is initial. %>
      <htmlb:content design="design2003">
         <htmlb:page title = "Top Level Navigation view">
    <% endif. %>
    hallo world
    <% if not isframe is initial. %>
         </htmlb:page>
      </htmlb:content>
    <% endif. %>
    thanks in advance and best regards
    Matthias Hlubek

    Matthias,
    The short answer: your example is <b>NOT</b> going to work. The long answer will probably 5 pages to describe. So first let me rewrite the example so that it could work, and then give a short version of the long answer. Do not be disappointed if it is not totally clear. It is rather complicated. (See the nice form of IF statements that are possible since 620.)
    <%@page language="abap"%>
    <%@extension name="htmlb" prefix="htmlb"%>
    <% if isframe is <b>NOT</b> initial. %>
    <htmlb:content design="design2003">
      <htmlb:page title = "Top Level Navigation view">
        hallo world
      </htmlb:page>
    </htmlb:content>
    <% else. %>
      hallo world
    <% endif. %>
    So why does your example not work? Let us start with a simple tag:
      <htmlb:page title = "Top Level Navigation view">
      </htmlb:page>
    Now, for each tag, we have effectively the opening part (<htmlb:page>), an optional body, and then the closing part (</htmlb:page>). We are now at the level of the BSP runtime processing one tag. What the runtime does not know, is whether the tag wants to process its body or not. Each tag can decide dynamically at runtime whether the body should be processed. So the BSP compiler generates the following code:
      DATA: tag TYPE REF TO cl_htmlb_page.
      CREATE OBJECT tag.
      tag->title = 'Top Level Navigation view'.
      IF tag->DO_AT_BEGINNING( ) = CONTINUE.
      ENDIF.
      tag->DO_AT_END( ).
    You should actually just debug your BSP code at ABAP level, and then you will immediately see all of this. Now, let us mix in your example with our code generation. First you simplified example:
    <% if isframe is NOT initial. %>
      <htmlb:page title = "Top Level Navigation view">
    <% endif. %>
    <% if isframe is NOT initial. %>
      </htmlb:page>
    <% endif. %>
    And then with our generated code. Look specifically at how the IF/ENDIF blocks suddenly match!
    if isframe is NOT initial.
      DATA: tag TYPE REF TO cl_htmlb_page.
      CREATE OBJECT tag.
      tag->title = 'Top Level Navigation view'.
      IF tag->DO_AT_BEGINNING( ) = CONTINUE.
    endif.
    if isframe is NOT initial.
      ENDIF.
      tag->DO_AT_END( ).
    endif.
    You can see that your ENDIF statements are closing IF blocks generated by the BSP compiler. Such a nesting will not work. This is a very short form of the problem, there are a number of variations, and different types of the same problem.
    The only way to solve this problem, is probably to put the body into a page fragment and include it like I did above with the duplicate HelloWorld strings. But this duplicates source code. Better is to put body onto a view, that can be processed as required.
    brian

Maybe you are looking for

  • Checkbox in integrated planning

    Hi, I'm new in the IP area and i need to know if i am able to use WAD with IP to do the following : for each line of a financial query result i need to have : - a commentary text zone, so the user can be able to insert any remarks concerning the resu

  • Unable to Create Connection ( Connection error DA0005) in DESKI 3 TIER

    Hi , I have strange error of connection in DESKI 3 Tier. Work Flow: => Wanted to create a deski report in Three Tier( from Infoview) using specific universe. => When I ran query it gives me error saying Connection error DA0005( Unable to create conne

  • Signatures no longer works in mail app

    I started modifying my signatures and after a few changes they quit showing up so I deleted them and now I can't do anything.

  • Qosmio F30-117: How to copy CD to CD?

    how can i copy cd to cd by using toshiba cd creator?

  • Regarding perfrommance tuning

    hi expert, i am having 5 millions records i want to insert record in a table which statement is faster from following. 1 insert into test1 values() select * from test 2 using bulk collect plz can me help me which one is the improvement of performance