Problem in modifying existing records in dbtab

Hi Experts,
I am doing a report where I have created two dbtab's , one for data getting saved and
other for fetching data and modifying exsiting records..
For eg - let ZABC be the table where I need to insert or update records and ZXYZ is the table where
I need to fetch and modify existing records.
Now my probelm is :
In case of inserting new records (multiple records ) into my dbtab ( ZABC ) its working ,
but modifying existing records in another dbtab (ZXYZ ) its not wroking !! plz advice !!
If my select querry for modifying exsiting records is:
SELECT *  FROM ZXYZ  INTO TABLE ITAB WHERE MATNR EQ S_MATNR.
*****then its inserting a newline along with the existing records.
but when my querry is,
SELECT single *  FROM ZXYZ  WHERE MATNR EQ S_MATNR.
then its modifying the existing records, but only the first record.
Loop at itab.
if sy-tabix  = 1.
zabc-matnr = matnr.
zabc-idnrk  = idnrk.
zabc-budat = s_budat.
zabc-menge = menge1.
ZXYZ-menge = ZABC-Menge + MENGE1.
ZXYZ-BALC  = ZXYZ-Menge   -   MENGE1.
ELSEIF sy-tabix  = 2.
zabc-matnr = matnr.
zabc-idnrk  = idnrk.
zabc-budat = s_budat.
zabc-menge = menge2.
ZXYZ-menge = ZABC-Menge + MENGE2.
ZXYZ-BALC  = ZXYZ-Menge  -  MENGE2.
ELSEIF sy-tabix  = 3.
zabc-matnr = matnr.
zabc-idnrk  = idnrk.
zabc-budat = s_budat.
zabc-menge = menge3.
ZXYZ-menge = ZABC-Menge + MENGE3.
ZXYZ-BALC  = ZXYZ-Menge   -  MENGE3.
ENDIF.
INSERT ZABC.
IF SY-SUBRC EQ 0.
MODIFY ZXYZ.
        IF SY-SUBRC = 0.
          MESSAGE : I002 WITH 'RECORD CREATED'.
            ENDIF.
ENDIF.
Please advice
Karthik
Edited by: Karthik R on Aug 24, 2009 9:42 PM

Hi,
This is because in the second case you are not selecting records into an internal table.
As a result only the first record which satisfies the where condition is fetched.
Check if the program goes into the loop when you write second select query.
KR Jaideep,

