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

table updation

Former Member
0 Likes
1,112

hi all,

i want to modify a selected record of a database table

please tell me how i can do the same

i have done following

data: idx type sy-tabix.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

data: itab2 type standard table of t508a with header line.

select * from t508a into table itab

where zeity = '1'

and mofid = '11'.

  • move itab to wa_tab.

idx = sy-tabix.

loop at wa_tab.

wa_tab-ENDDA = '99981231'.

MODIFY ITAB from wa_tab INDEX IDX

TRANSPORTING ENDDA.

endloop.

modify t508a from itab.

where t508a is a data base table like mara vbak and etc.

thanks in advance

pionts ll be surely awarded

anuj

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,042

Hi Anuj,

Just copy and paste the below code..

data: idx type sy-tabix.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

data: itab2 type standard table of t508a with header line.

select * from t508a into table itab

where zeity = '1'

and mofid = '11'.

loop at itab into wa_tab.

wa_tab-ENDDA = '99981231'.

MODIFY ITAB from wa_tab TRANSPORTING ENDDA.

endloop.

modify t508a from table itab.

commit work.

Reward points for helpful answers.

Regards,

hari krsihna

9 REPLIES 9
Read only

Former Member
0 Likes
1,042

hi,

try like this...

loop at it_tab into wa_tab.

wa_tab-ENDDA = '99981231'.

modify t508a from wa_itab.

endloop.

Satya.

Read only

Former Member
0 Likes
1,042

Hi anuj,

Do like this: -

loop at itab into wa.

wa_tab-ENDDA = '99981231'.

MODIFY itab from wa transporting ENDDA.

endloop.

Regards,

hari

Read only

former_member189059
Active Contributor
0 Likes
1,042

Hello Anuj,

First of all, your selection and looping seems a bit wrong

try it like this

data: idx type sy-tabix.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

data: itab2 type standard table of t508a with header line.

select * from t508a into<b> corresponding fields of</b> table itab

where zeity = '1'

and mofid = '11'.

<b>loop at itab into wa_tab.

wa_tab-ENDDA = '99981231'.

MODIFY ITAB from wa_tab.

update t508a from itab_wa.

endloop.</b>

Read only

Former Member
0 Likes
1,042

Hi anuj,

You may update the table individually.

UPDATE zsdautoave SET ENDDA = '99981231'

WHERE <selected record condition here>.

Or update the internal table first then mass database table update. Internal table and database table must have the same structure.

MODIFY <database table> FROM TABLE <internal table>.

Hope this helps.

Read only

Former Member
0 Likes
1,043

Hi Anuj,

Just copy and paste the below code..

data: idx type sy-tabix.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

data: itab2 type standard table of t508a with header line.

select * from t508a into table itab

where zeity = '1'

and mofid = '11'.

loop at itab into wa_tab.

wa_tab-ENDDA = '99981231'.

MODIFY ITAB from wa_tab TRANSPORTING ENDDA.

endloop.

modify t508a from table itab.

commit work.

Reward points for helpful answers.

Regards,

hari krsihna

Read only

0 Likes
1,042

hi Hari,

its very useful but using it i am getttin two record

say

fld1 fld2 date

aaa sss 12.04.2007

aaa sss 31.12.9998.

but i only need the second record(aaa sss 31.12.9998.) and not the first one

thanks alot

i have alot same piont also

anuj

Read only

Former Member
0 Likes
1,042

Hi,

Do Like This :

Tables : T508A.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

select * from T508A

into corresponding fields of table itab

where zeity = '1' and mofid = '11'.

if itab[] is not initial.

loop at itab into wa_tab.

wa_tab-endda = '99981231'.

modify itab from wa_tab transporting endda.

endloop.

endif.

give any suitable message

modify t508a from table itab.

if sy-subrc eq 0.

message ....

else.

message...

endif.

Reward points if useful.

Read only

Former Member
0 Likes
1,042

Hi Anuj,

I have changed your code as below. It should work fine now.

data: idx type sy-tabix.

data: itab type standard table of t508a." with header line.

data: wa_tab type t508a.

data: itab2 type standard table of t508a with header line.

select * from t508a into table itab

where zeity = '1'

and mofid = '11'.

loop at itab.

idx = sy-tabix.

Itab-ENDDA = '99981231'.

MODIFY ITAB INDEX IDX.

endloop.

modify t508a from itab.

*Reward points if helpful

Regards,

Amit

Read only

Former Member
0 Likes
1,042

ANSWERED