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: 

how to use counter in this case

Former Member
0 Kudos

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.

4 REPLIES 4

Former Member
0 Kudos

hi all,

plzz help

Former Member
0 Kudos

You can try something as below:

 SELECT single * INTO <wa_ztable> FROM <ztable>
    WHERE vbeln = p_vbeln.
    
 IF sy-subrc EQ 0.
   <wa_ztable>-vbeln = p_vbeln.
   <wa_ztable>-count = <wa_ztable> + 1.
   MODIFY <ztable> FROM <wa_table>.
 ELSE.
   <wa_ztable>-vbeln = p_vbeln.
   <wa_ztable>-count = 1.
   INSERT INTO <ztable> VALUE <wa_ztable>.
 ENDIF.

Regards

Eswar

Former Member
0 Kudos

To make the application persistent design a transparent table where u can store vbeln and counter value (count).

enter vbeln in the selection screen.

read ur custom table with the vbeln entered.

If record not found then set the counter to 1.

if record found then increment the counter by 1.

ans at last update the table with vbeln and new counter value.

Former Member
0 Kudos

Hi Rudra,

First You need to create a Ztable(say ZTT_VBELN_COUNT) with Three fields MANDT VBELN ETIMES.

Now in your program add code as below;

DATA wa_vbeln_count type line of ZTT_VBELN_COUNT.

SELECT SINGLE * FROM ZTT_VBELN_COUNT INTO CORESSPONDING FIELDS OF wa_vbeln_count where VBELN = lv_vbeln.

IF SY-SUBRC EQ 0.
   wa_vbeln_count-etimes = wa_vbeln_count-etimes + 1.
ELSE
   wa_vbeln_count-vbeln = lv_vbeln.
   wa_vbeln_count-etimes = 1.
ENDIF.

MODIFY ZTT_VBELN_COUNT FROM wa_vbeln_count.

Regards

Karthik D