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 Command Issue

Former Member
0 Likes
992

Dear All,

I have a scenarion to update only few fields to custom tables .

Here i should not use Modify command since other program runs every five minutes to update other fields in same table.

Some how the below program is not updating the data .

See the program and can you please tell me about performance if i use update within loop.

tables : zwvbak.

data : int_zwvbak LIKE zwvbak OCCURS 0 WITH HEADER LINE.

data : begin of wa_zwvbak ,

vbeln like zwvbak-vbeln,

BELNR like zwvbak-belnr,

ZZINVDATE like zwvbak-ZZINVDATE,

ZZINVTIME like zwvbak-ZZINVTIME,

end of wa_zwvbak.

data: f1 type i,

f2 type i,

f3 type i.

parameters p_vdatu like zwvbak-vdatu obligatory.

start-of-selection.

select * from zwvbak into corresponding fields of table int_zwvbak

where vdatu = p_vdatu.

get run time field f1.

loop at int_zwvbak.

clear : wa_zwvbak.

  • Accounting document number

MOVE '87999' TO wa_zwvbak-belnr.

  • Invoice date

move sy-datum to wa_zwvbak-zzinvdate.

  • Invoice Time

move sy-uzeit to wa_zwvbak-zzinvtime.

  • Sales order number

.

move int_zwvbak-vbeln to wa_zwvbak-vbeln.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = wa_zwvbak-vbeln

IMPORTING

OUTPUT = wa_zwvbak-vbeln

.

UPDATE zwvbak SET: zzinvdate = wa_zwvbak-zzinvdate

zzinvtime = wa_zwvbak-zzinvtime

belnr = wa_zwvbak-belnr

WHERE vbeln = wa_zwvbak-vbeln.

  • commit work.

endloop.

update zwvbak from table int_zwvbak.

commit work.

*

get run time field f2.

f3 = f2 - f1.

all inputs are welcome.

Thanks

Seshu

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
970

It looks to me like you are updating individual lines within the table in the loop, but then updating it again, setting it back the way it was in the final UPDATE statement.

Rob

9 REPLIES 9
Read only

former_member195698
Active Contributor
0 Likes
970

Using UPDATE from Table will be a better option as it will hit the database only once.

You can schedule this program in such a way that it doesn't collide with the Other program schedule.

Regards,

Abhishek

Read only

Former Member
0 Likes
971

It looks to me like you are updating individual lines within the table in the loop, but then updating it again, setting it back the way it was in the final UPDATE statement.

Rob

Read only

0 Likes
970

Thanks Rob, I just kept some dummy code here.. anyhow when i use client specified it works fine.

Can you please explain about update within loop,is it performance issue since i should not use update or modify outside of the loop .

I have many programs to update same table based on some conditions,if all programs are on same time it would be issue if i use modify statement.

I hope you got my point.

Thanks

Seshu

Read only

0 Likes
970

I would use the table update so long as the amount of data is reasonably small. If it is large, you have to split it into a number of updates with a COMMIT in between. This is done in order to avoid dumping when the rollback area is filled.

Rob

Read only

0 Likes
970

Rob,

May be i may have maximum 300 to 400 records each time since this job will run every 30 minutes.

so is it takes long time ?

Right now it is taking 180 seconds .

Thanks

Seshu

Read only

0 Likes
970

Is VBELN the first field in the primary key of your table?

Rob

Read only

0 Likes
970

Yes VBELN is the Key field .

custom tables contains only one key field called VBELN.

Thanks

Seshu

Read only

0 Likes
970

The time does seem excessive, but I don't really know why.

One thing I would defineitely do would be to get rod of the colon ( in the UPDATE statement. If you mis-place a comma in it as well, you can end up updating the entire database incorrectly.

Rob

Read only

0 Likes
970

Thanks Abhishek and Rob.

It is solved using update command within loop ,but little bit performance issue when you compare to modify command in out of loop.( 30 seconds extra).

Thank you for your support.

Thanks

Seshu