Application Development 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: 

Updating a table and displaying the result

Former Member
0 Kudos

hi all,

i have developed a report where i update a table with correct feild.

i display the output with write message, if a record is been updated once it gives me -->order no. 12345 updated . but if i execute the report again it gives me the same order no updation

Well, once i update the table with the correct field it should not give me the updation

message again

i am not getting how to do this.

any advice?

thnkx

bhanu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Bhanu,

before updating the table check whether the correct field exists already..if so then do not update...then ur pblm wil be resolved..

Regards,

Kaveri..

8 REPLIES 8

Former Member
0 Kudos

Hi Bhanu,

before updating the table check whether the correct field exists already..if so then do not update...then ur pblm wil be resolved..

Regards,

Kaveri..

0 Kudos

Ok i will check abt it and let you all know

thnkx

i will assure u points

Former Member
0 Kudos

Hi Bhanu,

AS Per my understanding, if you are updating a field once if u are updating the field with same value next time it is again updating the same value and giving you the message it ahs been updated sucessfully. When you don't want to do this then try to compare the previous value and present value and if they are same then don't update if not update it.

This is solution as per my understanding. If it is useful please reward and if I am wrong Please correct.

Thanks,

Murthy

former_member404244
Active Contributor
0 Kudos

Hi,

Before updating select the value from the table and check that if that entry exists,if yes then don't update and give message that already updated,if no then update the field and give message as field updated..

Regards,

nagaraj

former_member386202
Active Contributor
0 Kudos

Hi,

Refer this code

&----


*& Form SUB_READ_UPDATE_BSEG

&----


  • text

----


FORM sub_read_update_bseg.

IF NOT it_final[] IS INITIAL.

LOOP AT it_final INTO wa_final.

UPDATE bseg SET zuonr = wa_final-ccnum

WHERE bukrs EQ wa_final-bukrs

AND belnr EQ wa_final-vbeln

AND rfzei EQ wa_final-rfzei

AND saknr NE ' '.

ENDLOOP.

*--Message data updated successfully

MESSAGE i888 WITH text-002.

LEAVE LIST-PROCESSING.

ELSE.

*--Message No data found

MESSAGE i888 WITH text-003.

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. " SUB_READ_UPDATE_BSEG

Regards,

Prashant

Former Member
0 Kudos

I HAVE TAKEN THE FIELD LIKE THIS-->

WA_NEW-DATE IF NOT INITIAL.

UPDATE TABLE NAME.

NOW IF I WANT TO CHECK IF ITS ALREADY UPDATED

THEN?

0 Kudos

Hi Bhanu,

add one more check...

check table name-date is not initial with key field..

Regards,

Kaveri

0 Kudos

Hi,

Try like this

select single date from dbtable into v_date

where date = wa_new-date.

if sy-subrc eq 0.

(means record is thre).

message (record already exists).

else

update dbtable from wa_new.

message(record updated successfully).

endif.

Regards,

Nagaraj