Abap Logic for performance tuning not working when using Internal tables

Hi,
I wrote this piece of code that is working correctly that is select SUM of cost from DSO where Plant is the same for Sales Items.
LOOP AT RESULT_PACKAGE INTO rp.
SELECT SUM( /N/S_STRDCOST ) FROM /N/ADSP_DPIT00 INTO
rp-/N/S_STRDCOST
WHERE /N42/S_SALESITEM = rp-/N42/S_ITEMID AND /N42/S_PLPLANT EQ
rp-/N42/S_SOURCE.
MODIFY RESULT_PACKAGE FROM rp.
Clear rp.
ENDLOOP.
Now I try to rewrite it for performance tunning using internal table  but I am getting 0 values. can't figure out whats the problem and been struggling fixing it.
TYPES : begin of ty_DSO_TABLE,
         /N42/S_STRDCOST TYPE /N/ADSP_DSPC00-/N/S_STRDCOST,
         /N42/S_ITEMID TYPE /N/ADSP_DSPC00-/N/S_ITEMID,
       end of ty_DSO_TABLE.
DATA: it_DSO_TABLE type hashed table of ty_DSO_TABLE with unique key
/N/S_ITEMID,
     wa_DSO_TABLE type ty_DSO_TABLE.
Field-symbols:  <rp> TYPE tys_TG_1.
LOOP AT RESULT_PACKAGE assigning <rp>.
  clear wa_DSO_TABLE.
Read table IT_DSO_TABLE into wa_DSO_TABLE with table key /N/S_ITEMID
  = <rp>-/N/S_ITEMID.
  if sy-subrc ne 0.
      select SUM( /N/S_STRDCOST )  into CORRESPONDING
      FIELDS OF wa_DSO_TABLE from
      /N/ADSP_DPIT00 WHERE /N/S_SALESITEM =  <rp>-/N/S_ITEMID AND
      /N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
     if sy-subrc eq 0.
          <rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
     endif.
endif.
ENDLOOP.
Any idea whats wrong with the code
thanks

Hi Vaidya,
According to the code which you have written, there is no value in table IT_DSO_TABLE when you are trying to read the values.And after the read statement you have given a condition for sy-subrc. Hence the select statement is actually not even getting executed. *Also you have not assigned the final value back to the ResultPackage.*_
So Kindly correct your code as follows:
Data: wa_dso type ty_DSO_TABLE.
LOOP AT RESULT_PACKAGE assigning <rp>.
clear wa_DSO_TABLE.
select SUM( /N/S_STRDCOST ) into CORRESPONDING
FIELDS OF wa_DSO_TABLE from
/N/ADSP_DPIT00 WHERE /N/S_SALESITEM = <rp>-/N/S_ITEMID AND
/N/S_PLPLANT EQ <rp>-/N/S_SOURCE.
if sy-subrc eq 0.
<rp>-/N/S_STRDCOST = wa_DSO_TABLE-/N/S_STRDCOST.
MODIFY RESULT_PACKAGE FROM <rp>.
endif.
ENDLOOP.
Hope this helps you.
Regards,
Satyam

