- OracleApps Epicenter - http://www.oracleappshub.com -

Asset Reclass Programmatically

Last article you have seen some insight functionlity for Fixed asset Reclass functionality [1] and Business need.

Majority of time whenever there is merger/acquisitions or Instance consolidation exercise reclassification plays an important role specially when you as project team not allow any new category . Mapping all assets and aligning with Parent's company existing Category is major challenge depending volume of assets. The more challenge come to IT when you did not find right fitment for Mass reclassification native screen to cater the requirement quickly thus Reclass via API's Programmatically is good options indeed.

API availability for Reclass

You can use Reclass API that uses the FA_RECLASS_PUB.DO_RECLASS procedure

You can achieve

Let take a quick look the API details and Usage part.

API Usage

Use this script :

  1.  
  2.  
  3. l_count NUMBER [3];
  4. l_return_status VARCHAR2 [4](100);
  5. l_msg_count NUMBER [3]:= 0;
  6. l_msg_data VARCHAR2 [4](4000);
  7. l_request_id NUMBER [3];
  8. reclass_err EXCEPTION [5];
  9. temp_str VARCHAR2 [4](640);
  10. i NUMBER [3] := 0;
  11. l_api_version CONSTANT [6] NUMBER [3] := 1.0;
  12. l_msg_list VARCHAR2 [4](5) := FND_API.G_FALSE;
  13. l_commit_flag VARCHAR2 [4](5) := FND_API.G_FALSE;
  14. l_validation_level VARCHAR2 [4](5) := FND_API.G_VALID_LEVEL_FULL;
  15. l_debug_flag VARCHAR2 [4](5) := FND_API.G_FALSE;
  16. l_calling_fn VARCHAR2 [4](20) := 'Reclass Script';
  17. l_trans_rec FA_API_TYPES.trans_rec_type;
  18. l_asset_hdr_rec FA_API_TYPES.asset_hdr_rec_type;
  19. l_asset_cat_rec_new FA_API_TYPES.asset_cat_rec_type;
  20. l_recl_opt_rec FA_API_TYPES.reclass_options_rec_type;
  21.  
  22.  
  23. ---- fetch and pass the asset id for asset which you want to reclassify
  24.  
  25. l_asset_id NUMBER [3] := TO_NUMBER [7](<asset_id>);
  26.  
  27. ---- fetch and pass the target category id for asset which you want to reclassify
  28.  
  29. l_category_id NUMBER [3] := TO_NUMBER [7]('<new_category_id>');
  30. -- select the options YES or NO and flag depending upon how you want to copy the DFF's
  31.  
  32. l_copy_desc_flag VARCHAR2 [4](3) := UPPER [8](SUBSTR [9]('copy_category_desc_YES_NO',1,3));
  33. l_redefault_flag VARCHAR2 [4](3) := UPPER [8](SUBSTR [9]('redef_deprn_rule_YES_NO',1,3));
  34.  
  35. BEGIN [10]
  36. DBMS_OUTPUT [11].disable;
  37. DBMS_OUTPUT [11].enable(1000000);
  38. DBMS_OUTPUT [11].put_line('------***begin*****------');
  39. fa_srvr_msg.init_server_message;
  40. fa_debug_pkg.set_debug_flag(debug_flag => 'YES');
  41. DBMS_OUTPUT [11].put_line('.');
  42.  
  43. -- Get standard who info...use APP INITIALIZATION
  44.  
  45. l_request_id := fnd_global.conc_request_id;
  46. fnd_profile.get('LOGIN_ID', l_trans_rec.who_info.last_update_login);
  47. fnd_profile.get('USER_ID', l_trans_rec.who_info.last_updated_by);
  48.  
  49. IF [12] (l_trans_rec.who_info.last_updated_by IS [13] NULL [14]) THEN [15]
  50. l_trans_rec.who_info.last_updated_by := -1;
  51. END [16] IF [12];
  52. IF [12] (l_trans_rec.who_info.last_update_login IS [13] NULL [14]) THEN [15]
  53. l_trans_rec.who_info.last_update_login := -1;
  54. END [16] IF [12];
  55.  
  56. l_trans_rec.who_info.last_update_date := SYSDATE [17];
  57. l_trans_rec.who_info.creation_date := l_trans_rec.who_info.last_update_date;
  58. l_trans_rec.who_info.created_by := l_trans_rec.who_info.last_updated_by;
  59. l_asset_hdr_rec.asset_id := l_asset_id;
  60. l_asset_cat_rec_new.category_id := l_category_id;
  61. l_recl_opt_rec.copy_cat_desc_flag := l_copy_desc_flag;
  62. l_recl_opt_rec.redefault_flag := l_redefault_flag;
  63.  
  64. DBMS_OUTPUT [11].put_line('calling FA_RECLASS_PUB.do_reclass');
  65.  
  66. FA_RECLASS_PUB.do_reclass (
  67. -- std parameters
  68. p_api_version => l_api_version,
  69. p_init_msg_list => l_msg_list,
  70. p_commit => l_commit_flag,
  71. p_validation_level => l_validation_level,
  72. p_calling_fn => l_calling_fn,
  73. x_return_status => l_return_status,
  74. x_msg_count => l_msg_count,
  75. x_msg_data => l_msg_data,
  76. -- api parameters
  77. px_trans_rec => l_trans_rec,
  78. px_asset_hdr_rec => l_asset_hdr_rec,
  79. px_asset_cat_rec_new => l_asset_cat_rec_new,
  80. p_recl_opt_rec => l_recl_opt_rec );
  81.  
  82. DBMS_OUTPUT [11].put_line('l_return_status '||l_return_status);
  83.  
  84. IF [12] l_return_status = 'E' THEN [15] l_msg_count := fnd_msg_pub.count_msg;
  85.  
  86. IF [12] (l_msg_count > 0) THEN [15]
  87.  
  88. DBMS_OUTPUT [11].put_line('l_msg_count '||to_char(l_msg_count));
  89.  
  90. temp_str := SUBSTR [9](fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE), 1, 230);
  91.  
  92. DBMS_OUTPUT [11].put_line(temp_str);
  93.  
  94. temp_str:= NULL [14];
  95.  
  96. FOR [18] I IN [19] 1..(l_msg_count -1) LOOP [20]
  97. temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
  98. DBMS_OUTPUT [11].put_line(temp_str);
  99. END [16] LOOP [20];
  100.  
  101. ELSE [21]
  102.  
  103. DBMS_OUTPUT [11].put_line('dump: NO MESSAGE !');
  104.  
  105. END [16] IF [12];
  106.  
  107. RETURN [22];
  108.  
  109. END [16] IF [12];
  110. fa_srvr_msg.add_message
  111. ( calling_fn => 'TOAD SCRIPT',
  112. name => 'FA_SHARED_END_SUCCESS',
  113. token1 => 'PROGRAM',
  114. value1 => 'FA_RECLASS_PUB.do_reclass');
  115. WHEN [23] reclass_err THEN [15]
  116. ROLLBACK [24] WORK [25];
  117. fa_srvr_msg.add_message(
  118. calling_fn => 'TOAD SCRIPT',
  119. name => 'FA_SHARED_PROGRAM_FAILED',
  120. token1 => 'PROGRAM',
  121. value1 => 'FA_RECLASS_PUB.do_reclass');
  122.  
  123. l_msg_count := fnd_msg_pub.count_msg;
  124. IF [12] (l_msg_count > 0) THEN [15]
  125. temp_str := fnd_msg_pub.get(fnd_msg_pub.G_FIRST, fnd_api.G_FALSE);
  126. DBMS_OUTPUT [11].put_line('dump: ' || temp_str);
  127. FOR [18] I IN [19] 1..(l_msg_count -1) LOOP [20]
  128. temp_str := fnd_msg_pub.get(fnd_msg_pub.G_NEXT, fnd_api.G_FALSE);
  129. DBMS_OUTPUT [11].put_line('dump: ' || temp_str);
  130. END [16] LOOP [20];
  131. ELSE [21]
  132. DBMS_OUTPUT [11].put_line('dump: NO MESSAGE !');
  133. END [16] IF [12];
  134. END [16];
  135.