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

regarding Data into the table

Former Member
0 Likes
411

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

2 REPLIES 2
Read only

Former Member
0 Likes
387

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

Read only

vinod_vemuru2
Active Contributor
0 Likes
387

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.