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: 

counter logic

Former Member
0 Kudos

Hi,

in my selection screen i have billing doc no- vbeln.

in my ztable i have etimes a field.

when i enter a bill doc no and press f8, my etimes feild in ztable sets to 1.

my requirement is if i enter a bill doc as 97600654 for first time, etimes is 1.

for second time if i enter that same bill doc i.e 97600654 , etimes should be 2 and if third then 3 and so on.

if a new doc is entered then etimes is again 1.

how to code this..plz provide some code.

1 REPLY 1

valter_oliveira
Active Contributor
0 Kudos

If there is concorrency, you should consider on locking your ztable first.

If not, just do something similar to this:


CLEAR w_etimes.
SELECT SINGLE etimes FROM ztable 
  INTO (w_etimes) 
 WHERE vbeln EQ p_vbeln.

IF sy-subrc EQ 0.
  ADD 1 TO w_etimes.
  UPDATE ztable 
     SET etimes = w_etimes
   WHERE vbeln EQ p_vbeln.
ELSE.
  wa-vbeln = p_vbeln.
  wa-etimes = 1.
  INSERT ztable FROM wa.  
ENDIF.

Regards,

Valter Oliveira.