Application Development and Automation 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: 
Read only

Modify statement is not working.

Former Member
0 Likes
2,055

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
Read only

Former Member
0 Likes
1,499

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

ashish

Read only

0 Likes
1,499

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.

Read only

0 Likes
1,499

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

Read only

0 Likes
1,499

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

Read only

0 Likes
1,499

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.

Read only

0 Likes
1,499

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.

Read only

0 Likes
1,499

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

Read only

0 Likes
1,499

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

Read only

0 Likes
1,499

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.

Read only

0 Likes
1,499

Experts, "Modify Statement" does not work between

EXEC SQL -


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

Read only

Former Member
0 Likes
1,499

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

Read only

0 Likes
1,499

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

Read only

Former Member
0 Likes
1,499

Thank You all.