壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5258|回复: 11

求助---AR Customer API

[复制链接]
发表于 2007/6/6 16:42:30 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
各位高人,谁有用API 导 AR Customer的文档?
发表于 2007/6/6 16:59:49 | 显示全部楼层
呵呵,AR 的user guide里有标准的客户接口表文档,上面字段的说明都比较详细。导客户是件很麻烦的事情,各家公司的需求都会相差很多,即时给你找了也不见得有多大的借鉴意义
发表于 2007/6/6 18:32:34 | 显示全部楼层
你试用一下 webadi

AR_CUSTOM_CONTRACT_API 这个接口包。

或者开发导入程序,还是用AR_CUSTOM_CONTRACT_API 这个接口包
发表于 2007/6/7 10:01:02 | 显示全部楼层
看看这个有没有帮助

[ 本帖最后由 kenny.wang 于 2007-6-7 10:02 编辑 ]

115hzapiug.pdf

4.46 MB, 下载次数: 179, 下载积分: 努力值 -5 点

发表于 2007/6/7 13:08:13 | 显示全部楼层
很不错的资料
很全面
不过创建 AR Customer  用上面的包就足够了
呵呵
 楼主| 发表于 2007/6/7 13:30:45 | 显示全部楼层
谢谢啦! 要是谁还能放一些代码,用API去创建Customer,就更好了.

