Application Development 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: 

Modify database table from internal table

Former Member
0 Kudos

Hi All,

I need to update database table from internal table which is having around 30000 records.

I am using MODIFY tabname FROM TABLE int_tabname...

Using this statement, I can modify the databse records very well. But user has some additional requirement.

He wants that the table should be modified from the internal table and after modification we should have the erroneous records to be displayed if any.

e.g. if 1500 records out of 30000 are erroneous then only 28500 records should be updated and 1500 records should be displayed as erroneous records so that the user can correct them and use them again for executing the program.

Is there any FM which imports the database table name and internal table, modifies the database and exports an internal tanle with erroneous records?

Any help will be appriciated,

Regards,

Neha

5 REPLIES 5

former_member404244
Active Contributor
0 Kudos

Hi,

In this case..u have use loop statemnt .But performance wiese not good...

LOOP AT ITAB INTO WA.

MODIFY ZTABLE FROM WA.

IF SY-SUBRC NE 0.

Move wa to wa1.

append itab1 from wa1.

endif.

clear wa.

endloop.

now the table itab1 will have error records..

Reward if helpful.

Regards,

Nagaraj

Former Member
0 Kudos

Hi,

i suggest to use BDC or some other method to update database table ,

if you use this to update directly then check sy-subrc after each UPDATE or MODIFY commend if sy-subrc not equal to 0 then move the record to a seprate intenal table and show it to user.

regards

Deepak.

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Use the abap code:

<b>LOOP AT ITAB INTO WA.

MODIFY ZTABLE FROM WA.

IF SY-SUBRC NE 0.

Move wa to wa1.

append itab1 from wa1.

endif.

clear wa.

endloop.</b>

Regards,

Sree

Former Member
0 Kudos

Hi

modifying datbase table useing internal table

<b>advises</b> before updating this datbase table plz lock that table to avoid incosistency

write the logic for modifying

  • Modify the database table as per new dunning procedure

MODIFY fkkvkp FROM TABLE lt_fkkvkp .

and finally unlock the table

<b>example</b>

*To lock table for further operations

constants: lc_tabname TYPE rstable-tabname VALUE 'FKKVKP' . "FKKVKP

CALL FUNCTION 'ENQUEUE_E_TABLE'

EXPORTING

tabname = lc_tabname

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

IF sy-subrc EQ 0.

  • To fetch all the contract accounts for customers of the segment

  • Households/SME.

PERFORM fetch_contract_accounts using lc_tabname .

ENDIF. " IF sy-subrc EQ 0.

*wrote the logic

  • Modify the database table as per new dunning procedure from internal table

MODIFY fkkvkp FROM TABLE lt_fkkvkp .

*unlock the tbale

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

TABNAME = uc_tabname .

<b>Reward if usefull</b>

Former Member
0 Kudos

Hi,

As you asked try this function modules:

BDL/_MODIFY_MAINTAIN_A1S

BDL/_MODIFY_SESSMAP_A1S

BDL/_MODIFY_TASKS_A1S

APPTSEG_MODIFY_INTERNAL

Try it once the above function modules.

If it is useful please reward it.

thanks &regards

venkat