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

How to update database table !!!

Former Member
0 Likes
2,496

hi all,

Please advice how to update database table with certain cndition needs to be checked.

Please consider below scenario.

have used enqueu and dequeue function to lock entries  and also i have used BAPI so considering that return parameter . i want to update table

/tdk/st0027.

1. I want to update database table

2. there are certain condition needs to be checked like ,

   loop at it_final into wa_final.

th_return-type = 'S'.

*********************************************************************

           if th_final-vbeln = /tdk/st0027-vbeln and

              th_final-posnr = /tdk/st0027-posnr and

              th_final-etenr = /tdk/st0027-sdslno.

above condition which i need to check .and need to append below system fields need to be appended in table.

          th_final-prstsind = '20'.

          th_final-chgdate  = g_date.

          th_final-chgtime  = g_uzeit.

          th_final-chgprog  = g_cprog.

          th_final-chguser  = g_uname.

          append th_final to td_final.

       

          update /tdk/st0027 FROM th_final.

          endif.

endloop.

but i am getting error saying that  "The type od database table and work area (TH_FINAL)  are not unicode convertible"?

I am not able to understandwhat would be the solution for this ?

Thanks and regards,

Prasad K. NAralkar

11 REPLIES 11
Read only

Former Member
0 Likes
2,296

Hi,

The work area is not type compatible with the DB.

Check how  you have declared the work area TH_FINAL.

It should be DATA: work area  TYPE database table.

Regards

Sree

Read only

0 Likes
2,296

yes have declared the same .but still its not allowing me to write modify or update query ?

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
2,296

Prasad

Can you please paste declaration of TH_FINAL and TD_FINAL

Read only

0 Likes
2,296

please find above details as i am restrict to copy paste the perticular code .

Read only

0 Likes
2,295

Read only

0 Likes
2,295

Prasad

Please compare structure of typ_final with database table /tdk/st00027. These both are different. Please create a local internal table of same type as database table. append data into that table and update

Nabheet

Read only

0 Likes
2,295

Hi but i want to update only some of fields of them .. have declared another structure with same fields still i am getting same error. ??

Read only

Former Member
0 Likes
2,295

hi,

plz check the data type of your inter table th_final.

your  table type must be same .

Read only

Former Member
0 Likes
2,295

i think the structure of both table is not same. first declare a local internal table as same as structure of that db table. then move corresponding value of th_final to that local internal table. then, update it.

Read only

mayur_priyan
Active Participant
0 Likes
2,295

The error occurs in the UPDATE statement included in the code. In this statement it is seen that there is a mismatch of structure defined for the DDIC table /tdk/st0027 and that of your work area th_final.

try to create a structure w.r.t the DDIC table.

Eg: DATA: wa_temp TYPE /tdk/st0027.

MOVE-CORRESPONDING th_final TO wa_temp.

Then try to UPDATE using the temporary work area i.e wa_temp which has structure similar to that of the database table.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,295

Either use a structure identical to database (and initially filled with current values of every field from database, else many fields will get initial value) or use a LOOP and a SELECT SET field = value WHERE statement.

Regards,

Raymond