‎2009 Feb 12 8:26 AM
hi,
I have upload program for duplicate entries.In that for duplicate entries if i give * (for ex 2001*)
it is not taking for the upload.In my case 2001 is ulready there.How to give one more new entry
on the same.Please give some suggestions.
TYPE-POOLS TRUXS.
TABLES : ZGATEP.
TYPES : BEGIN OF TY_ZGATEP,
GTEN TYPE ZGATEP-GTEN,
ZDATE TYPE ZGATEP-ZDATE,
LIFNR TYPE ZGATEP-LIFNR,
NAME1 TYPE ZGATEP-NAME1,
VBELN TYPE ZGATEP-VBELN,
DDATE TYPE ZGATEP-DDATE,
EBELN TYPE ZGATEP-EBELN,
GJAHR TYPE ZGATEP-GJAHR,
WERKS TYPE ZGATEP-WERKS,
END OF TY_ZGATEP.
DATA : IT_ZGATEP TYPE TABLE OF TY_ZGATEP,
WA_ZGATEP TYPE TY_ZGATEP,
IT_TYPE TYPE TRUXS_T_TEXT_DATA.
PARAMETER : P_FILE TYPE RLGRAP-FILENAME.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = P_FILE
.
START-OF-SELECTION.
Uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_TYPE
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_ZGATEP[]
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
END-OF-SELECTION.
LOOP AT IT_ZGATEP INTO WA_ZGATEP.
ZGATEP-GTEN = WA_ZGATEP-GTEN.
ZGATEP-ZDATE = WA_ZGATEP-ZDATE.
ZGATEP-LIFNR = WA_ZGATEP-LIFNR.
ZGATEP-NAME1 = WA_ZGATEP-NAME1.
ZGATEP-VBELN = WA_ZGATEP-VBELN.
ZGATEP-DDATE = WA_ZGATEP-DDATE.
ZGATEP-EBELN = WA_ZGATEP-EBELN.
ZGATEP-GJAHR = WA_ZGATEP-GJAHR.
ZGATEP-WERKS = WA_ZGATEP-WERKS.
MODIFY ZGATEP.
ENDLOOP.
‎2009 Feb 12 8:29 AM
if an entry already exists for a set of primary key in a table, it will not allow dupliacate entries.
wat r the primary keys in ur table.
‎2009 Feb 12 8:33 AM
in my case 2000 is a primary key.if any option is availabe for giving duplicate entries like 2000*.
‎2009 Feb 12 8:33 AM
hi,
1) In your case if the table has the value 2001 in the primary key, then it is not possible to upload a new value, instead the table modifies the existing record.
2) For this to happen make sure the record 2001* you are referring to should not be a value in the primary key.
3) Instead of looping the internal table and modifying the DBTABLE for every record in internal table, directly insert the entries using INSERT DBTAB FROM TABLE <itab>.
This might give you a duplicate record in the table as per your requirement.
Thanks
Sharath
‎2009 Feb 12 8:36 AM
so if 2000 alone is a primary key, u can hve a unique value for this 2000 in the table.
now if u pass the new values and modify the table also, it will jus overwrite the previous values with the new value that u hve passed now.
‎2009 Feb 12 8:38 AM
HI,
In your case, create a primary key with more than one field,
then its possible for you to have duplicate entries for value 2000 with some other key field combination inside the database table.
Thanks
Sharath
‎2009 Feb 12 8:43 AM
2000 02.02.2009 100525 ACME SAFETYWEARS LIMITED 4382 02.02.2009 5500000028
like this my entries are there.already one entry is there with 2000.i need to to insert this record also.
‎2009 Feb 12 8:47 AM
hi,
In the DBTABLE , if it is possible for you restructure in a way that the fields LIFNR or VBELN or EBELN, can make a primary key combination, with 2000* (GTEN)then its possible to have more than one entry for that value, else if you are restricted as per your requirement to only one field(GTEN,2000) to be the primary key then its not possible to have more than one record in the table.
Thanks
Sharath
‎2009 Feb 12 9:27 AM
thank u .That is not possible.I have to tell my consultants.
Regard,
Bathri...
‎2009 Feb 12 9:02 AM
‎2009 Feb 12 9:28 AM
‎2009 Feb 12 9:29 AM
‎2009 Feb 12 9:34 AM
ok..if u hve rec like this:
2000 02.02.2009 100525 ACME SAFETYWEARS LIMITED 4382 02.02.2009 5500000028
gten is 2000 gjhr is 02.02.2009 werks:5500000028
this means a record is already there for this set of primary keys.
now if u insert a rec with gten 2000 and wth gjhr or werks with a diff. value from the above one, a rec gets created.
but if u enter a record for the same set of primary keys, it will be overwritten.what exactly u need to insert now?
Edited by: Kalyan Chakravarthi on Feb 12, 2009 10:34 AM
‎2009 Feb 12 10:03 AM
200023 02.02.2009 100525 ACME SAFETYWEARS LIMITED 4382 02.02.2009 5500000028 2009 RAU1
this is already there.
200023 02.02.2009 100384 SREE MADESHWARA ENTERPRISES 587 02.02.2009 5500000194 2009 RAU1
second is my duplicate entry.
primary keys are 20023 2009 RAU1
program is given up.
tell some possible solutions.
‎2009 Feb 12 10:07 AM
its already said.
if u see, u r tryin to insert another record for the same set of entires for which a record already exists.this will not insert rather it will overwrite.
what u can do is if u make another field as a primary key and if u hve a diff val in this field, this record will get inserted.
‎2009 Mar 06 5:30 AM