‎2010 Aug 18 3:15 PM
Hello experts,
i have written the following logic.
IT_CAL[] = IT_PRICING[].
CLEAR : WA_PRICING.
LOOP AT IT_CAL INTO WA_CAL.
SELECT SINGLE * FROM ZPRICING_SCALE WHERE ZCERTTYPE = WA_CAL-ZCERTTYPE
AND ZCUT = WA_CAL-ZCUT
AND ZGRWT_FR = WA_CAL-ZGRWT_FR
AND ZGRWT_TO = WA_CAL-ZGRWT_TO
AND ZFR_DAY = WA_CAL-ZFR_DAY
AND ZTO_DAY = WA_CAL-ZTO_DAY
AND ZCON_RATE = WA_CAL-ZCON_RATE.
IDX = SY-TABIX.
IF SY-SUBRC EQ 0.
WA_CAL-ZTO_DATE = SY-DATUM.
MODIFY ZPRICING_SCALE FROM WA_CAL." TRANSPORTING ZFR_DATE.
WA_PRICING-ZCERTTYPE = WA_CAL-ZCERTTYPE.
WA_CAL-ZFR_DATE = SY-DATUM.
WA_CAL-ZTO_DATE = '31129999'.
INSERT INTO ZPRICING_SCALE VALUES WA_CAL.
COMMIT WORK.
ELSE.
WA_CAL-ZFR_DATE = SY-DATUM.
INSERT INTO ZPRICING_SCALE VALUES WA_CAL.
ENDIF.
ENDLOOP.
my requirement is to find out the matching record with above selection criteria.
if it finds any matching record then i have to change the 'TO' date to today's date and also
append one line into z table with same line but 'FROM' date will be today's date and 'TO' days will be 3112999.
the above query is updating but not able to insert the record.
plz help.
Regards,
Ashmita Singh.
‎2010 Aug 18 3:33 PM
Hi Ashmita,
can you check what are the key fields for Z-table? if they are same, then you might not be able to insert entry.
Gouri.
‎2010 Aug 18 3:36 PM
Hi Ashmita,
Can you detail your requirment in now coded part,
wht I understood from this is, you want to check the entry in the Ztable if it exist u want to modify it and if it is not there u want to insert the record.
If this is the case then,
use your select query from the ztable if sy-dbcnt is initial. then insert tht entry into ztable else, modify the entry using the work area.
Thanks,
Anmol.
‎2010 Aug 18 3:50 PM
Hi Ahsmita,
I assume that the date field which are changing is a non key field. Since there already is a record with same key fields(Data) the modify statement is updating the record. If you want a new record add one more new field(item) ( increment the value for every new field or simply make the date field as key field.
Thanks,
Venkat
‎2010 Aug 19 7:53 AM
Hi ,
Thanks to all. Exactly, i want to change the date field if an existing record found .
eg.
there are to date fields1.From and 2. To
From date is decided on the day record is added but TO is always 99991231.
if suppose From - 20100812 and TO-99991231.
Then for the above record in ztable my query should update the TO date to today's date and also insert a new record
with From- 20100819 and TO-99991231.
IDX = SY-TABIX.
IF SY-SUBRC EQ 0.
WA_CAL-ZTO_DATE = SY-DATUM.
MODIFY ZPRICING_SCALE FROM WA_CAL INDEX idx TRANSPORTING ZFR_DATE.
but the above query is adding new line in ztable instead of modifying the same line.
and also i am getting a syntax error. "." expected after "WA_CAL"
And i have changed the date fields to key fields.
plz help
Records
Ashmita Singh
Edited by: Ashmita Singh on Aug 19, 2010 8:54 AM
‎2010 Aug 19 8:13 AM
Hi Ashmita,
This is called delimiting a record, which is common in SAP HR infotypes.
For this, two steps are required:
a) First find the correct existing record with TO DATE = 99991231 (forget the from date)
Modify the TO DATE to 20100819 (i.e. new date Minus 1)
b) Insert new record with all fields duly populated.
At this time put FROM DATE = 20100819 TO DATE = 99991231.
Regards,
Amit Mittal.