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 SQL

Former Member
0 Likes
469

Hi

I want to update work area (wa)

fields (p1, p2)

with f1,f2 from table t1

where wa.id = t1.id

looping through the wa.

Whats the syntax?

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

former_member191735
Active Contributor
0 Likes
452

I want to update work area (wa)

fields (p1, p2)

with f1,f2 from table t1

where wa.id = t1.id

looping through the wa.

Whats the syntax?

You cannot loop through the work area. Work area is a structure.

well, in your case, you can either loop through the internal table t1 or you can read the internal table t1.

syntax

1)

read table t1 into w1 with key id = wa-id.

if sy-subrc = 0.

wa-p1 = w1-f1.

wa-p2 = w1-f2.

endif.

or you can loop through the internal table

loop at t1 where id = wa-id.

wa-p1 = t1-f1.

wa-p2 = t1-f2.

endloop.

2 REPLIES 2
Read only

former_member191735
Active Contributor
0 Likes
453

I want to update work area (wa)

fields (p1, p2)

with f1,f2 from table t1

where wa.id = t1.id

looping through the wa.

Whats the syntax?

You cannot loop through the work area. Work area is a structure.

well, in your case, you can either loop through the internal table t1 or you can read the internal table t1.

syntax

1)

read table t1 into w1 with key id = wa-id.

if sy-subrc = 0.

wa-p1 = w1-f1.

wa-p2 = w1-f2.

endif.

or you can loop through the internal table

loop at t1 where id = wa-id.

wa-p1 = t1-f1.

wa-p2 = t1-f2.

endloop.

Read only

Former Member
0 Likes
452

Hi,

if u want to update work area

u can simply pass the data like this.

wa is work area with two fields p1 and p2

l1 is the table with header line with two field f1 and f2.

read table l1 with key id = wa-id.
wa-p1 = l1-f1.
wa-p2 = l1-f2.

here loop is not used because u r filling data into work area.

so work area can contain only one record at a given point of time

reward if helpful

raam