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

Modifying DBTAB

Former Member
0 Likes
859

Dear Guru's,

I have a Ztable with the following Fields:

OBJECT_ID

BEGDA

ENDDA

SEQNR

WERKS

BTRTL

of which OBJECT_ID, BEGDA, ENDDA, SEQNR are keyfields.

Consider I have a data with OBJECT_ID = 9400, BEGDA = '20080929', ENDDA = '99991231', SEQN = '001'.

now I am gonna save a new record to the table OBJECT_ID = 9400, BEGDA = '20081029', ENDDA = '99991231', SEQN = '001' through a program.

What I want to do in my program is I want the first data to be delimited to the new datas begda.

i.e., first data must change to OBJECT_ID = 9400, BEGDA = '20080929', ENDDA = '20081029', SEQN = '001'.

how to do it....

I cant use modify because the key fields are different so it will add a new record. Please tell me how to go about it???

Regards

VIjay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
818

Hi,

Delete the Exisiting record and add the new record.

santhosh

8 REPLIES 8
Read only

Former Member
0 Likes
819

Hi,

Delete the Exisiting record and add the new record.

santhosh

Read only

0 Likes
818

isn't there another way than deleting & recreating??

Regards

VIjay

Read only

0 Likes
818

As far as my knowledge

santhosh

Read only

Former Member
0 Likes
818

Hi,

You have to read the first record and set the new end date using MODIFY and then create the new record.

Regards,

Darren

Read only

ThomasZloch
Active Contributor
0 Likes
818

This is why SAP does not include BEGDA in the primary key of their date dependent tables, see table CSKS for example. Maybe you can still adapt that design and solve the problem this way.

Thomas

Read only

Former Member
0 Likes
818

hi,

delete itab1 where index = 1.

loop at itab1 into wa1.

wa_out_end_date = 'enter the new date'.

modify itab1 from wa1 where index = sy-tabix.

clear wa1.

endloop.

Read only

Former Member
0 Likes
818

Hi,

Try like this....



Read table <internaltable> into wa index 1.
lv_tabix = sy-tabix.
wa-enddate = '20080929'.
modify <internaltable> index lv_tabix from wa transporting enddate.

Hope it will helps

Read only

valter_oliveira
Active Contributor
0 Likes
818

DATA: wa1 TYPE ztable,
      wa2 TYPE ztable.
SELECT SINGLE * FROM ztable INTO wa1 WHERE. "some condition
CHECK sy-subrc EQ 0.
wa2 = wa1.
wa2-BEGDA = '20081029'.
INSERT ztable FROM wa2.
DELETE ztable FROm wa1.

Regards,

Valter Oliveira.