Skip to Content
0
Apr 26, 2005 at 01:46 PM

SECUENTIAL FIELD IN ZTABLE

26 Views

Hi,

i´m developing a ZTABLE. In this ztable there are two key fields. One of them (

ZNUMDE

) must be the result of concatenating

sy-uname(3) sy-datum+2(2) and a secuential
number of 2 digits

the moment the entry is created.
This key field must distinguish the number of entries in the table by user.
e.g. user PETER has 2 entries -> 1st ZNUMDE = PET0501
2nd ZNUMDE = PET0502
for user JOHN (1 entry) -> ZNUMDE = JOH0501.
In order to achieve this i´ve created a maintenance view of the table and within the event '01' BEFORE SAVING IN THE DATABASE i´ve created a routine within which i´ve added the following code:

DATA: v_max(2) TYPE i,

v_numde(7) TYPE c,

v_conta(2) TYPE c.

CLEAR: v_max, v_numde, v_conta.

  • Here i check the number of entries of a the user

SELECT COUNT( DISTINCT usuar ) INTO v_max

FROM ZTABLE WHERE usuar = sy-uname.

IF v_max GT 0.

v_max = v_max + 1.

v_conta = v_max.

ELSE.

v_max = 1.

v_conta = v_max.

ENDIF.

SHIFT v_conta RIGHT.

REPLACE '' WITH '0' INTO v_conta.

CONCATENATE sy-uname(3) sy-datum+2(2) v_conta

INTO z_v_devolucion-numde.

z_v_devolucion-usuar = sy-uname.

The question is that thus i´m not able to get ZDEVNUM as desired.

Any suggestion?

Best regards.