Abap code not working  - deleting based on master data table information

Hi,
I wrote a piece of code earlier which is working and during test we found out that it will be hard for the support guys to maintain because it was hard coded and there is possibility that users will include more code nums in the future
sample code
DELETE it_source WHERE /M/SOURCE EQ 'USA' AND
/M/CODENUM NE '0999' AND
/MCODENUM NE '0888' AND.
Now I created a new InfoObject master data so that the support people can maintain the source and code number manually.
master data table - the codenum is the key.
XCODENUM    XSOURCE
0999               IND01
0888               IND01
now I wrote this routine all the data gets deleted.
tables /M/PGICTABLE.
Data tab like /M/PGICTABLE occurs 0 with header line.
Select * from /M/PGICTABLE into table tab where objvers = 'A'.
if sy-subrc = 0.
LOOP at tab.
DELETE it_source WHERE /M/SOURCE EQ tab-XSOURCE AND /M/CODENUM NE tab-XCODENUM.
ENDLOOP.
Endif.
But when I chage the sign to EQ, I get opposite values , Not what I require.
DELETE it_source WHERE /M/SOURCE EQ tab-XSOURCE AND /M/CODENUM EQ tab-XCODENUM.
Cube table that I want to extract from
/M/SOURCE                             /M/CODENUM
IND01                                       0999
IND01                                       0888
IND01                                       0555
IND01                                       0444
FRF01                                      0111
I want to only the rows where the /M/CODENUM = 0999 and 0888 and i would also need FRF101
and the rows in bold  should be deleted.
thanks
Edited by: Bhat Vaidya on Jun 17, 2010 12:38 PM

It's obvious why it deletes all the records. Debug & get your answer i wont spoon feed
Anyways on to achieve your requirement try this code:
DATA:
      r_srce TYPE RANGE OF char5, "Range Table for Source
      s_srce LIKE LINE OF r_srce,
      r_code TYPE RANGE OF numc04,"Range table for Code
      s_code LIKE LINE OF r_code.
s_srce-sign = s_code-sign = 'I'.
s_srce-option = s_code-option = 'EQ'.
* Populate the range tables using /M/PGICTABLE
LOOP AT itab INTO wa.
  s_code-low = wa1-code.
  s_srce-low = wa1-srce.
  APPEND: s_code TO r_code,
          s_srce TO r_srce.
ENDLOOP.
DELETE ADJACENT DUPLICATES FROM:
r_code COMPARING ALL FIELDS,
r_srce COMPARING ALL FIELDS.
* Delete from Cube
DELETE it_source WHERE srce IN r_srce AND code IN r_code.