Similar Messages

  • Problem in Modifying the records

    Hi all,
    I have a button "Find", when the button is Pressed, I've to query the records and modify the records. I have to modify only the "Reading" Column in only one row.
    It is querying all the records successfully (here retrieves 10 records) but when I modify the Reading value in one Row, all the 10 records are inserting as new row. Am not able to update.
    Please suggest me with the solution.
    Regards,
    Mini

    Hi Mini
    Sounds Strange and i think the problem resides in ur design of code in Find Button So i suggest to Share us the Code pls.
    Well ,for now u can try to use ...
    IF :system.current_record THEN
    END IF;Hope this helps...
    Regards,
    Abdetu...

  • Problem in modifying control record

    Hi All,
    My scenario is Purchase order to Sales order. Once PO is created IDOC will be created and that idoc will be taken as source and i will be modifying the idoc in abap mapping as per requirement.
    All the segements are being modified and getting updated in IDOC but when i am trying to change the control record its not getting reflected in the r/3 but when i check in moni before comming to r/3 the xml struture has changed as per my requirement even for control record also but while comming from XI control record is not getting changed.
    I would like to change senderpartner and sender partner type in control records.
    every configurattion steps has been done  correctly.
    Would request your experiences if you would have faced any this type of situation in your projects.
    Thanks in Advance.

    Apply Control Record Values from Payload
    If you set the indicator, the conversion of communication parties to the IDoc partner is only possible for systems that are not logical systems.
    If you do not set the indicator, all combinations of communication parties and services are handled as services without party.
    If the IDoc XML structure contains a control record during outbound processing on the Integration Server, it is rejected and created again by the IDoc adapter. If you want to include additional values in the control record, set the indicator and provide an appropriate mapping for the values.
    http://help.sap.com/saphelp_nw04s/helpdata/en/96/791c42375d5033e10000000a155106/frameset.htm

  • ISync Error Message "you can't modify a record that doesn't exist...."

    "[ISyncConcreteSession pushChange:]: you can't modify a record that doesn't exist: <ISyncChange 0x3215870>{ modify record id 'BE86E203-EC1F-4F3E-A2F2-180EC5FA5210'
    set com.apple.ical.type = local
    set title = Unfiled }"
    I have 2 macs connected to the .mac sync and until recently the flow of info between them (mostly iCal) has been smooth. Now it appears to not be working.
    thoughts? thanks.
    --Kevin

    wrong forum, sorry.

  • Modify existing rebate condition and exclusion

    Hi
    We are rebate agreements for customers. Currently I want to modify rebate condition in one of rebate agreement.
    Scenario: let us June 10th 2010 onwards, the rebate % is 3% for Profit center 'xxxx' & customer 'yyyy' instead of 1%. And 3% needs to accrued on billing docs going forward. How to set up this.
    I tried to modify existing rebate condition using VBo2 as follows: went into rebate agreement using VBo2, changed rebate % for condition record with effective from 06/11/2010 and Saved.  problem when I ran VBOF program, system posted reversal accrual for old rebate condition 1%. Old condition record validity from 01/01/2009 Valid to 12/31/2011.
    I have one more question. We want to set up rebate condition for all materials exclude some of them. we have thousands of materials for which we need to calculate rebates. but we want to exclude some materials in the rebate agreement. How to set up such exclus
    any ideas really appreciated
    thnx

    The key of your condition table (the one supporting your condition record in the agreement) is evidently Profit Center / Customer.  So for any combination of profit center and customer, you can maintain a rate and validity period. 
    You are attempting to maintain two separate records having the same key.  As you have experienced, the system does not allow it.
    The simple solution is to expire that rebate agreement and start a new one with the updated validity period and conditions.
    As for excluding certain materials, you need a more detailed key in your condition table.  Something else from the material master seems appropriateu2014Commission Group for example.  Maintain commissionable materials in group 01 and non-commissionable ones in group 02.  Then a key combination of Commission Group / Profit Center / Customer  would work well for you.
    Regards,
    Ken

  • End Routine - Modify a record in the cube

    Hello Guys,
    In the end routine I have to update a field . The transformation is the same cube to the cube. I want the record to be modified like add a value to a field in the end routine. Since it is a cube it creates a new record instead of overwriting the existing record. Is there anyway I can modify the record. I know I can make the existing record 0.00 and then create a new record with the new value.Is there any other solution.
    For example:This is the existing record in the cube
    sales order           Item No                      Backlog Amount                      Indicator
    1000                     10                              1000.00
    After applying the end routine it has 2 records ( I modify the record with the indicator value)
    sales order           Item No                      Backlog Amount                      Indicator
    1000                     10                              1000.00                                  
    1000                     10                              1000.00                                    REV
    After applying the end routine I need the record to be like overwrite(similar to DSO)
    sales order           Item No                      Backlog Amount                      Indicator
    1000                     10                              1000.00                                   REV
    How to achieve the above result in end routine.
    Thanks
    Senthil

    Hi there,
    Since you create new records in end routine in the InfoCube, why not delete the old ones?
    You can use the
    delete RESULT_PACKAGE where ...
    Therefore deleting the old records after inserting the new ones.
    Diogo.

  • How to write the new records not with existing records.

    hi,
    I have a script.If i execute the script it writes the records.but its writing with the exisiting records.It writes not only the new records but also the old records.
    for eg: the exisiting records are:
    1111115-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111116-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111117-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111118-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111119-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    but now what happend is the new records such as
    1111116-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111117-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111118-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111119-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    it gets appended with the old existing records,
    1111117-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111118-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111119-2,USD,DINESH,1,1,,,,9,,,,123456184001,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111113-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111114-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111115-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111116-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111117-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111118-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    1111119-2,USD,DINESHBABU,1,1,,,,9,,,,123456184003,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,9999,,,,
    there will be some problem happens when we are going to upload a bulk data of say 25000 records.if its gonna update 20000 records,rest 5000 records i have to do it in next step,if this is going to happen then the first 20000 records will be displayed forever.because it have the capacity to write 20000 records.thenext 500 records will not be written.so there is a chance of redundancy.how to avoid this redundancy while running this script
    my script is
    create or replace procedure input_tables(table1 in varchar2)
    is
    str varchar2(32767);
    cnt number(2);
    cursor c1(tname in varchar2)
    is
    select column_name
    from all_tab_columns
    where table_name = tname
    order by column_id;
    rec c1%rowtype;
    begin
    cnt:= 1;
    str:= 'declare '||
    'cursor c2 '||
    'is '||
    'select ';
    open c1(table1);
    loop
    fetch c1 into rec;
    exit when c1%notfound;
    if cnt = 1 then -- Added New
    str:= str||rec.column_name; -- Added New
    cnt:= cnt + 1; -- Added New
    else -- Added New
    str:= str||'||'',''||'||rec.column_name; -- Added New
    end if; -- Added New
    end loop;
    close c1;
    str:= str||' SRC from '||table1||';'||
    ' r2 c2%rowtype;'||
    ' ft UTL_FILE.file_type;'||
    ' str2 varchar2(200);'|| --Added New
    ' begin '||
    ' ft := UTL_FILE.fopen(''SAMPLE'',''OUTPUT.csv'',''w'');'||
    ' for r2 in c2'||
    ' loop '||
    ' UTL_FILE.put_line(ft,r2.SRC);'||
    ' end loop;'||
    ' UTL_FILE.fclose(ft);'||
    ' end;';
    execute immediate(str);
    end;
    thanks,
    Ratheesh.

    Hi!
    U can check the following script --
    create or replace procedure input_tables(table1 in varchar2,start_col in number,last_col in number)
    is
         str varchar2(32767);
         cnt number(2);
         cursor c1(tname in varchar2)
         is
           select column_name
           from all_tab_columns
           where table_name = tname
           order by column_id;
         rec c1%rowtype;
    begin
         cnt:= 1;
         str:= 'declare '||
         'cursor c2 '||
         'is '||
         'select ';
         open c1(table1);
         loop
              fetch c1 into rec;
              exit when c1%notfound;
                   if cnt = 1 then -- Added New
                        str:= str||rec.column_name; -- Added New
                        cnt:= cnt + 1; -- Added New
                   else -- Added New
                        str:= str||'||'',''||'||rec.column_name; -- Added New
                   end if; -- Added New
         end loop;
         close c1;
         str:= str||' SRC from '||table1||
         ' where rownum between '||start_col||' and '||last_col||';'|| -- Added New
         ' r2 c2%rowtype;'||
         ' ft UTL_FILE.file_type;'||
         ' str2 varchar2(200);'|| --Added New
         ' begin '||
         ' ft := UTL_FILE.fopen(''SAMPLE'',''OUTPUT.csv'',''w'');'||
         ' for r2 in c2'||
         ' loop '||
         ' UTL_FILE.put_line(ft,r2.SRC);'||
         ' end loop;'||
         ' UTL_FILE.fclose(ft);'||
         ' end;';
         execute immediate(str);
    end;
    / To print first ten rows --
    exec input_tables('EMP',1,10);  --first 10 rowsTo print next remain rows --
    exec input_tables('EMP',11,15);N.B: No tested....
    Regrads.
    Satyaki De.

  • Modifying the record in the extractor.

    Hi gurus,
    i am a BW developer. i have one requirement, i have to enhance some fields from table MSEG to my generic extractor.
    In my extractor structure, Material, Plant and Order number is the key fields. i am selecting some fields from MSEG table into internal tables and doing some calculation on that fields and finally i have to enhance those records into my extractor.
    material, plant and ordernumber are the key fields. in my internal table i have 2 records and in my extractor i have only one record for particular combination of keys.
    example:
    in my internal table:
    material plant odernumber quantity week
    0980009 1800 2000125    500   200702
    0980009 1800 2000125    453   200704
    in my extractor:
    ( quantity and week are the enhanced fields)
    material plant ordernumber quantity week
    0980009 1800 2000125   
    in my code: while enhancing the fields to extractor, i have modifying the existing record.  so that i am getting only the second record in my extractor.
    like 0980009 1800 2000125 453 200704
    and i cannot append the record into my extractor, because for example for this combination of key if have 100 records in my extractor it is adding all the 100 records instead of one record.
    Can any one suggest me how can enhance these records into my extractor.
    Any help is greatly appriciatable. Thanks in advance.

    This question has been answered

  • How to create idocs  for  existing records

    Hi
    are there any standard program by which i could create and send the existing customer invoice (VF01) data thru EDI idoc to a 3rd party system even if the output type is not defined during the creation of the invoices?
    Regards
    Sujai

    I am supposed to send all customer invoice data to an external system. I have been able to configure the system to trigger an idoc when an invoice is saved. That takes care of my delta transfer. But i would like to know if there is a way by which i can send all the existing customer invoice data to the 3rd party system that were already created in the SAP system. Something like an initial download of all the existing records.
    I am asked to keep the abap development to Zero as far as possible, hence i am exploring the idea of finding any standard program that could do this for me.
    just like Tx: BD10 for the material master data.
    I tried VF31 but the problem is that the invoice that would have been created might not contain the output type as EDI. So is there a way by which i can achieve this task with any standard program?
    I also have another question:
    how do i do the configuration to send all the SD invoices to a specific partner all the time thru EDI by default?
    Sujai

  • Problems in Vendor master record.

    Hi Sdn Experts...Could you help me?
    I have problems with vendor master record. I have vendors in duplicity....to solved this I aplly the solution by sap for make the consistency by Tax number. Now I cant insert the vendor with the same Tax Number...But appear other problem..I have a lot of vendor in duplicty befora i aplly the solution and i need to eliminate this vendors...
    I execute the Transaction XK05 ( Block Vendor ) and XK06 (Mark Deletion Flag), but doesnt work...because if i make any modification in a vendor master correct the system show up the message..
    ''Vendor master record with the same tax number already exists''
    There is other way to make the deletion the vendor record? How I solve this issue?  Pleaaase help meee!
    Take a look in the File
    [http://www.easy-share.com/1903543315/vendor_problem.doc]
    Thanks,

    hi
    u have to archive the vendors inOBR2 or the simple way is go to XK99 here give the list of the vendors and then change the description with * in mass
    so description of all the duplicate vendors will be * and then flag them for deletion so they cant be used again
    agin u can use them agin by changing the name by some other vendor so u can use the same vendor code for other vendor by just changing the  description
    regards
    KI

  • Form won't query existing record

    I'm creating a User Preferences page based on a table that contains one record per user, with the primary key = user_id.
    The form creates the record fine. If I exit the form and get back in, however, it does not fetch that existing record.
    The form has:
    - An Application Item called GLOBAL_ID
    - An Application Computation called GLOBAL ID with:
    Computation Point=*On New Instance*
    Computation Type=SQL Query
    Computation=select f_get_id from dual
    - A page Process called Fetch row from SZBRPRF with:
    Process Point=*On Load Before Header*
    Run Process=Once per Page Visit, ...
    Item Containing Primary Key Column Value=*P1_USER_ID*
    Primary Key Column=*USER_ID*
    DML Fetch Mode=Set Memory Cache on Fetch
    Runtime Where=*USER_ID = :GLOBAL_ID*
    Success Message=*Fetched record for &GLOBAL_ID.*
    - The P1_USER_ID item has the following attributes set:
    Source Type=*Database Column*
    Source Value or Expression=*USER_ID*
    Default Value=*:GLOBAL_ID*
    Default Value Type=*PL/SQL Expression*
    When I open the page, the success message (Fetched record for +389+ is displayed, but the values are not.
    So it looks like GLOBAL_ID does contain the value I want it to contain, at the time the fetch is executed, but the record is not found?
    If I enter a value in one of the fields and click on Create, I get a unique constraint error.
    I have also confirmed, via SQL*Plus, that the record exists in the database.
    I keep thinking the problem is with the P1_USER_ID field, and have tried various combinations, but it still isn't working.
    Any suggestions would be greatly appreciated.

    Laura - Please change your handle to something easier to read and put your first name in your profile to assist us. Thanks.
    Computation=select f_get_id from dualIf f_get_id uses APP_USER to determine the record ID, you should move that item-setting code into the authentication scheme's post-authentication process instead of using an on-new instance computation.
    - A page Process called Fetch row from SZBRPRF with:
    Process Point=*On Load Before Header*After-Header is a good firing point for ARF processes
    Runtime Where=*USER_ID = :GLOBAL_ID*This seems redundant. I'd remove it.
    - The P1_USER_ID item has the following attributes set:
    Source Type=*Database Column*
    Source Value or Expression=*USER_ID*
    Default Value=*:GLOBAL_ID*
    Default Value Type=*PL/SQL Expression*The ARF process fires way before any form item attributes (like Default Value) are evaluated. Plus, if the PK item is null, the ARF process doesn't fetch anything (the process success message notwithstanding).
    I keep thinking the problem is with the P1_USER_ID field, and have tried various combinations, but it still isn't working.I think a before-header computation to set P1_USER_ID is your best bet (as Dimitri suggested). Make sure it fires before the ARF process.
    Scott

  • Can't not update existing record filter value in java sdk.

    Hi,
    If there is existing record filter, such as " {table.a_field} = {?paramA}"
    Then can't update it to other value. e.g " {table.a_field} = value_A"
    The flow is
    1. Update paramA value
    2. Update record filter value
    Java code
    public void setRecordFilter(ReportClientDocument clientDoc, String filter)
         try
           IFilter iFilter = clientDoc.getDataDefController().getDataDefinition().getRecordFilter();
           iFilter.setFreeEditingText(filter);
           clientDoc.getDataDefController().getRecordFilterController().modify(iFilter);
         catch (ReportSDKException e)
             throw new Error("Couldn't set RecordFilter " + e.getMessage());
    if exsiting filter is empty then "setRecordFilter" works.
    Do you know why? and any idea to update reocord filter if the existing one like "{table.a_field} = {?paramA}"
    Thanks
    Forest

    Hi,
    In uploading of flat file , If you are able to capture the changes to the previously loaded records, Then you can follow the additve delta. So it decreases the time of uploading .Only changed or new records will be uploaded every time.
    If you are not able capture the changes in flat file ,Every time you have to do full upload ,Before this delete the contents of Infocube. (Assuming there is no ODS B/W Infocube and Flat file).
    With rgds,
    Anil Kumar Sharma. P

  • Modify MDM Record

    HI,
    When i am trying to Modify an existing MDM Record in Products Table using 7.1 Java API, i am getting the following error.
    Can not update record with modification status NEW
    When i directly modify the record in MDM Data Manager, it works fine, but when i try updating the record using Java API, i am getting the above Error. Can anyone advice what's wrong in here, i am using the following code.
    ModifyRecordCommand modifyRecordsCommand = new ModifyRecordCommand(connecPool);
    modifyRecordsCommand.setSession( usrSessionIdAdm );
    modifyRecordsCommand.setRecord(emptyRecordProduct);
    modifyRecordsCommand.setModifyAnyway(true);
    //Create Record in MDM
    modifyRecordsCommand.execute();
    On "execute" command, i am getting the error.
    Your help is really appreciated.
    Thanks
    Vijay Budati

    Greg,
    Thanks for the reply.
    I am using the following code. "emptyRecordProduct" is not but creating an empty record first and then updated values to the fields and then telling to modify the record using "ModifyRecordCommand". As you mentioned, when i use RecordFactory.createEmptyRecord, it might mis-understood that i am trying to create a new record. If this is not the right way to use, could you advice which record i should use?
    Record emptyRecordProduct = RecordFactory.createEmptyRecord(tableId) ;
    emptyRecordProduct.setFieldValue(...., .....);
    //Pass all the required values
    ModifyRecordCommand modifyRecordsCommand = new ModifyRecordCommand(connecPool);
    modifyRecordsCommand.setSession( usrSessionIdAdm );
    modifyRecordsCommand.setRecord(emptyRecordProduct);
    modifyRecordsCommand.setModifyAnyway(true);
    //Create Record in MDM
    ModifyRecordsCommand.execute();
    Thanks for your help.
    Thanks
    Vijay Budati

  • Modify existing Message

    Hi all,
    I need to change text/html part of message which I have in mail format. How to do this easily without loosing other parts of message?
    Or maybe you know some better way to create kind of simple proxy for SMTP which would add and replace some text in HTML part of email?
    So far I am reading message from plain stream of mail text representation (got it from Subethamail SMTP server) into JavaMail Message object. I had problem, when my changes to message were not reflected - I posted question on http://stackoverflow.com/questions/7674775/how-to-modify-existing-java-mail-mimemessage-body-parts/ and solved this one by calling message.saveChanges();
    The issue is that when I call message.saveChanges() headers seams to be lost - especially those around Content Type and Charset.
    My code looks like this:
    public void resend(InputStream data) throws Exception {
            Transport transport = mailSession.getTransport();
            MimeMessage message = new MimeMessage(mailSession, data);
            Object content = message.getContent();
            if (MimeMultipart.class.isAssignableFrom(content.getClass())) {
                MimeMultipart mimeMultipart = (MimeMultipart) content;
                for (int i = 0; i < mimeMultipart.getCount(); i++) {
                    MimeBodyPart bodyPart = (MimeBodyPart) mimeMultipart.getBodyPart(i);
                    if (bodyPart.getContentType().startsWith("text/plain")) {
                        String cnt = updateContent((String) bodyPart.getContent());
                        System.out.println("ContentType = " + bodyPart.getContentType());
                        System.out.println("Content = " + cnt);
                        String contentType = bodyPart.getContentType();
                        System.out.println("Updating content type to = " + contentType);
                        bodyPart.setContent(cnt, contentType);
                    } else if (bodyPart.getContentType().startsWith("text/html")) {
                        String cnt = updateContent((String) bodyPart.getContent());
                        System.out.println("ContentType = " + bodyPart.getContentType());
                        System.out.println("Content = " + cnt);
                        String contentType = bodyPart.getContentType();
                        System.out.println("Updating content type to = " + contentType);
                        bodyPart.setContent(cnt, contentType);
            } else {
                String cnt = updateContent((String) message.getContent());
                System.out.println("ContentType = " + message.getContentType());
                System.out.println("Content = " + cnt);
                String contentType = message.getContentType();
                System.out.println("Updating content type to = " + contentType);
                message.setContent(cnt, contentType);
            message.saveChanges();
    }Mark on Stackoverflow suggested that problem is in bodyPart.setContent(cnt, contentType); call...
    Hope that makes sense for you... and you will be able to help me...
    Thanks in advance
    Konrad
    Edited by: 890134 on 2011-10-07 08:29

    JavaMail wasn't really design to support "editing" of existing messages.
    That's caused some problems over the years and I've had to fix a number
    of bugs in this area. The current version (1.4.4) definitely works better
    than older versions, but I won't be surprised if there are still bugs.
    Even so, your code is making a number of invalid assumptions about the
    structure of messages. I would suggest looking at the msgshow.java
    demo program. It includes code that visits all the parts of a message.
    It should be straightforward to extend that code to detect the parts you
    want to modify and to change the content of those parts using the
    setContent (or setText) method.
    If it's still not working for you, provide more detail about what you're doing,
    including a same message. (Send the details to me at [email protected]
    if you prefer.)

  • Modify Existing infocube

    Hi all,
    In BW 3.1, How we can modify existing cube with 3 years of data?
    I need to add characterstic in the existing cube with millions of record. If i add, then what will be the impact?
    Regards,
    Rajvinder

    Hi,
    From what I understand, you wish to have field set to either 'Y' or 'N' depending on availability of date. I assume this date is part of your BEx Query. In that case:
    1. You could create local CKF and do the needful. However, you will be unable to retrieve it from your InfoCube, which means the query can undergo performance issues if data is large. Nevertheless, it is worth a try.
    2. If the above does not work and you really need to have the field at InfoCube level, then you could try to create another Infocube (IC2) with key fields of present InfoCube (IC1) and add this field. After you have populated data in IC2, you can create an Infoset and you should be there.
    Hope this works.

Maybe you are looking for

  • Temperature Dirplay Panel For Geforce FX?

    I bought an MSI GeforceFX 5200 (TDR-128). In the past i have seen a temperature display panel in one of the nvidia display panels, when i was surfing. I have the latest drivers from nvidia (45.23), plus the "coolbits", but i cant see this temperature

  • Why can't I sign in and finish my registration

    Hi I can't finish registering my HP all-in-one C3180 can anyone tell me why.

  • Balanced ScoreCard Problem

    Hi, We are creating Balanced ScoreCard in SAP SEM System. The steps which we are following are like this: 1) First we created Scorecard Elements like Strategies,Perpsectives and init etc. in UMC_CUST tc. 2) Now, I am creating a Measure in UMK_MB and

  • Printing Problem in MS Excel

    When in Excel, I try to pring fast draft or regular draft both with plain paper. For some reason, I can't choose plain paper from the paper selection as it is grayed out. So when I print anything, it takes forever and colors it pixel by pixel. No mor

  • Progress bar do not show progress

    Hi there, I have created one dialog with button and progress bar. When I click on button, I have functionality which is getting called through which I make some changes in  currently open Indesign document like drawing some graphic frames, placing im