‎2008 Oct 31 2:21 PM
Hi,
i am defining internal table as hash table but it is giving runtime error like bolow. some times it is executing properly or giving dump.please give me some suggestions to come out of this problem.
Ex:
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLZGIT_MED" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
An entry was to be entered into the table
"\FUNCTION=ZBAPI_GIT_MED_HD_BOTELLAS_RPT\DATA=T_THERAPY_INFO" (which should
have
had a unique table key (UNIQUE KEY)).
However, there already existed a line with an identical key.
The insert-operation could have ocurred as a result of an INSERT- or
MOVE command, or in conjunction with a SELECT ... INTO.
The statement "INSERT INITIAL LINE ..." cannot be used to insert several
initial lines into a table with a unique key.
Code: .....................................
TYPES: BEGIN OF X_THERAPY_INFO,
GIT_THERAPY_ID TYPE ZGIT_VBELN_GIT,
CHO_THERAPY_ID TYPE VBELN,
SERVICE_ID TYPE MATNR,
SERVICE_DESC TYPE ARKTX,
FLOW TYPE ZGIT_ZFLOW,
DURATION TYPE ZGIT_ZDURATION,
GIT_PAT_ID TYPE ZGIT_KUNNR_GIT,
CHORUS_PAT_ID TYPE KUNNR,
END OF X_THERAPY_INFO,
....
DATA:
T_THERAPY_INFO TYPE HASHED TABLE OF X_THERAPY_INFO WITH UNIQUE KEY GIT_THERAPY_ID, " Internal table for extracting the therapy Informamtion
,
...................
*******************************************
Extract the Therapy Details
*******************************************
SELECT VBELN_GIT
VBELN
MATNR
ARKTX
ZFLOW
ZDURATION
KUNNR_GIT
KUNNR
INTO TABLE T_THERAPY_INFO
FROM ZGIT_T_VBAK
WHERE KUNNR_GIT NE SPACE
AND KVGR2 IN TR_KVGR2
AND ZDOCTOR IN TR_DOC_SEL_ID
AND ZHOSPITAL IN TR_HOSPITAL_ID
AND ( ZSTATUS_ID NE C_HIDDEN
AND ZSTATUS_ID NE C_DISABLED
AND ZSTATUS_ID NE C_OTHERS )
AND VBELN IN TR_VBELN.
IF SY-SUBRC NE C_0.
Thanks in advance,
Srinivas P
‎2008 Oct 31 2:25 PM
Hello,
The answer is present right in the dump error analysis :
Error analysis
An entry was to be entered into the table
"\FUNCTION=ZBAPI_GIT_MED_HD_BOTELLAS_RPT\DATA=T_THERAPY_INFO" (which should
have
had a unique table key (UNIQUE KEY)).
However, there already existed a line with an identical key.
You need to delete the duplicate records.
DELETE ADJACENT DUPLICATES ...regards,
Advait
Edited by: Advait Gode on Oct 31, 2008 3:26 PM
‎2008 Oct 31 2:58 PM
i did not get u. Please tell me. where should i write this statement?
because t_therapy_info is empty before select statement .
Cheers,
Srinivas P
‎2008 Oct 31 3:05 PM
When you are using hashed tables, you cannot have duplicate records (considering it's key). So DELETE ADJACENT DUPLICATES won't solve it. It will dump before that.
Find if you are inserting records with the same fields you inserted in the key.
Example.
If your key is VBELN, you cannot make it like this:
SELECT a~vbeln b~matnr
INTO TABLE hashed_itab
FROM vbak AS a INNER JOIN vbap as b
ON a~vbeln = b~vbeln
WHERE ...
It will dump if your vbeln has 2 lines in vbap.
Two solutions:
1 - expand the itab key to VBELN and POSNR (for example) or
2
SELECT DISTINCT a~vbeln b~matnr
INTO TABLE hashed_itab
FROM vbak AS a INNER JOIN vbap as b
ON a~vbeln = b~vbeln
WHERE ...
Regards,
Valter Oliveira.
‎2008 Oct 31 2:51 PM
You defined GIT_THERAPY_ID as the unique key of the table, but you are not selecting this field while filling the table with entries from the database. See if you can include this field in the select statement.
Thomas
Correction: you are filling it, but it seems that this column does not have unique entries in the database. Maybe several blank values? You could also try defining the table as SORTED with NON-UNIQUE key.
‎2008 Oct 31 3:02 PM
VBELN_GIT is same as the above declared one but i changed the name .
‎2008 Oct 31 3:06 PM
try to define standard table.
DATA:
T_THERAPY_INFO TYPE STANDARD TABLE OF X_THERAPY_INFO .
and Delete the Adjacent duplicates.
instead of hashedtable. it behaves like a Database table. if you have duplicates then it will give dump.
‎2008 Nov 01 11:25 AM
Hi....
In your SELECT query use DISTINCT.... so that duplicate values will be delete while you fetch from database itself....
SELECT DISTINCT <fields> from <database> INTO TABLE <ITAB> WHERE <CONDITIONS>.
Hope this will help you....
Thanks & Regards
Raja
‎2009 Sep 02 6:51 AM