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

update code

Former Member
0 Likes
719

Dear Friends

Basically i had an tables

zhr_pr_m where perid is primary key

zhr_pr_m_sal where perid is again primary key

two fields a field names Inact is also their which is type dataelement j_inact

menas active or inactive

with a screen with transaction zaa

i insert the values in

zhr_pr_m and zhr_pr_m_sal

now with another screen i want to update the

inact field of both tables corresponding perid of zhr_pr_m_sal

that means i had inact field and 3 more fields from zhr_pr_m_sal

now i want for a particular perid wen i run that and save to database then

it should modify that table zhr_pr_m_sal and

automatically update the same value for inact that zhr_pr_m_sal had

Please tell me the solution

i had written modify comand but its inserting the value in othe rline not modifying the same

i m new to abap

With Best Regards

Ruby

6 REPLIES 6
Read only

former_member189059
Active Contributor
0 Likes
687

Hello Ruby,

This is the syntax for updation of database tables

      LOOP AT itab.
        MOVE itab TO zdbtab.
        UPDATE zdbtab.
      ENDLOOP.

or


      LOOP AT itab INTO wa_itab.
        UPDATE zdbtab FROM wa_itab.
      ENDLOOP.

Read only

0 Likes
687

friend

itab type??/

zhr_pr_m_sal or zhr_pr_m

as i want to update value for inact first in zhr_pr_m_sal then corresponding value is to be inserted in zhr_pr_m

Hope u got will give me full answer

Thanks & Regards

Ruby

Read only

0 Likes
687

The itab should be of the same type of the table that you are updating

if the table structures are different, then you will have to use two internal tables to update data in both the database tables

so for zhr_pr_m_sal, you can use the update option

      LOOP AT itab.
        UPDATE zhr_pr_m_sal FROM itab.
      ENDLOOP.

then copy all that data to an internal table of zhr_pr_m_sal type (eg itab) to the internal table of zhr_pr_m type (eg itab2)

loop at itab.
  move-corresponding itab to itab2.
  append itab2.
endloop.

then insert / modify the zhr_pr_m table from itab2 according to your requirement

Read only

Former Member
0 Likes
687

Hi,

Do not write the Modify statment, Just change that to UPDATE then it will work

Regards

Sudheer

Read only

Former Member
0 Likes
687

UPDATE Statement

The UPDATE statement allows updating the values of selected columns of rows of a database table.

Syntax

<update statement> ::= UPDATE <table name> SET <assignment list> ( <where clause> )?.

<assignment list> ::= <assignment> ( ',' <assignment> ).

<assignment> ::= <column name> '=' <update source>.

< update source > ::= <value expression>

| <dynamic parameter specification>

| NULL.

You cannot specify string literals as values for CLOB columns. Hex literals are not supported in Open SQL.

Example

UPDATE employees SET employee_name = 'Mary Jones'

WHERE employee_id = 23

Read only

Former Member
0 Likes
687

Thanx