Similar Messages

  • Abap logic not fetching multiple rows from master data table

    Hi
    I just noticed that my logic is fetching only 1 row from master data table.
    ProdHier table
    PRODHIERACHY            Level
    1000                                  1
    1000011000                      2
    10000110003333              3
    10000110004444              3
    '10000110005555              3*
    logic only fetches one row of level 3, I would like to fetch all level 3 rows.
    DATA: ITAB type table of /BI0/PPROD_HIER,
          wa like line of ITAB.
    Select * from /BI0/PPROD_HIER INTO wa where /BIC/ZPRODHTAS = 3.
    IF wa-PROD_HIER(10) = SOURCE_FIELDS-PRODH2.
         RESULT = wa-PROD_HIER.
         ELSEIF wa-PROD_HIER(5) = SOURCE_FIELDS-PRODH1.
         RESULT = wa-PROD_HIER.
    ENDIF.
    ENDSELECT.
    thanks

    Hi,,
    I have implemented the logic in end routine and it still reads only the first row.
    I am loading only PRODH1 and PROD2 but now I want to get all values of PRODH3 from the master data table.
    The first 5 values are PRODH1 and first 10 values belongs to PRODH2.
    Whenever PRODH2 = 1000011000 in source I should get the following values
    10000110001110
    10000110001120
    10000110001130
    I have multiple rows of 1000011000 so my result should be
      1000011000               10000110001110
      1000011000               10000110001120
      1000011000               10000110001130
    DATA: ITAB type table of /BI0/PPROD_HIER,
    wa like line of ITAB.
    data rp type _ty_s_TG_1.
    Select  * from /BI0/PPROD_HIER INTO table itab where /BIC/ZPRODHTAS = 3.
    LOOP AT RESULT_PACKAGE INTO rp.
    read table itab into wa with key PROD_HIER(5) = rp-PRODH1.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
         ELSE.
    read table itab into wa with key PROD_HIER(10) = rp-PRODH2.
    IF sy-subrc EQ 0.
         rp-PRODH3 = wa-PROD_HIER.
    ENDIF.
    ENDIF.
    MODIFY RESULT_PACKAGE FROM rp.
    ENDLOOP.
    Edited by: Bhat Vaidya on Sep 10, 2010 11:27 AM
    Edited by: Bhat Vaidya on Sep 10, 2010 11:37 AM

  • HR_INFOTYPE_OPERATION not working when editing HR master data

    Hi all,
    I search for similar problem but couldn't find any.
    I am using HR_INFOTYPE_OPERATION to insert record to an infotype. I proceed with standard way (ENQUEUE employee, call above fm, DEQUEUE employee). It works fine when running as executable program.
    Now I want this functionality when editing EE's master data (i.e. modifiying one infotype record). For this I put the same code to some user exit. Now when executed I can proceed with creating new entry, it saves I can see how data are updated in pa30 for this EE. But when I reenter his master data are without this new record anymore.
    Does anyone faced similar issue? I guess it is not allowed to use that fm when editing master data, but can't find a answer if this is the issue.
    I did also a test creating this new entry for some different EE, but it neither worked.
    Any info appreciated.
    Thank you
    Marcin

    Hi Marcin,
    Please check whether the following links are useful,
    HR_INFOTYPE_OPERATION mod not working
    HR_INFOTYPE_OPERATION is not working in user exit ZXPADU02
    Best Regards.

  • Co code not seen for cost center master data creation in OKEON

    hI:
               In org tab of Cost center master data creation while configuring cost center hierarchy in OKEON i can not see organization tab. I have checked in OKKP Co area is assigned to co code but still the issue persist.
    Br

    hi
    you mean the tab is not displayed? strange, it seems that there should be a screen layout to control the ui, or any transaction variant is recorded. I tried in my side, the tab is there.
    @ Murali, you are right, but in that tab, not only company code can be configured, but also business area, functional area etc.
    best regards, Lawrence

  • Smart Mailbox not working correctly based on received date

    I setup a smart mailbox with the condition:
    Date Received is not in the last 1 year
    I get plenty of messages where the date received was within the last year. Anyone know how to fix this problem.
    Thanks in advance,
    Roy

    David needs to get extra points for slipping in the Princess Bride reference.
    As he points out, this smart mailbox rule should exclude all messages not from THIS calendar year--2007. If you want all messages older than one year, do date received is not in the last 12 months, and it should give you what you want.
    G4 933 mhz Quicksilver   Mac OS X (10.4.9)   Wacom Intuos 2 tablet; Epson 2400 Photo; HP Deskjet 6840; LaCie 80gb D2 FWDV

  • Field not being updated in Master Data table

    Hi guys,
    I'm pulling data from master data in BW... specifically 0ven_compc. I haven't added any new fields to this maser data table, and one field that I'm trying to pull is not being populated. In the master data table this field is blank, but in the PSA there are values. Somehow the values are not being loaded into the master data table. I've checked the transfer rules and communication structure and everything looks fine. Why is this happening?
    Thanks,
    Anthony

    Hi Anthony,
    The problem may be that there is an inconsistency with the target master data infoobject. Please make a dummy change to the target infoobject (i.e you can change the description), save this change and then click on the activate icon. Please then check if the field is filled with the next load.
    If the problem still exists please let us know your BI version and support package level.
    Best Regards,
    Des.

  • Queries based on Master data for the particular periods not working

    Hi,
    My Queries are based on master data and for 2007 we did not have customer groups define hence for the historical also we would like to display the customer groups hence we are reproting based on master data. But when iam executing my reprots for each and every month for the 2007 , i can able to execute the reprot properly but same when iam giving the values in ranges with the help of input filed ( calender month -interval) its taking hours but unable to retrieve the data for the 6 months at a time even if iam restricting the values in the queries still the problem is same...
    Can anyone has an idea what would be the problem .. its only for 6 months
    Thanks

    Hi
    Master data report consumes much time. try to see the Query Statistics  and make the performance tuning.
    Recheck your data flow for routines at TRules/upRules level.
    Recheck on the Query designer for formula/ Cmod Variables.
    The report fetching time even depends on the NO.of records too.
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d06dcd70-41a8-2b10-9f8f-dc5c68769753
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6009e125-e9a3-2a10-c6a9-e1483dfa2e1b
    Hope ithelps

  • Do we have a ABAP code / program to delete all objects viz. InfoObjects etc

    I am working on a SAP BI7.0 implementation project and seek help on the following points -
    Do we have a ABAP code / program to delete all objects viz. InfoObjects, InfoProviders, Datasources, Infopackages, DTP, Transformations etc. in ONE shot
    Secondly, does anyone have a template created for capturing information on Transports created for release?
    Please do let me know.
    Thanks in advance,
    Venkat

    It may be hard to delete objects containing data.
    Try
    RSDG_CUBE_DELETE               Deleting InfoCubes
    RSDG_IOBC_DELETE               Deleting InfoCubes
    RSDG_IOBJ_DELETE               Deleting InfoObjects (without automatic transport connection !)
    RSDG_MPRO_DELETE               Deleting InfoCubes
    Also check :
    How to delete multiple InfoObjects in one shot?

  • I have 10.7.3 lion on my computers an iMac and a macbook pro plus a new iPod touch, and two older touches, now trying to sync my calendars is not working deletes some events, duplicates others, I want all my calendars to be the same.  Any ideas

    I have 10.7.3 lion on my computers an iMac and a macbook pro plus a new iPod touch, and two older touches, now trying to sync my calendars is not working deletes some events, duplicates others, I want all my calendars to be the same.  Any ideas

    Have you tried resetting the SMC ?     >  Resetting the System Management Controller (SMC)

  • Not able to create customer master data with country code US

    Hey All,
    I am not able to create customer master data in the Transaction Code XD01/FD01 with the country code as US.
    The error message for the same is NO JURISDICTION CODE COULD BE DETERMINED. I have checked the tax code settings but could not locate the problem.
    Request you to provide me with a solution.
    Thanks & Regards
    VK

    Hey all,
    I have checked the field in the account group(OBD2) but its in optional status
    and also checked the country settings for US in the transaction code OY17 still the same error message, but when i tried checking the settings for a differnt company code's customer data base i can see that there is a number mentioned in the address tab under tax jurisdiction feild (beside time zone) which is not populating for this company code.
    so, do anyone know where exaclty we mention this number so that it populates in that field of address.
    hope am clear
    hope to receive  a solution
    thanks & regards
    vinila

  • Period overlaps code not working in apex page

    Hi there,
    Employees have a schedule with a begin and end date. Schedule periodes may not overlap each other for the same employee.
    I have a function returning error text validation as follow:
    declare
    l_dummy number;
    begin
    select  count(*)
    into    l_dummy
    from    fus_medewerker_roosters
    where   mdr_code = :p61_mdr_code
    and     id <> :p61_id
    and     to_date(:p61_begin_periode,'DD-MON-YY') <= eind_periode
    and     to_date(:p61_eind_periode,'DD-MOn-YY')>= begin_periode
    +;+
    if l_dummy > 0
    then
    return 'This employee already has a schedule in this periode.';
    else
    return null;
    end if;
    end;
    But the code is not working. It does save data for an employee even if the periodes overlaps.
    But the code works fine in workshop:
    declare
    l_dummy number;
    begin
    select  count(*)
    into    l_dummy
    from    fus_medewerker_roosters
    where   mdr_code = :p61_mdr_code
    and     id <> :p61_id
    and     to_date(:p61_begin_periode,'DD-MON-YY') <= eind_periode
    and     to_date(:p61_eind_periode,'DD-MOn-YY')>= begin_periode
    +;+
    if l_dummy > 0
    then
    DBMS_OUTPUT.PUT_LINE ('This employee already has a schedule in this periode.');end if;
    end;
    What is going wrong. Why is it working fine in workshop but not in my page?
    Regards,
    Diana
    Edited by: dianap on Sep 4, 2009 8:31 AM

    Hi Andy,
    I left out the id is not :p11_id
    and the code is working fine now.
    I have another problem now.
    The user can make a choice between a department or an employee.
    The validation works fine when a schedule is given to a employee (choossing a department from the department list and a employee from the employee list)
    But if the user wants to give a schedule to a department(one or more employee depending on the employees of that department) then he chooses the department from the department select list, leaving the employee select list empty. When i want to save these changes, i get a invalid number error. I tried making the validation conditional for when the employee item is null.
    But still i get invalid number.
    Any suggestions how i could solve this problem?
    Thanks,
    Diana

  • Master data tables not available after installing trail version sap abap

    Hi Experts,
    After installing trail version of sap for practicing SAP ABAP..i am not able to access master data tables like MARA EKKO etc.
    Please let me know how i can access these tables data .
    Is there any alternate to access these tables?
    Thanks and Regards,
    Siva

    Hi Siva,
    Master data table and any other application table are not present in trail systems. Notice that solely purpose of those trials is to learn/practice basis stuff and ABAP programming.
    If you need to practice ECC's modules like FI, SD, ... you need to have an access to IDES system. For this you need to be SAP partner or customer.
    cheers
    m./

  • PS4 Game Voucher Code not working

    my PS4 Game Voucher Code not working and says: "The code you entered may not be correct or may no longer be valid" "Please check your entry (e-820000134)  

    Voucher codes are region-specific. For instance a US voucher won't work with a UK account. First thing to check is whether the voucher's region matches your account's region.

  • Vine.co can not watch videos on other browsers do not have the problem with firefox firefox there just did not work, delete cookies, history

    vine.co can not watch videos on other browsers do not have the problem with firefox firefox there just did not work, delete cookies, history

    I think this problem may be caused by Yahoo's changes making it incompatible with the klatest version of FireFox.
    This is suddenly affecting many many people who use Firefox and are members of Yahoo Groups. All these people say they themselves changed nothing and have not been locked out before when using Firefox. But suddenly, within the last week, they are.
    What did Mozilla do or what did Yahoo do to cause this problem? I can say that I was not blocking cookies and after trying a number of things to fix it, I went to Yahoo's home page and navigated to my group from here.
    This problem is not anything a user did. Either Firefox is at fault or Yahoo is. I want to know which company is at fault and when they are going to fix it.

  • Archiving and deleting of equipment master data in plant maintenance module

    Hi,
    Can anyone explain me the process to archive and delete the equipment master data in PM module using archiving tools.
    I tried doing it thru t-code SARA, would be grateful if anyone can help me with the steps to follow to archive the equipment master data.
    Thanks in advance,

    Many thanks for your reply,
    I tried doing the same in IDES, but unfortunately the archive file is not getting generated when i write it. I have clearly specified in the variant to create an archive file. Can you please explain how does the system generate an archive file. And also in the customizing " Archiving Object-Specific Customizing " techincal settings, i have maintained the production variant and have marked start automatically.
    Please advise,
    thanks again ,

Maybe you are looking for