万分感谢先
发表于 2007/6/7 14:23:30 | 显示全部楼层
晕 lz
你总不成想着 别人帮你把程序都写好了
放上来吧   :02526o1
发表于 2007/9/26 20:21:22 | 显示全部楼层
要导Customer了,interface真不好用,看看api的
发表于 2007/9/26 21:58:49 | 显示全部楼层
给你提供一段核心代码,请参考:

  1. PROCEDURE Import(p_User_Id IN NUMBER,
  2. p_Error_Flag OUT VARCHAR2,
  3. p_Error_Msg OUT VARCHAR2) IS
  4. Cust_Exception EXCEPTION;

  5. n_Dummy NUMBER;

  6. Vc_Error_Msg VARCHAR2(240);
  7. b_Cont_Flag BOOLEAN := TRUE;
  8. b_Cust_Header_Exist_Flag BOOLEAN;

  9. P_Cou_Code VARCHAR2(20);
  10. P_Rec_Id NUMBER;
  11. P_Rev_Id NUMBER;

  12. CURSOR Cust_Data IS
  13. SELECT t.ROWID, t. *
  14. FROM Cux.CUX_AR_CUSTOMERS_TEMP t
  15. WHERE (t.Record_Processed = 'N' AND t.Error_Flag = 'N')
  16. OR (t.Record_Processed IS NULL AND t.Error_Flag IS NULL)
  17. ORDER BY t.ROWID;

  18. Cci CUX_AR_CUSTOMERS_TEMP%ROWTYPE;

  19. v_Orig_System_Customer_Ref Ra_Customers_Interface.Orig_System_Customer_Ref%TYPE;
  20. v_Orig_System_Address_Ref Ra_Customers_Interface.Orig_System_Address_Ref%TYPE;
  21. v_Orig_System_Contact_Ref Ra_Contact_Phones_Int_All.Orig_System_Contact_Ref%TYPE;
  22. v_Orig_System_Telephone_Ref Ra_Contact_Phones_Int_All.Orig_System_Telephone_Ref%TYPE;

  23. Customer_Number Ra_Customers_Interface.CUSTOMER_NUMBER%TYPE;

  24. BEGIN

  25. /*******************************************************
  26. * loop for each row
  27. *******************************************************/
  28. FOR Cci IN Cust_Data LOOP
  29. BEGIN

  30. /*******************************************************
  31. * verify the system info
  32. *******************************************************/
  33. IF Cci.Business_Sys_Id IS NULL THEN
  34. Vc_Error_Msg := 'Bussiness_Sys_Id不能为空';
  35. RAISE Cust_Exception;
  36. END IF;

  37. IF Cci.Record_Type IS NULL THEN
  38. Vc_Error_Msg := 'Record_Type不能为空';
  39. RAISE Cust_Exception;
  40. END IF;

  41. /*******************************************************
  42. * begin to fill the columns interface table used
  43. *******************************************************/
  44. Customer_Number := Cci.Bs_Customer_Code;

  45. v_Orig_System_Customer_Ref := Cci.ORG_ID || Cci.Bs_Customer_Code;

  46. v_Orig_System_Address_Ref := Cci.Address1 || '-' ||
  47. Cci.Translated_Customer_Name || '-' ||
  48. Cci.Location;

  49. BEGIN
  50. /*******************************************************
  51. * verify Orig_system_customer_ref
  52. * one of the primary key
  53. *******************************************************/
  54. SELECT COUNT(1)
  55. INTO n_Dummy
  56. FROM Hz_Parties t
  57. WHERE t.Orig_System_Reference = v_Orig_System_Customer_Ref;

  58. IF n_Dummy > 0 THEN
  59. b_Cust_Header_Exist_Flag := TRUE;
  60. Vc_Error_Msg := 'The customer header (' ||
  61. v_Orig_System_Customer_Ref ||
  62. ') ORIG_SYSTEM_CUSTOMER_REF has already existed in the system!';
  63. RAISE Cust_Exception;
  64. ELSE
  65. b_Cust_Header_Exist_Flag := FALSE;
  66. END IF;

  67. --dbms_output.put_line(v_orig_system_customer_ref);

  68. /*******************************************************
  69. * verify customer_name
  70. * This column is required
  71. *******************************************************/
  72. IF Cci.Customer_Name IS NULL THEN
  73. Vc_Error_Msg := 'Customer_Name不能为空!';
  74. RAISE Cust_Exception;
  75. END IF;

  76. /*******************************************************
  77. * verify customer_number
  78. * This value must be unique within RA_CUSTOMERS.
  79. *******************************************************/
  80. SELECT COUNT(1)
  81. INTO n_Dummy
  82. FROM Ra_Customers t
  83. WHERE t.customer_number = Cci.Bs_Customer_Code;
  84. IF n_Dummy > 0 THEN
  85. b_Cust_Header_Exist_Flag := TRUE;
  86. Vc_Error_Msg := 'The customer header (' ||
  87. Customer_Number ||
  88. ') CUSTOMER_NUMBER has already existed in the system!' ||
  89. n_Dummy;
  90. RAISE Cust_Exception;
  91. ELSE
  92. b_Cust_Header_Exist_Flag := FALSE;
  93. END IF;
  94. END;

  95. /*******************************************************
  96. * get the county code from country description
  97. * You must enter values that have already been
  98. * defined in AR_LOCATION_VALUES if Address
  99. * Validation is set to ’Error’ and you are
  100. * calculating sales tax.
  101. * You must always enter a value for Country.
  102. *******************************************************/
  103. BEGIN

  104. SELECT TT.TERRITORY_CODE
  105. INTO P_COU_CODE
  106. FROM FND_TERRITORIES_VL TT
  107. WHERE TT.TERRITORY_SHORT_NAME = CCI.COUNTRY;
  108. --AND TT.LANGUAGE = USERENV('LANG') ;
  109. EXCEPTION
  110. WHEN OTHERS THEN
  111. Vc_Error_Msg := 'Country 字段无效!';
  112. RAISE Cust_Exception;
  113. END;

  114. /*******************************************************
  115. * get the Gl_Id_Rec code from Gl_Id_Rec
  116. *******************************************************/
  117. IF Cci.Gl_Id_Rec IS NOT NULL THEN
  118. BEGIN
  119. SELECT GLCC.CODE_COMBINATION_ID
  120. INTO P_Rec_Id
  121. FROM GL_CODE_COMBINATIONS GLCC
  122. WHERE GLCC.SEGMENT1 || '.' || GLCC.SEGMENT2 || '.' ||
  123. GLCC.SEGMENT3 || '.' || GLCC.SEGMENT4 || '.' ||
  124. GLCC.SEGMENT5 || '.' || GLCC.SEGMENT6 || '.' ||
  125. GLCC.SEGMENT7 || '.' || GLCC.SEGMENT8 = Cci.Gl_Id_Rec;
  126. EXCEPTION
  127. WHEN OTHERS THEN
  128. Vc_Error_Msg := 'Gl_Id_Rec 字段无效!';
  129. RAISE Cust_Exception;
  130. END;
  131. END IF;

  132. /*******************************************************
  133. * get the Gl_Id_Rev code from Gl_Id_Rev
  134. *******************************************************/
  135. IF Cci.Gl_Id_Rev IS NOT NULL THEN
  136. BEGIN
  137. SELECT GLCC.CODE_COMBINATION_ID
  138. INTO P_Rev_Id
  139. FROM GL_CODE_COMBINATIONS GLCC
  140. WHERE GLCC.SEGMENT1 || '.' || GLCC.SEGMENT2 || '.' ||
  141. GLCC.SEGMENT3 || '.' || GLCC.SEGMENT4 || '.' ||
  142. GLCC.SEGMENT5 || '.' || GLCC.SEGMENT6 || '.' ||
  143. GLCC.SEGMENT7 || '.' || GLCC.SEGMENT8 = Cci.Gl_Id_Rev;
  144. EXCEPTION
  145. WHEN OTHERS THEN
  146. Vc_Error_Msg := 'Gl_Id_Rev 字段无效!';
  147. RAISE Cust_Exception;
  148. END;
  149. END IF;

  150. /*******************************************************
  151. * insert telephone and fax records when
  152. * contract_last_name is not null, that is,
  153. * there must be a contract user
  154. *******************************************************/
  155. v_Orig_System_Contact_Ref := NULL;
  156. v_Orig_System_Telephone_Ref := NULL;

  157. IF Cci.Contact_Last_Name IS NOT NULL THEN
  158. BEGIN
  159. b_Cont_Flag := TRUE;
  160. v_Orig_System_Contact_Ref := v_Orig_System_Customer_Ref || '-' ||
  161. Cci.Contact_Last_Name;

  162. IF Cci.Telephone IS NOT NULL THEN
  163. v_Orig_System_Telephone_Ref := v_Orig_System_Contact_Ref || '-' ||
  164. Cci.Telephone || '-' || 'GEN';

  165. /*******************************************************
  166. * insert records --telephone
  167. *******************************************************/
  168. INSERT INTO Ra_Contact_Phones_Int_All
  169. (Orig_System_Customer_Ref,
  170. Orig_System_Contact_Ref,
  171. Orig_System_Telephone_Ref,
  172. Insert_Update_Flag,
  173. Contact_Last_Name,
  174. CONTACT_JOB_TITLE,
  175. Telephone,
  176. Telephone_Type,
  177. INTERFACE_STATUS,
  178. Org_Id,
  179. Email_Address,
  180. Creation_Date,
  181. Created_By,
  182. Last_Update_Date,
  183. Last_Updated_By)
  184. VALUES
  185. (v_Orig_System_Customer_Ref,
  186. v_Orig_System_Contact_Ref,
  187. v_Orig_System_Telephone_Ref,
  188. 'I',
  189. Cci.Contact_Last_Name,
  190. 'SOC', --称谓
  191. Cci.Telephone,
  192. 'GEN', --select ar_lookups.lookup_code, lookup_type
  193. --from ar_lookups
  194. --where lookup_type='COMMUNICATION_TYPE'
  195. 'A',
  196. Cci.Org_Id,
  197. Cci.e_Mail,
  198. SYSDATE,
  199. p_User_Id,
  200. SYSDATE,
  201. p_User_Id);
  202. END IF; --cci.telephone IS NOT NULL

  203. IF Cci.Fax IS NOT NULL THEN
  204. v_Orig_System_Telephone_Ref := v_Orig_System_Contact_Ref || '-' ||
  205. Cci.Fax || '-' || 'FAX';

  206. /*******************************************************
  207. * insert records --fax
  208. *******************************************************/
  209. INSERT INTO Ra_Contact_Phones_Int_All
  210. (Orig_System_Customer_Ref,
  211. Orig_System_Contact_Ref,
  212. Orig_System_Telephone_Ref,
  213. Insert_Update_Flag,
  214. Contact_Last_Name,
  215. CONTACT_JOB_TITLE,
  216. Telephone,
  217. Telephone_Type,
  218. Org_Id,
  219. Creation_Date,
  220. Created_By,
  221. Last_Update_Date,
  222. Last_Updated_By)
  223. VALUES
  224. (v_Orig_System_Customer_Ref,
  225. v_Orig_System_Contact_Ref,
  226. v_Orig_System_Telephone_Ref,
  227. 'I',
  228. Cci.Contact_Last_Name,
  229. 'SOC', --称谓
  230. Cci.Fax,
  231. 'FAX', --select ar_lookups.lookup_code, lookup_type
  232. --from ar_lookups
  233. --where lookup_type='COMMUNICATION_TYPE'
  234. Cci.Org_Id,
  235. SYSDATE,
  236. p_User_Id,
  237. SYSDATE,
  238. p_User_Id);
  239. END IF; --cci.FAX IS NOT NULL

  240. EXCEPTION
  241. WHEN OTHERS THEN
  242. b_Cont_Flag := FALSE;
  243. END; -- of cci.contact_last_name IS NOT NULL
  244. END IF;

  245. /************************************************************
  246. * insert records if previous telephone insert no error occurs
  247. ************************************************************/
  248. IF b_Cont_Flag THEN
  249. BEGIN
  250. INSERT INTO Ra_Customers_Interface_ALL
  251. (Orig_System_Customer_Ref,
  252. Site_Use_Code,
  253. Insert_Update_Flag,
  254. Customer_Name,
  255. Customer_Number,
  256. Customer_Status,
  257. Customer_Name_Phonetic,
  258. Org_Id, -- user info
  259. Location,
  260. Address1,
  261. Address2,
  262. Address3,
  263. Country,
  264. Province,
  265. City,
  266. Postal_Code, -- site info
  267. Customer_Attribute1,
  268. Customer_Attribute2,
  269. Customer_Attribute3, -- contract info
  270. Gl_Id_Rec,
  271. Gl_Id_Rev,
  272. Site_Use_Attribute1,
  273. Site_Use_Attribute2,
  274. Address_Attribute5, -- credit info
  275. Creation_Date,
  276. Created_By,
  277. Last_Update_Date,
  278. Last_Updated_By, -- insert info
  279. ORIG_SYSTEM_ADDRESS_REF,
  280. PRIMARY_SITE_USE_FLAG --在插入地址时必须输入 PRIMARY_SITE_USE_FLAG
  281. )
  282. VALUES
  283. (v_Orig_System_Customer_Ref,
  284. 'BILL_TO', --select AR_LOOKUPS.LOOKUP_CODE
  285. --from ar_lookups
  286. --where LOOKUP_TYPE = 'SITE_USE_CODE'
  287. 'I',
  288. Cci.Customer_Name,
  289. Cci.Bs_Customer_Code,
  290. 'A', --'A':Active,'D':Deleted,'I':Inactive
  291. Cci.Translated_Customer_Name,
  292. Cci.Org_Id,
  293. Cci.Location,
  294. Cci.Location,
  295. Cci.Address1,
  296. Cci.Address2,
  297. P_Cou_Code, --Country,
  298. Cci.Province,
  299. Cci.City,
  300. Cci.Postal_Code,
  301. Cci.Customer_Attribute1,
  302. Cci.Customer_Attribute4,
  303. Cci.Customer_Attribute3,
  304. P_Rec_Id, --Gl_Id_Rec,
  305. P_Rev_Id, --Gl_Id_Rev,
  306. Cci.Location1,
  307. Cci.Site_Use_Attribute2,
  308. Cci.Address_Attribute5,
  309. SYSDATE,
  310. p_User_Id,
  311. SYSDATE,
  312. p_User_Id,
  313. v_Orig_System_Address_Ref,
  314. 'Y');

  315. -- 一个客户头只需要一条Profile记录
  316. SELECT COUNT(1)
  317. INTO n_Dummy
  318. FROM Ra_Customer_Profiles_Int_All Cpi
  319. WHERE Cpi.Orig_System_Customer_Ref =
  320. v_Orig_System_Customer_Ref
  321. AND Cpi.Orig_System_Address_Ref IS NULL
  322. AND Cpi.Interface_Status IS NULL;
  323. --dbms_output.put_line(n_Dummy);

  324. IF n_Dummy = 0 AND b_Cust_Header_Exist_Flag = FALSE THEN
  325. INSERT INTO Ra_Customer_Profiles_Int_All
  326. (Orig_System_Customer_Ref,
  327. Insert_Update_Flag,
  328. Customer_Profile_Class_Name,
  329. Credit_Hold,
  330. Last_Updated_By,
  331. Last_Update_Date,
  332. Created_By,
  333. Creation_Date,
  334. Org_Id)
  335. VALUES
  336. (v_Orig_System_Customer_Ref,
  337. 'I',
  338. 'DEFAULT', --select Name
  339. --from ar_customer_profile_classes
  340. --where status='A'
  341. 'N', -- 'Y' or 'N'
  342. p_User_Id,
  343. SYSDATE,
  344. p_User_Id,
  345. SYSDATE,
  346. Cci.Org_Id);
  347. END IF;

  348. EXCEPTION
  349. WHEN OTHERS THEN
  350. p_Error_Flag := 'Y';
  351. p_Error_Msg := 'SQL error! ' || SQLCODE || SQLERRM;
  352. Vc_Error_Msg := p_Error_Msg;
  353. RAISE Cust_Exception;
  354. --RETURN;
  355. END;

  356. /*******************************************************
  357. * Update record status success
  358. *******************************************************/
  359. UPDATE CUX_AR_CUSTOMERS_TEMP
  360. SET Record_Processed = 'Y', Error_Flag = 'N'
  361. WHERE ROWID = Cci.ROWID;
  362. ELSE
  363. /*******************************************************
  364. * Update record status error
  365. *******************************************************/
  366. UPDATE CUX_AR_CUSTOMERS_TEMP
  367. SET Record_Processed = 'Y',
  368. Error_Flag = 'Y',
  369. Error_Message = 'Contact record insert fails'
  370. WHERE ROWID = Cci.ROWID;
  371. END IF;

  372. EXCEPTION
  373. WHEN Cust_Exception THEN
  374. --Dbms_Output.Put_Line('Cust import error:' || Vc_Error_Msg);
  375. UPDATE CUX_AR_CUSTOMERS_TEMP
  376. SET Record_Processed = 'Y',
  377. Error_Flag = 'Y',
  378. Error_Message = Vc_Error_Msg
  379. WHERE ROWID = Cci.ROWID;

  380. END;
  381. /*******************************************************
  382. * Commit this customer
  383. *******************************************************/
  384. COMMIT;

  385. END LOOP; -- FOR cci IN cust_data LOOP
  386. /*******************************************************
  387. * update procedure status if no errors
  388. *******************************************************/
  389. p_Error_Flag := 'N';
  390. p_Error_Msg := NULL;

  391. END Import;
复制代码
发表于 2007/10/5 10:05:49 | 显示全部楼层
!:handshake !
发表于 2008/12/15 21:26:25 | 显示全部楼层
四海兄真是很热心阿!大力支持一下。
发表于 2011/1/14 16:55:42 | 显示全部楼层
到不错,想想自己怎么用吧!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 18:18 , Processed in 0.016236 second(s), 15 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表