2008 Jul 30 12:35 PM
hi
i want to modify a table
how do i write the command if i want to modify it according to the table's keys ????
thanks
hi
i want to modify a table
how do i write the command if i want to modify it according to the table's keys ????
thanks
2008 Jul 30 12:37 PM
2008 Jul 30 12:37 PM
hiii
if you want to modify an internal table then use follwoing code
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0and if you want to update ztable then you need to use UPDATE of MODIFY query for that table.
regards
twinkal
2008 Jul 30 12:37 PM
Hi Ami,
The below thread gives you information on how to use the Modify Keyword in ABAP
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm
Have A Nice Day
Chaitanya.
2008 Jul 30 12:38 PM
Hi,
To change a single line, use the following statement:
MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].The work area <wa>, which must be compatible with the line type of the internal table, plays a double role in this statement. Not only it is used to find the line that you want to change, but it also contains the new contents. The system searches the internal table for the line whose table key corresponds to the key fields in <wa>.
The system searches for the relevant lines as follows:
Standard tables
Linear search, where the runtime is in linear relation to the number of table entries. The first entry found is changed.
Sorted tables
Binary search, where the runtime is in logarithmic relation to the number of table entries. The first entry found is changed.
Hashed tables
The entry is found using the hash algorithm of the internal table. The runtime is independent of the number of table entries.
To change one or more lines using a condition, use the following statement:
MODIFY <itab> FROM <wa> TRANSPORTING <f1> <f 2> ... WHERE <cond>.
This processes all of the lines that meet the logical condition <cond>. The logical condition can consist of more than one comparison. In each comparison, the first operand must be a component of the line structure. If the table lines are not structured, the first operand can also be the expression TABLE LINE. The comparison then applies to the entire line.
Regards,
Swapna.
2008 Jul 30 12:41 PM
Ami,
take a help of MODIFY by pressing F1 in se38.
because SAP help is most accurate help they desnt miss but we may
2008 Jul 30 12:42 PM
report .
types: begin of ttab ,
vbeln(10) type c ,
vkorg(4) type c,
dele(4) type c,
end of ttab ,
begin of ttab1 ,
vbeln(10) type c,
dele(4) type c,
end of ttab1 .
data: itab type table of ttab with header line,
itab1 type table of ttab1 with header line,
wa like line of itab ,
wa1 like line of itab1 .
itab-vbeln = '0000000001'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab-vbeln = '0000000002'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab-vbeln = '0000000003'.
itab-vkorg = '1000'.
itab-dele = 'DEL'.
append itab .
itab1-vbeln = '0000000001'.
itab1-dele = 'TST'.
append itab1 .
itab1-vbeln = '0000000002'.
itab1-dele = 'GRE'.
append itab1 .
sort itab by vbeln.
sort itab1 by vbeln.
loop at itab into wa.
data:v_index type sy-index .
v_index = sy-tabix.
read table itab1 into wa1 with key vbeln = wa+0(10).
wa14(4) = wa110(4).
modify itab index v_index from wa .
endloop.
loop at itab.
write:/ itab-vbeln,itab-vkorg,itab-dele .
endloop.
2008 Jul 30 12:45 PM
Hi,
I guess no just check the syntax through f1 ..
If you see the definition you will come to know on the key basis its not possible,
agree to a point that the structure of the internal table (in case if modifying ) through it has to be same.
:" Inserts new lines or updates existing lines in a database table (s. relational database). If a line with the specified primary key already exists, an UPDATE is executed. Otherwise, an INSERT is performed."
Mohinder
2008 Jul 30 12:52 PM
Hi
To update the data in the DB tables you can use either UPDATE statement or MODIFY statement.
Eg. UPDATE <table_name> SET <field1>=<value1> <field2>= <value2> .....
WHERE <key_field> = <value>
(or) MODIFY <table_name> from TABLE <ITAB>.
Hope it helps.
Murthy
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |