Skip to Content
author's profile photo Former Member
Former Member

sql query...

Hi ,

I have 2 database tables . one is vbep and the other one is zsodate. values will be changed in vbep . when we add a new records in vbep it will also adds the rows in zsodate. but our requirement is if one value is changed in vbep we have to updated the values in zsodate table by wrting the sql query by comparing the fields in vbeln and posnr .

give me update query how to find the exact row in zsodate and replace the value...

my code is this.

report z_test1 message-id xx .

tables : zsodate, vbap , vbep .

data : itab type standard table of zsodate with header line.

data : jtab type standard table of vbep with header line.

select-options : ordno for vbap-vbeln no intervals no-extension ,

itemno for vbap-posnr no intervals.

start-of-selection.

select * from zsodate into table itab where vbeln in ordno.

if sy-dbcnt = 0 .

message s999 with 'You Entered Wrong Order No ' .

exit.

endif.

select * from vbep into corresponding fields of table jtab

where vbeln in ordno.

loop at jtab.

write :/ jtab-vbeln,

jtab-edatu,

jtab-posnr.

select * from zsodate into corresponding fields of zsodate

where vbeln = jtab-vbeln and posnr = jtab-posnr.

where vbeln = jtab-vbeln and posnr = jtab-posnr.

  • loop at itab where vbeln = jtab-vbeln and posnr = jtab-posnr.

if sy-subrc = 0.

  • write / 'vbep entries '.

*write :/4 jtab-etenr , 'vbep etenr',

  • 15 jtab-edatu , 'vbep edatu'.

  • uline.

*write:/2 zsodate-vbeln,

  • 13 zsodate-posnr,

  • 26 zsodate-etenr,

  • 45 'has been updated'.

move jtab-etenr to zsodate-etenr.

write jtab-edatu to zsodate-origdate mm/dd/yyyy.

zsodate-mandt = sy-mandt.

zsodate-uname = sy-uname.

modify zsodate.

write:/2 zsodate-vbeln,

13 zsodate-posnr,

26 zsodate-etenr,

45 'has been updated.'.

endif.

endselect.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 12:05 PM

    not sure abt ur exact requirement but update query shud be liek this -

    update zsodate set field 1 = '1' field2 = '2' where field3 = 'abc'.

    but better to use Modify statement as it will serve both the purpose create and update..

    so press F1 on modify and use it..

    amit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2007 at 12:32 PM
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.