‎2007 Oct 23 4:51 AM
Hi all,
Will you pls anybody let me know ,
what is the difference of
Modify table itab from wa
and
Modify itab from wa
In which scenarios you have to you have to use the following statements,
thanks in advance
regards,
Madhavi
‎2007 Oct 23 4:55 AM
to modify table
Modify table itab from wa is not correct
Modify table itab.
is used to change the total internal table from work area containts
and
Modify itab from wa
is used to change the single row in internal table from work area containts
TABLE itab
Effect
The line to be changed is determined by the fact that the content of the table key matches the content of the corresponding components in the wa work area. For tables with a key that is not unique, the first entry that is found is changed.
Example
Conversion of the local currency of an airline to Euro using key access in the scarr_tab internal table.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab INTO scarr_wa
WITH TABLE KEY carrid = p_carrid.
scarr_wa-currcode = 'EUR'.
MODIFY TABLE scarr_tab FROM scarr_wa
TRANSPORTING currcode.
The INDEX addition can also be after FROM wa.
Example
Conversion of the local currency of an airline to Euro in the scarr_tab internal table using index access.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA: idx TYPE sy-tabix,
scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab
WITH TABLE KEY carrid = p_carrid
TRANSPORTING NO FIELDS.
idx = sy-tabix.
scarr_wa-currcode = 'EUR'.
MODIFY scarr_tab INDEX idx FROM scarr_wa
TRANSPORTING currcode.
Rewards if useful.......
Minal Nampalliwar
‎2007 Oct 23 4:55 AM
to modify table
Modify table itab from wa is not correct
Modify table itab.
is used to change the total internal table from work area containts
and
Modify itab from wa
is used to change the single row in internal table from work area containts
TABLE itab
Effect
The line to be changed is determined by the fact that the content of the table key matches the content of the corresponding components in the wa work area. For tables with a key that is not unique, the first entry that is found is changed.
Example
Conversion of the local currency of an airline to Euro using key access in the scarr_tab internal table.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab INTO scarr_wa
WITH TABLE KEY carrid = p_carrid.
scarr_wa-currcode = 'EUR'.
MODIFY TABLE scarr_tab FROM scarr_wa
TRANSPORTING currcode.
The INDEX addition can also be after FROM wa.
Example
Conversion of the local currency of an airline to Euro in the scarr_tab internal table using index access.
PARAMETERS p_carrid TYPE scarr-carrid.
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA: idx TYPE sy-tabix,
scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab
WITH TABLE KEY carrid = p_carrid
TRANSPORTING NO FIELDS.
idx = sy-tabix.
scarr_wa-currcode = 'EUR'.
MODIFY scarr_tab INDEX idx FROM scarr_wa
TRANSPORTING currcode.
Rewards if useful.......
Minal Nampalliwar
‎2007 Oct 23 4:55 AM
Please look into the link...
http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
Modify table itab from wa.....for changing a line....
modify itab from wa ....for changing lines....
‎2007 Oct 23 4:56 AM
Check the Help files:
Modify itab from wa
Changes a single entry in the internal table itab, specifying the key explicitly or implicitly. You can only use this variant with index table (standard or sorted tables).
Modify table from wa
Generic change to a single entry in the internal table itab with key. Unlike variant 1, you can use this variant for any table.
‎2007 Oct 23 4:57 AM
Hi,
MODIFY
Change a database table
- MODIFY dbtab.
MODIFY *dbtab.
MODIFY (dbtabname) ... .
- MODIFY dbtab FROM TABLE itab.
MODIFY (dbtabname) FROM TABLE itab.
- MODIFY dbtab VERSION vers.
MODIFY *dbtab VERSION vers.
Change an internal table
- MODIFY itab [FROM wa] [INDEX idx].
[TRANSPORTING f1 ... fn [WHERE cond]].
- MODIFY TABLE itab [FROM wa]
[TRANSPORTING f1 ... fn].
- MODIFY itab [FROM wa]
TRANSPORTING f1 ... fn WHERE cond.
When you use TABLE in MODIFY, then you do not need any LOOP, it will modify all records of table where condition is true.
But when you say MODIFY ITAB, it will just modify taht specific record.
Hope it answers your question.
ashish
‎2007 Oct 23 4:58 AM
Hi ,
The main diff is:
MODIFY itab [FROM wa]----
You can only use this variant with index table (standard or sortedtables).
Modify table itab from wa -
youcan use this variant for any table. (standard or sortedtables or hashed tables).
Rvert back if any issues,
reward if helpful.
regards
Naveen
‎2007 Oct 23 5:07 AM
Hi Madhavi,
To Change a single Line Using the Table Key use the following statement:
MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...].
The system searches the internal table for the line whose table key corresponds to the key fields in <wa>.
The TRANSPORTING clause is optional in this statement.
-
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 TRANSPORTING addition is not optional here.Furthermore, you can only modify the key fields of the internal table if it is a standard table.
Reward useful answers