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: 

Modifying DBTAB

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Delete the Exisiting record and add the new record.

santhosh

8 REPLIES 8

Former Member
0 Kudos

Hi,

Delete the Exisiting record and add the new record.

santhosh

0 Kudos

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

Regards

VIjay

0 Kudos

As far as my knowledge

santhosh

Former Member
0 Kudos

Hi,

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

Regards,

Darren

ThomasZloch
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

valter_oliveira
Active Contributor
0 Kudos

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.