Application Development and Automation 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: 
Read only

Hash Table -Runtime error.

Former Member
0 Likes
2,050

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

8 REPLIES 8
Read only

Former Member
0 Likes
1,315

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

Read only

0 Likes
1,315

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

Read only

0 Likes
1,315

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.

Read only

ThomasZloch
Active Contributor
0 Likes
1,315

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.

Read only

0 Likes
1,315

VBELN_GIT is same as the above declared one but i changed the name .

Read only

0 Likes
1,315

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.

Read only

raja_narayanan2
Active Participant
0 Likes
1,315

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

Read only

Former Member
0 Likes
1,315

Check data in table is there any mutiple entries