‎2007 Nov 13 8:27 AM
Hi,
I want to replace some old values with new values at table level.there are so many tables need to replace those values.that means i have 30 to 40 tables to replace.for this i want a report program .Can any one give me the idea.
Thanks in advance.
‎2007 Nov 13 8:29 AM
‎2007 Nov 13 8:50 AM
If we have done by manually there is a chance to make mistakes.so they have asked to create custom program .give me the idea?.
‎2007 Nov 13 8:59 AM
Hi
with this code one table getting modified
write the same modify statement to all the tables in this program
*----------------------------------------------------------------------
*TYPE DECLARATION
*----------------------------------------------------------------------
TYPES : tt_fkkvkp TYPE STANDARD TABLE OF fkkvkp. "Table type for fkkvkp
*----------------------------------------------------------------------
*START-OF-SELECTION.
*----------------------------------------------------------------------
START-OF-SELECTION.
*To lock table for further operations
PERFORM lock_table .
*&---------------------------------------------------------------------*
*& Form fetch_contract_accounts
*&---------------------------------------------------------------------*
* To fetch all the contract accounts for customers of the segment
* Households/SME.
*----------------------------------------------------------------------*
FORM fetch_contract_accounts using uc_tabname type rstable-tabname .
CONSTANTS : lc_01 TYPE mahnv_kk VALUE '01' , "01
lc_02 TYPE mahnv_kk VALUE '02' . "02
DATA : lt_fkkvkp TYPE STANDARD TABLE OF fkkvkp . "int table for FKKVKP
* All the fields of FKKVKP are selected to modify FKKVKP
* as per new dunning procedure
SELECT *
INTO TABLE lt_fkkvkp
FROM fkkvkp
WHERE mahnv EQ lc_01
OR mahnv EQ lc_02 .
IF sy-subrc EQ 0 .
PERFORM get_creditworthiness USING lt_fkkvkp
uc_tabname
lc_01
lc_02.
ENDIF. " if sy-subrc eq 0
ENDFORM. " fetch_contract_accounts
*&---------------------------------------------------------------------*
*& Form get_creditworthiness
*&---------------------------------------------------------------------*
* To get the creditworthiness value of the customer
*----------------------------------------------------------------------*
FORM get_creditworthiness USING ut_fkkvkp TYPE tt_fkkvkp
uc_tabname type rstable-tabname
uc_01 TYPE mahnv_kk
uc_02 TYPE mahnv_kk .
DATA : ls_fkkvkp TYPE fkkvkp , "work area of type fkkvkp
lv_creditwortiness TYPE bonma_kk , "creditworthiness
lv_gpart TYPE gpart_kk , "buss. part no
lt_fkkvkp TYPE tt_fkkvkp . "int table of type fkkvkp
SORT ut_fkkvkp BY gpart .
* Scan through all the contract accounts fetched above to get the
* creditworthiness
LOOP AT ut_fkkvkp INTO ls_fkkvkp .
* if the business partner number is not processed earlier
* then only fetch the creditworthiness value else use
* the value fetched earlier.This is done to avoid dupliacte
* processing of business partners
IF lv_gpart NE ls_fkkvkp-gpart .
lv_gpart = ls_fkkvkp-gpart .
CLEAR : lv_creditwortiness .
* BAPI to get the creditworthiness value of the customer
CALL FUNCTION 'BAPI_CTRACCREDITRATING_GET'
EXPORTING
buspartner = ls_fkkvkp-gpart
value_date = sy-datum
IMPORTING
value = lv_creditwortiness.
ENDIF. " if lv_gpart ne ls_fkkvkp-gpart .
* if creditworthiness value found then update it in internal table
* ut_contract_acc
IF lv_creditwortiness LE 1000
AND ls_fkkvkp-mahnv EQ uc_02.
ls_fkkvkp-mahnv = uc_01 .
* To store only the modified records
append ls_fkkvkp to lt_fkkvkp .
ELSEIF lv_creditwortiness GT 1000
AND ls_fkkvkp-mahnv EQ uc_01.
ls_fkkvkp-mahnv = uc_02 .
* To store only the modified records
append ls_fkkvkp to lt_fkkvkp .
ENDIF. " if lv_creditwortiness le 1000
CLEAR : ls_fkkvkp .
ENDLOOP. " loop at Ct_FKKVKP
* Modify the database table as per new dunning procedure
MODIFY fkkvkp FROM TABLE lt_fkkvkp .
* To unlock database table
PERFORM unlock_table using uc_tabname .
ENDFORM. " get_creditworthiness
*&---------------------------------------------------------------------*
*& Form lock_table
*&---------------------------------------------------------------------*
* This form is used to lock database table
*----------------------------------------------------------------------*
FORM lock_table .
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.
ENDFORM. " lock_table
*&---------------------------------------------------------------------*
*& Form unlock_table
*&---------------------------------------------------------------------*
* This form is used to unlock the table
*----------------------------------------------------------------------*
FORM unlock_table using uc_tabname type rstable-tabname .
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
TABNAME = uc_tabname .
ENDFORM. " unlock_table<b>Reward if usefull</b>