‎2009 Jun 16 9:24 AM
table EVPOC contains objnr ,versn,evpai,datab,poc.
i have designed a similar Ztable (ZEVPOC) with fileds as of EVPOC but with date and time
as additional fields.
whenever an entry is made in tcode CJ2B it gets updated in EVPOC.
I have wrriten code which inserts all records if EVPOC to ZEVPOC.
TABLES : evpoc.
DATA: BEGIN OF itab OCCURS 0,
objnr LIKE evpoc-objnr,
versn_ev LIKE evpoc-versn_ev,
evpai LIKE evpoc-evpai,
datab LIKE evpoc-datab,
poc LIKE evpoc-poc,
END OF itab.
DATA : wa TYPE zevpoc,
v_objnr LIKE evpoc-objnr.
SELECT * FROM evpoc INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab.
wa-objnr = itab-objnr.
wa-versn_ev = itab-versn_ev.
wa-evpai = itab-evpai.
wa-datab = itab-datab.
wa-poc = itab-poc.
wa-date1 = sy-datum.
wa-time1 = sy-uzeit.
INSERT INTO zevpoc VALUES wa.
CLEAR: itab.
ENDLOOP.
which inserts all records from EVPOC to ZEVPOC via this code which is inside tcode ZPOC.
my requirement is if there is only one record in EVPOC after running this code i will get
one records in ZEVPOC (correct)
but again if i run ZPOC , ztable should insert the same record with
date and time .
if i run zpoc 20 times it should insert in ZEVPOC 20 times the same record inspite of the fact
that EVPOC has only 1 record
.
‎2009 Jun 16 9:30 AM
Hi,
Apply the initial check.
TABLES : evpoc.
DATA: BEGIN OF itab OCCURS 0,
objnr LIKE evpoc-objnr,
versn_ev LIKE evpoc-versn_ev,
evpai LIKE evpoc-evpai,
datab LIKE evpoc-datab,
poc LIKE evpoc-poc,
END OF itab.
DATA : wa TYPE zevpoc,
v_objnr LIKE evpoc-objnr.
SELECT * FROM evpoc INTO CORRESPONDING FIELDS OF TABLE itab.
LOOP AT itab.
wa-objnr = itab-objnr.
wa-versn_ev = itab-versn_ev.
wa-evpai = itab-evpai.
wa-datab = itab-datab.
wa-poc = itab-poc.
wa-date1 = sy-datum.
wa-time1 = sy-uzeit.
<Populate ITAB_ZEVPOS with ZEVPOS >
IF ITAB_ZEVPOS[] IS INITIAL
INSERT INTO zevpoc VALUES wa.
ENDIF
CLEAR: itab.
ENDLOOP.
Hope it helps....
‎2009 Jun 16 9:33 AM
You have to make the date and time fields as part of primary key in the database table ZEVPOC...
This will ensure that you have as many entries in ZEVPOC how many times you run the program...
Before inserting....populate the date field with sy-datum and time field with sy-uzeit...
Hope it clears! Otherwise please let me know!
‎2009 Jun 16 9:35 AM
Hi,
my requirement is if there is only one record in EVPOC after running this code i will get
one records in ZEVPOC (correct)
but again if i run ZPOC , ztable should insert the same record with
date and time .
if i run zpoc 20 times it should insert in ZEVPOC 20 times the same record inspite of the fact
that EVPOC has only 1 record
If you have duplicate entries in your records for the same key you will get dump so just add the extension ... accepting duplicate keys..
‎2009 Jun 16 9:39 AM
hi,
for this requirement :
1) open the table in se11.
2) open table maintenance generator
3) then go to enviroment => modification => events
there create event " 05 CREATE ENTRY".
in this event write the following code :
FORM create_entry.
ZEVPOC-date = sy-datum .
ZEVPOC-TIME = sy-uzeit .
ENDFORM. "create_entrynow when u create the same entry again and again it will create it with the automatically generated date and time in the column of date and time as per ur requirement
it will help u
rahul
Edited by: RAHUL SHARMA on Jun 16, 2009 4:50 AM
‎2009 Jun 16 9:40 AM
hi
ABLES : evpoc.
DATA: BEGIN OF itab OCCURS 0,
objnr LIKE evpoc-objnr,
versn_ev LIKE evpoc-versn_ev,
evpai LIKE evpoc-evpai,
datab LIKE evpoc-datab,
poc LIKE evpoc-poc,
END OF itab.
DATA : wa TYPE zevpoc,
v_objnr LIKE evpoc-objnr.
SELECT * FROM ZEVPOC INTO CORRESPONDING FIELDS OF TABLE itab2.
SELECT * FROM evpoc INTO CORRESPONDING FIELDS OF TABLE itab.
DELETE itab WHERE objnr = itab2-objnr.
LOOP AT itab.
wa-objnr = itab-objnr.
wa-versn_ev = itab-versn_ev.
wa-evpai = itab-evpai.
wa-datab = itab-datab.
wa-poc = itab-poc.
wa-date1 = sy-datum.
wa-time1 = sy-uzeit.
if wa is not initial.
INSERT INTO zevpoc VALUES wa.
endif.
CLEAR: itab.
ENDLOOP.
Hope it wil be help ful to u..
regard
nawa