Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Modify statement is not working.

Former Member
0 Kudos

MODIFY AH(table) FROM wa(workarea)

TRANSPORTING Funct Sh SF (table fields)

WHERE Funct = wa-functlr

AND Sh = v_sh

AND SF = wa-sf.

13 REPLIES 13

Former Member
0 Kudos

Let me know your code. Are you modifying standard db table or a internal table?

ashish

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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.

0 Kudos

Experts, "Modify Statement" does not work between

EXEC SQL -


ENDEXEC. So only Insert or Update can be used depending on the requirement.Thank you.

Former Member
0 Kudos

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

0 Kudos

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??.

Former Member
0 Kudos

Thank You all.