‎2008 Feb 18 5:51 PM
Hi frnds,
I have a ztable having 5 fields and i m updating data into these fields from a file in the application server , but i have a requirement where i have added one more key field (Seq no)
in the table but i dont have data for that field in the File present in the application server.
so i have been given a logic to update data into that field as like :While inserting generate a running number for inserting into SEQNO field . This is to ensure unique records in the table. Whenever a table insert is first initiated max( seqno) from ZACT should be picked and the new number will be max number + 1 , for next set of data it will be last number + 1.
Can anyone help me regarding this.
regards,
sanjay
Edited by: sanjay jaju on Feb 18, 2008 7:04 PM
‎2008 Feb 18 6:15 PM
Hi Sanjay,
Although I am not completely convinced you are using the concept of sequence number correctly, I will try and answer your requirement here:
To get the latest Sequence Number in the Z table (called say ZTAB) do as follows:
SELECT seqnr FROM ZTAB INTO v_max_seqnr
ORDER BY seqnr DESCENDING.
ENDSELECT.
v_max_seqnr = v_max_seqnr + 1.
Then the file that you have uploaded into an internal table compatible with ZTAB for the update, just modify it to update the Sequence number field (in internal table) with v_max_seqnr as below
wa-seqnr = v_max_seqnr.
MODIFY itab FROM wa
TRANSPORTING seqnr
WHERE seqnr IS INITIAL.
Finally
MODIFY ztab FROM TABLE itab.
-
Normally how I believe the sequence number should be used is, say currently your Z table has two primary key fields. Now the sequence number should be started from 1 for each new combination of the existing primary key combination and incremented every time this combination repeats.
Cheers,
Aditya
‎2008 Feb 19 3:06 PM
Hi,
Do like this.
DATA: w_count TYPE zact-seqno.
SELECT MAX( seqno ) INTO w_count FROM zact.
w_count has the max value of seqno in ur Ztable.
U can increment this by 1 and insert in new records. Hope this will solve ur problem.
Thanks,
Vinod.