2010 Apr 17 4:14 AM
Dear Guru ,
I need a program which can compare the records between internal table and transparent table .
If the transparent table already have the record (check with PK) , it only update the record from internal table .
If not , append the record from my internal table to the transparent table ...
My solution is a stupid way that is to check the transparent table before we take the decision ... if it has , update , if not , append ...
Does any fast way can do this ?
Thanks .
Best Regards,
Carlos Zhang
2010 Apr 17 6:18 AM
Use MODIFY <database table> FROM TABLE <internal table>
If the record avaialble for primary key condition in database table, record will be updated, otherwise record will be inserted.
Regards
Vinod
Dear Guru ,
I need a program which can compare the records between internal table and transparent table .
If the transparent table already have the record (check with PK) , it only update the record from internal table .
If not , append the record from my internal table to the transparent table ...
My solution is a stupid way that is to check the transparent table before we take the decision ... if it has , update , if not , append ...
Does any fast way can do this ?
Thanks .
Best Regards,
Carlos Zhang
2010 Apr 17 4:22 AM
Hi,
You can use MODIFY key word to update the database. This serves 2 purposes.
1) if the Records with Primary Key already there it UPDATEs the Records
2) Otherwise it APPENDs the Records to the Transperant Table.
loop at itab into wa.
" do whatever you want to process
endloop.
modify <DBTAB> FROM TABLE <ITAB> " Instead of modifying within a loop you can do it FROM TABLE additionFor more infor Take F1 help on this MODIFY key word
Hope this would serve your purpose.
Cheerz
Ram
2010 Apr 17 4:47 AM
Good day Carlos Zhang,
Here is the code i used.
data: fs_spfli like line of t_spfli,
fs_spfli1 like line of t_spfli.
Loop at t_spfli into fs_spfli.
MODIFY zspfli from fs_spfli.
clear fs_spfli.
IF sy-subrc EQ 0.
COMMIT WORK.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Endloop.
HERE ZSPFLI IS MY TRANSPERANT TABLE I CREATED.
T_SPFLI CONTAINS RECORDS SOME MAY BE EXTRA RECORDS.
Regards and Best wishes.
2010 Apr 17 6:18 AM
Use MODIFY <database table> FROM TABLE <internal table>
If the record avaialble for primary key condition in database table, record will be updated, otherwise record will be inserted.
Regards
Vinod
2010 Apr 17 6:31 AM
May i know how does your solution differ from Ramchander's post ? Does it add any value ?
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |