10-22-2007 10:05 PM
MODIFY AH(table) FROM wa(workarea)
TRANSPORTING Funct Sh SF (table fields)
WHERE Funct = wa-functlr
AND Sh = v_sh
AND SF = wa-sf.
10-22-2007 10:15 PM
Let me know your code. Are you modifying standard db table or a internal table?
ashish
10-22-2007 11:09 PM
Ashish,
I am trying to modify the data in MSSQL-SERVER data base table from the ABAP.I have a workarea 'wa' and
the table lets say AH.I want to modify the table data
EXEC SQL
MODIFY AH(table) FROM wa(workarea)
TRANSPORTING Funct Sh SF (table fields)
WHERE Funct = wa-functlr
AND Sh = v_sh
AND SF = wa-sf.
ENDEXEC.
10-22-2007 11:13 PM
Hi Neeraj,
Instead of directly modifing db table,
First fill up internal table with required data and use Insert statement.
Insert DBTABLE from ITAB.
check syntax with help..
Then it works.
priya
null
10-22-2007 11:14 PM
I fee lthis modify syntax will not work.
Check this link for Native SQL which will give you an idea -
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm
ashish
10-22-2007 11:20 PM
Priya, I have tried the Insert and update statement and they work fine but at the moment requirement is to modify the data not to insert only. Because modify do insert and update both depending on the records availability.My syntax is jumping back with error saying there is error.
10-22-2007 11:23 PM
Experts, Update actually only works when there is data existing but if the table is empty then I should insert and when there is data then I should update to unique records means the different records then what I am inserting.So modify was the only option but it does not work.
10-22-2007 11:27 PM
Do one thing.
Before inserting or updating ,
first delete all the records in the DB table.
Then use Insert statement with ITAB.
Then you wll not get error. You will have latest data in the ITAB any way.
priya
10-22-2007 11:27 PM
Do one thing,
Select data for the specified condition from table.
If data exists, use UPDATE command.
If data does not exist, use INSERT command.
ashish
10-22-2007 11:41 PM
Priya, The requirement is like this.
If
the data record(PRkey) to be inserted in table is same like existing record then update other columns for this PRkey record.
Else
Insert new record.
EndIf.
That's why I thought to use Modify because that statement automatically do these both works but I am missing something in syntax.
10-23-2007 2:18 PM
Experts, "Modify Statement" does not work between
EXEC SQL -
ENDEXEC. So only Insert or Update can be used depending on the requirement.Thank you.
10-22-2007 10:30 PM
Hi,
Did you check the value of SY-SUBRC after the modify statement? If the sy-subrc eq 0 then its modifying the data. If its not equal to 0 then the modify statement is failing. Hope the structure of the workarea and the table you are trying to modify is same. Hope you have a record which stratifies the where clause mentioned in the modify statement.
Cheers
VJ
10-22-2007 11:15 PM
Vijayendra, Structure of the workarea is not same because the values coming into the workarea are coming from othertable of SAP and I have to update the values of SQLServer table columns.Do you think it is going to modify only same structure table from workarea??.
10-23-2007 1:36 PM