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

logic

Former Member
0 Likes
645

Hi

i am using the following logic to insert the records to database table. but i ll affect the performance. how can i improve the performance using field symbols.

IF counta <> 0.

LOOP AT itab_zdfkkwoh INTO wa_zdfkkwoh.

TRY.

INSERT zdfkkwoh FROM wa_zdfkkwoh.

CATCH cx_sy_open_sql_db INTO error_obj_ref.

error_text = error_obj_ref->get_text( ).

MESSAGE i398(00) WITH 'Error Inserting Records. Duplicate copies exist.'.

SKIP 1.

WRITE: /10 'zdfkkwoh:',error_text.

SKIP 1.

ULINE.

SKIP 1.

ENDTRY.

ENDLOOP.

ENDIF.

points will be reward

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
620

Hi

Check this Code For INserting

IF counta 0.

INSERT zdfkkwoh FROM TABLE itab_zdfkkwoh .

Mass insert: Inserts all lines of table itab in a single operation. The lines of itab must satisfy the same condition as the work area wa in variant 1.

IF sy-subrc = 0 .

'sucess'.

ELSE.

'show error;

ENDIF,

ENDIF.

Hope it Helps.

Praveen

Edited by: praveen parasiya on Feb 21, 2008 2:35 AM

5 REPLIES 5
Read only

Former Member
0 Likes
621

Hi

Check this Code For INserting

IF counta 0.

INSERT zdfkkwoh FROM TABLE itab_zdfkkwoh .

Mass insert: Inserts all lines of table itab in a single operation. The lines of itab must satisfy the same condition as the work area wa in variant 1.

IF sy-subrc = 0 .

'sucess'.

ELSE.

'show error;

ENDIF,

ENDIF.

Hope it Helps.

Praveen

Edited by: praveen parasiya on Feb 21, 2008 2:35 AM

Read only

0 Likes
620

Hi Praveen

Shall i code like this?

IF counta <> 0.

SORT itab_zdfkkwoh.

LOOP AT itab_zdfkkwoh ASSIGNING <fs_zdfkkwoh>.

lv_tabix = sy-tabix.

READ TABLE itab_zdfkkwoh WITH KEY abbel = <fs_zdfkkwoh>-abbel BINARY SEARCH.

IF sy-subrc = 0.

<fs_zdfkkwoh>-opsta = itab_zdfkkwoh-opsta.

Append itab_zdfkkwoh. " INDEX lv_tabix.

CLEAR itab_zdfkkwoh.

ENDIF.

ENDLOOP.

ENDIF.

INSERT zdfkkwoh

FROM TABLE itab_zdfkkwoh.

Read only

0 Likes
620

Hi

Kumar you are looping the table and then reading the same table..

I would suggest like below..

IF counta 0.

SORT itab_zdfkkwoh.

LOOP AT itab_zdfkkwoh WHERE abbel = 'Your Value'

IF sy-subrc = 0.

Build another table ITAB2.

ENDIF.

ENDLOOP.

ENDIF.

INSERT zdfkkwoh

FROM TABLE itab2.

OR lets Us say you want to insert records only from

itab_zdfkkwoh WHERE ABBEL = '2' .

DOlike below..

DELETE itab_zdfkkwoh WHERE ABBEL NE '2' ,

INSERT zdfkkwoh

FROM TABLE itab_zdfkkwoh .

Hope it helps.

Let me know if u any doubt ..

Praveen

Read only

0 Likes
620

hi praveen

thanks for ur help

Read only

0 Likes
620

Hi

Kumar Check this FORM,,

itab_zdfkkwoh From itab_temksv-newkey

FORM get_newkey.

SORT itab_temksv BY newkey.

SORT itab_zdfkkwoh BY abbel.

SELECT * FROM temksv INTO TABLE itab_temksv

FOR ALL ENTRIES IN itab_keys

WHERE firma = 'SPS' AND object = 'DOCUMENT'

AND oldkey = itab_keys-oldkey.

LOOP AT itab_zdfkkwoh ASSIGNING <fs_zdfkkwoh>.

READ TABLE itab_temksv WITH KEY oldkey = <fs_zdfkkwoh>-abbel.

IF sy-subrc = 0.

<fs_zdfkkwoh>-abbel = itab_temksv-newkey.

MODIFY itab_zdfkkwoh FROM <fs_zdfkkwoh> TRANSPORTING abbel . (Check Syntax For this )

ENDIF.

ENDLOOP.

ENDFORM. "get_newkey

Hope it will helps.

Praveen