Similar Messages

  • WMI InvokeMethod for StartService does not work when used with ManagementOperationObserver on IIS

    Hi,
    I am using .net 4.5 and C# to remotely restart the services. I am using WMI to do this task.  This code works when called from windows application on the machine, but same code when used inside web application it gives exception of invalid parameter.
    We saw it log error in System Event log 
    The machine-default permission settings do not grant Local Activation permission for the COM Server application with CLSID
    {49BD2028-1523-11D1-AD79-00C04FD8FDFF}
     and APPID
    {49BD2028-1523-11D1-AD79-00C04FD8FDFF}
     to the user IIS APPPOOL\<app pool user> SID (S-1-5-82-634865507-143429395-1373251082-3464226226-3883016302) from address LocalHost (Using LRPC). This security
    permission can be modified using the Component Services administrative tool.
    I am pasting below code for reference.
    m.InvokeMethod(observer, "Startservice", null, null);
    //wait until invoke method is complete or 30 sec timeout
    int intCount = 0;
    while
    (!completionHandlerObj.IsComplete)
    if (intCount > 60)
    MessageBox.Show("Inside 30 seconds");
    break;
    //wait 1 sec.
    System.Threading.Thread.Sleep(1000);
    //increment counter
    intCount++;
    //see if call was successful.
    if (HandlerObj.ReturnObject.
    Properties["returnValue"].Value.ToString() == "0")
    isStarted = true;
    Dhanaji

    For web apps the context will be the context of the app pool.  Unless you set the app pool to run as a user account that has admin privileges on the remote machine then you won't be able to control the services on a remote machine.  If you have
    enabled Win auth such that the app runs in the context of the remote user then you might need to turn on delegation otherwise the hop won't work.
    Note that if you are using Win auth then consider using ServiceController instead which provides the same functionality as WMI but with a cleaner syntax.  This wouldn't work if you need to impersonate a user though.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • Siri does not work when used for calling a contact function

    Siri does not work when used for calling a contact function

    Very strange, try to turn off/on your iPhone. Or make a reset (home+power button)...
    If it continues try to restore it.

  • Why is my touch screen function not working when using facetime

    Why is my touch screen function not working when using facetime

    Hello megascones,
    After reviewing your post, it sounds like the screen is not responding to touch in one app. I would recommend that you read this article, it may be able to help the issue.
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Restart your device. If you can't restart, reset your device.
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Lenovo S8-50LC Wlan(WiFi) Does not work when use Sim Cart(3G)

    Hi
    Tablet Lenovo S8-50LC
    Wlan(WiFi) Does not work when use Sim Cart(3G).
    What is the solution for this problem?
    Build Number : TABS8-50LC_S000200_150121_ROW
    SoftWarw Version : TABS8-50LC_150121

    Right, but if you have the SIM in the tablet and you put the tablet in airplane mode, does wifi work then? If so, it may be a bad SIM. Do you have another SIM you can try?

  • How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    How do I set up a mail group on mac mail?  All the advise on line seems to refer to 'address book' and I only have 'contacts'.  The guidance does not work when using 'contacts' - can anyone help me?

    Create a group and send mail
    http://www.dummies.com/how-to/content/how-to-create-a-basic-contact-group-in-mac -os-x-li.html
    http://www.macworld.com/article/1165582/how_to_email_groups_with_mail.html
    Best.

  • Photoshop CC. Colour selection not working when using alt and brush.

    Hi, Photoshop CC. Windows 8.1 64 bit. Colour selection not working when using alt and brush. I have tried rebooting and other things like closing swatch panel etc.
    The alt key is otherwise OK.  It's not the recent upgrade from Win 8 to 8.1 (5 days ago) because the colour selection facility was working yesterday. Any ideas.

    I'd say things sound desperate enough to try resetting Preferences
    Reset Preferences
    Windows — Hold down Shift Ctrl Alt immediately after starting Photoshop
    Mac — Hold down Shift Cmd Opt immediately after starting Photoshop
    If that fails, we need to know your operating system?
    Do you have a full CC subscription, or by apps do you mean Photoshop, Bridge and Lightroom?
    Another other information that might pertain ?

  • HT204168 touch screen function not working when using facetime

    Why is my iPad touch screen function not working when using FaceTime?

    Hi megascones,
    I apologize, I'm a bit unclear on the exact nature or scope of the issue you are describing. If you are having issues with the touch screen on your iPad, you may find the troubleshooting steps outlined in the following article helpful:
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Regards,
    - Brenden

  • I have an iMac with OS Lion. The Smartart feature for Office for Mac will not work when I am logged on to my personal user account. It works with other user accounts on the same computer, and it works after "safe start". How can I fix the problem?

    The Smartart feature of Office for Mac will not work in my user account. It works for all other user accounts on the same computer, and it works after a "safe start". How can I fix the problem?

    You may also want to search/ask in the forums run by the people who make the product which is causing you problems:
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011

  • Why does diadem intellisense not work when using scriptinclude or for global object

    I have a script with a different classes in it (scripted 1).  When I create an object of a class in the script 1 intellisense works.  Intellisense is when you type name of the object created from a class it shows all the possible variables and functions contained in that object.  But when I write another script and use scriptinclude(scripted 1) the intellisense does not work.  I also tried a global object and intesllisense does not work.  Is there a way to get intellisense to work when using scriptinclude?  I am working with version 2012. 

    Here is more information on the issue.
    I have a script with a different classes in it (scripted 1).  When I create an object of a class in the script 1 intellisense works.  Intellisense is when you type name of the object created from a class it shows all the possible variables and functions contained in that object.  But when I write another script and use scriptinclude(scripted 1) the intellisense does not work.  I also tried a global object and intesllisense does not work.  Is there a way to get intellisense to work when using scriptinclude?  I am working with version 2012. 
    'Test.vbs
    class test
        public function test1()
             msgbox("test1")
        end function
        public function test2()
             msgbox("test2")
        end function
    end class
    'now create a object of the class
    dim oTest
    set oTest=new Test
    'now when you type oTest. you get the following functions to choose from
    oTest.test1
            .test2
    Now if you remove the object from Test.vbs and create a main program with scriptinclude(Test.vbs) it will not show the two functions
    'Main.vbs
    Option Explicit  'Forces the explicit declaration of all the variables in a script.
    call scriptinclude("c:\1atmp\Test.vbs")
    dim oTest
    set oTest=new test
    'now when you type oTest. it shows none of the functions in the object oTest
    oTest.

  • Microphone not working when using a phone call, Microphone not working when using a phone call

    Microphone is not working when i use my iphone 4, first day when i installed a iOS 7 , was all good, second day this happened. Please help me. When i use a Viber microphone working. I think this is not a hardwear problem.

    Hi Mike
    That was very helpful thank you.
    I did as you suggested and found the "switch" was already turned on green. I swiched it off waited a while then turned it back on and microphone was back in use in viber. I have a sneaky feeling I may have to do this again in the future.  I am not aware that I did anything that led to the microphone going off, but having said that I have only had the phone for a few days so may have done something when checking it out.
    The phone has been a lot of fun after replacing my ancient Nokia with it. That Nokia worked in Morse code!
    Best wishes
    Rob

  • Keyboard backlighting not working when using Windows in Boot Camp

    Hi, I'm posting this for a friend with a new Macbook Air. He says that his keyboard backlighting does not work when he is using it for Windows (don't know which, but probably Vista). Any ideas why? Thanks. Gary

    Install all the drivers needed when running boot camp - try for example inserting a DVD - then press the eject key - See if it comes out - If it doesn't install all the drivers - try Control Panel - If not try re-installing your version of Windows.

  • Enter Key Not Working When Using Text Tool

    For some reason, my enter key has stopped working when using the text tool.  Instead of making a soft return to a new line, it simply commits the type. What is going on here?
    I'm using a desktop and CS3.

    there are 2 enter keys in key board
    if u enter main key board enter, sentence will go to next line
    In case u enter the key  available in  rightside of the key board , in the cluster of numericals, the type tool is committed.

  • Elements 11 - Brush tool not working when using layer mask

    My brush tool won't work when using layer mask in PS Elements 11. I also have Elements version 10 installed and there it works fine. If I do the exact same proces in version 11 nothing happens.
    Is this a bug or has something changed in the proces?
    Please help.
    Thanks.

      Make sure you have the mask thumbnail selected - it will be highlighted in blue.

  • Abap code Logic for splitting is not working

    Hi,
    I have a requirement to split a single amount and product into several parts. so far my logic is not working as only the first row is being fetched.
    TYPES: BEGIN of map_tab,
             ZPRODH4 TYPE NEWMAPPINGTABLE-/BIC/ZNEW_MP,
             ZSPRATIO TYPE NEWMAPPINGTABLE-/BIC/ZSP_RATIO,
             ZMATERIAL TYPE NEWMAPPINGTABLE-MATERIAL,
           END OF map_tab.
    Data:IT_MAP_TAB TYPE HASHED table of MAP_TAB with unique Key ZPRODH4,
         wa_it_map_tab like line of IT_MAP_TAB.
    Data rp TYPE _ty_s_TG_1.
    LOOP AT RESULT_PACKAGE into rp.
    Clear wa_it_map_tab.
    read table IT_MAP_TAB into wa_it_map_tab with table key ZPRODH4 =
    rp-prodh4.
    IF sy-subrc EQ 0.
    select SINGLE /BIC/ZNEW_MP /BIC/ZSP_RATIO MATERIAL into corresponding
    fields of wa_it_map_tab from NEWMAPPINGTABLE
    where  PRODH4 = rp-PRODH4.
    IF sy-subrc EQ 0.
      rp-PRODH4 = wa_it_map_tab-ZPRODH4.
      rp-AMOUNT = rp-AMOUNT * wa_it_map_tab-Zspratio.
      rp-MATERIAL = wa_it_map_tab-ZMATERIAL.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    <br><br>
    This is how my tables looks like
    Source Table
    PROD                                       AMOUNT
    900006600999                          1000
    400004400000                           500
    NEW MAPPING TABLE
    PROD                                      NEWPROD                      MATERIAL                             SPLITRATIO
    900006600999                         1000066001111                    7000                                         0.5
    900006600999                         1000066002222                    7001                                         0.4
    900006600999                         1000066003333                    7002                                         0.1
    OLD MAPPING TABLE
    PROD                              MATERIAL
    4000044000000               7100
    TARGET TABLE
    PROD                        PROD3               MATERIAL        AMOUNT
    1000066001111         100006600            7000                 500            
    1000066002222         100006600            7001                 400          
    1000066003333         100006600            7002                 100
    4000044000000         400004400            7100                 500

    Hi,
    I rewrote the code the like this and it is still not working as the new value is not being fetched.
    {* TABLES: ...
    Defining tables
    Tables: /BIC/OLDTABLE,/BIC/NEWTABLE.
    $$ 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/CS8ZSEM_TC03.
    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.
    New Material table
    DATA: BEGIN OF I_S_NEWTAB,
    PRODH4 TYPE /BIC/NEWTABLE-PRODH4,
    /BIC/ZNEW_MP TYPE /BIC/NEWTABLE-/BIC/ZNEW_MP,
    /BIC/ZSP_RATIO TYPE /BIC/NEWTABLE-/BIC/ZSP_RATIO,
    MATERIAL TYPE /BIC/NEWTABLE-MATERIAL,
    END OF I_S_NEWTAB.
    Data: i_t_newtab LIKE TABLE OF I_S_NEWTAB.
    *Old Material table
    DATA: BEGIN OF I_S_OLDTAB,
    PRODH4 TYPE /BIC/OLDTABLE-PRODH4,
    MATERIAL TYPE /BIC/OLDTABLE-MATERIAL,
    END OF I_S_OLDTAB.
    DATA: i_t_oldtab like table of I_S_oldTAB.
    data: e_s_result type STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH
    HEADER LINE
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    data: e_t_result type STANDARD TABLE OF DATA_PACKAGE_STRUCTURE WITH
    HEADER LINE
    WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
    data: amount type DATA_PACKAGE_STRUCTURE-/BIC/AMOUNT.
    data: CUSTSOLD type DATA_PACKAGE_STRUCTURE-/BIC/CUSTSOLD.
    selecting data from new table
    Select PRODH4 /BIC/ZNEW_MP /BIC/ZSP_RATIO MATERIAL FROM /BIC/NEWTABLE
    into corresponding fields of table i_t_newtab.
    SORT i_t_newtab by PRODH4.
    Selecting data from old material table
    Select PRODH4 MATERIAL FROM /BIC/OLDTABLE into corresponding fields
    of table i_t_oldtab.
    SORT i_t_oldtab by PRODH4.
    LOOP AT DATA_PACKAGE INTO e_s_result.
    read table i_t_oldtab into i_s_oldtab with key PRODH4 =
    e_s_result-PRODH4.
    if sy-subrc EQ 0.
    MOVE i_s_oldtab-PRODH4 to e_s_result-PRODH4.
    MOVE i_s_oldtab-PRODH4(14) to e_s_result-PRODH3.
    MOVE i_s_oldtab-MATERIAL to e_s_result-MATERIAL.
    APPEND e_s_result to e_t_result.
    ELSE.
    LOOP AT i_t_newtab into i_s_newtab where PRODH4 = e_s_result-PRODH4.
    amount = i_s_newtab-/BIC/ZSP_RATIO * e_s_result-/BIC/AMOUNT.
    CONCATENATE DATA_PACKAGE-SOLD_TO i_s_newtab-PRODH4(10) into AMOUNT.
    MOVE i_s_newtab-/BIC/ZNEW_MP to e_s_result-PRODH4.
    MOVE i_s_newtab-MATERIAL to e_s_result-MATERIAL.
    MOVE i_s_newtab-/BIC/ZNEW_MP(14) to e_s_result-PRODH3.
    MOVE amount to e_s_result-/BIC/AMOUNT.
    MOVE ZASTUOTE to e_s_result-/BIC/CUSTSOLD.
    APPEND e_s_result to e_t_result.
    ENDLOOP.
    ENDIF.
    ENDLOOP.
    REFRESH DATA_PACKAGE.
    MOVE e_t_result to DATA_PACKAGE[].}

Maybe you are looking for