FORM开发

分手后的思念是犯贱 2022-09-18 02:58 67阅读 0赞

一、修改FORM级触发器

1.PRE-FORM

  1. app_window.set_window_position('CUXCRVAS', 'FIRST_WINDOW');

2.WHEN-NEW-FORM-INSTANCE

  1. FDRCSID('$Header: TEMPLATE.fmb 115.12 level:6 2013/11/05 10:00:48 pkm ship $');
  2. APP_STANDARD.EVENT('WHEN-NEW-FORM-INSTANCE');
  3. --
  4. -- app_folder.define_folder_block('template test', 'folder_block', 'prompt_block', 'stacked_canvas', 'window', 'disabled functions');
  5. -- app_folder.event('VERIFY');
  6. --
  7. cux_control.botton_control('when-new-form');
  8. 二、创建数据块 1.QFIND快添加项

设置块和项的属性:

2012032116160086.png

2012032116194890.png

2012032116204390.png

2012032116271895.png

QFIND画布

2012032116283591.png

修改块级触发器KEY-NXTBLK:

  1. :parameter.G_query_find := 'TRUE';
  2. app_find.find('CUX_CRVAL');
  3. :parameter.G_query_find := 'FALSE';

分别编写以下触发器:

2012032116310257.png

  1. app_find.clear;
  2. app_find.new('CUX_CRVAL');
  3. :parameter.G_query_find := 'TRUE';
  4. app_find.find('CUX_CRVAL');
  5. :parameter.G_query_find := 'FALSE';

三、创建CUXCRVAS块

画布CUXCRVAS效果:

2012032116371744.png

2012032116405892.png

设置块和项属性

2012032116433143.png

2012032116441524.png

2012032116482134.png

2012032119493194.png

修改ITEM级触发器WHEN_CHECKBOX_CHANGED

  1. BEGIN
  2. IF :CUX_CRVAL.ATTRIBUTE1 IS NULL THEN
  3. :CUX_CRVAL.END_DATE := NULL;
  4. app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_FALSE);
  5. app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
  6. ELSE
  7. app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_TRUE);
  8. app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_TRUE);
  9. END IF;
  10. END;

修改块级触发器:

1、QUERY_FIND

  1. NULL;
  2. APP_FIND.QUERY_FIND('CUXCRVAS','QFIND','QFIND');

2、PRE_INSERT

  1. cux_private.per_insert;

3、PRE_UPDATE

  1. cux_private.per_update;

4、PRE_DELETE

  1. cux_private.per_delete;

5、PRE_QUERY

  1. NULL;
  2. IF :Parameter.G_query_find='TRUE' THEN
  3. :CUX_CRVAL.CUSTOMER_ID:=:QFIND.CUSTOMER_ID;
  4. --:CUX_CRVAL.CUSTOMER_NUMBER:=:QFIND.CUSTOMER_NUMBER;
  5. --:CUX_CRVAL.CUSTOMER_NAME:=:QFIND.CUSTOMER_NAME;
  6. :CUX_CRVAL.STATUS:=:QFIND.STATUS;
  7. :Parameter.G_query_find:='FALSE';
  8. END IF;

6、WHEN_NEW_RECORD_INSTANCE

  1. APP_STANDARD.EVENT('WHEN-NEW-RECORD-INSTANCE');
  2. cux_control.record_control;

四、LOV设置

2012032116555332.png

2012032116563722.png

2012032116585013.png

2012032116593450.png

2012032117011595.png

2012032117012610.png

五、修改程序单元

修改APP_CUSTOM包

  1. package body app_custom is
  2. procedure close_window(wnd in varchar2) is
  3. /*
  4. This procedure is called whenever the user closes a window, as
  5. a result of the WHEN-WINDOW-CLOSED trigger firing. You are responsible
  6. for supplying unqiue code that addresses the needs of each window, such as
  7. deferring master-detail relations, or closing related windows.
  8. Other windows that will be referenced into your form rely on the default
  9. code at the beginning and end of this procedure - under no circumstances
  10. should you modify that code.
  11. */
  12. begin
  13. /*
  14. THE FOLLOWING CODE MUST NOT BE MODIFIED. It prevents windows from closing
  15. while in enter-query mode.
  16. */
  17. if (name_in('system.mode') = 'ENTER-QUERY') then
  18. app_exception.disabled;
  19. return;
  20. end if;
  21. /*
  22. YOU MUST MODIFY THE FOLLOWING CODE to account for specific behaviors of your
  23. form, including:
  24. 1. identifying the 'first window' of the form and treating
  25. a close window on that window like a close form.
  26. 2. deferring master-detail relations for detail blocks that
  27. exist in other windows.
  28. 3. closing other related windows.
  29. The default code at the end of this procedure actually closes the window.
  30. If you do that yourself in this code, issue a 'return;' at the end of
  31. your logic for your specific windows.
  32. */
  33. if (wnd = 'CUXCRVAS') then
  34. app_window.close_first_window;
  35. elsif (wnd = '<another window>') then
  36. --defer relations
  37. --close related windows
  38. null;
  39. elsif (wnd = '<yet another window>') then
  40. --defer relations
  41. --close related windows
  42. null;
  43. end if;
  44. /*
  45. THE FOLLOWING CODE MUST NOT BE MODIFIED. It ensures the cursor is not in
  46. the window that will be closed (by moving it to the previous block if
  47. needed), and actually closes the specified window.
  48. */
  49. if (wnd = get_view_property(get_item_property(:SYSTEM.CURSOR_ITEM,
  50. ITEM_CANVAS), WINDOW_NAME)) then
  51. do_key('PREVIOUS_BLOCK');
  52. end if;
  53. hide_window(wnd);
  54. end close_window;
  55. procedure open_window(wnd in varchar2) is
  56. /*
  57. This procedure should be called from any code that could result
  58. in a non-modal window being opened.
  59. */
  60. begin
  61. /*
  62. YOU MUST MODIFY THE FOLLOWING CODE to account for specific behaviors of your
  63. form, including:
  64. 1. Positioning the window to be opened
  65. 2. Resetting master-detail relations for blocks in the window
  66. 3. navigation to a block in that window
  67. */
  68. if (wnd = '<a window>') then
  69. --position the window
  70. --reset master-detail relations
  71. --navigate to a block in the window
  72. null;
  73. elsif (wnd = '<another window>') then
  74. --position the window
  75. --reset master-detail relations
  76. --navigate to a block in the window
  77. null;
  78. elsif (wnd = '<yet another window>') then
  79. --position the window
  80. --reset master-detail relations
  81. --navigate to a block in the window
  82. null;
  83. end if;
  84. end open_window;
  85. end app_custom;

编写CUX_CONTROL包

  1. PACKAGE BODY cux_control IS
  2. procedure summit is
  3. begin
  4. if :CUX_CRVAL.credit_values is null then
  5. FND_MESSAGE.SET_STRING('信用额度不能为空!');
  6. FND_MESSAGE.ERROR;
  7. RAISE Form_Trigger_Failure;
  8. elsif :CUX_CRVAL.ATTRIBUTE1 ='Y' and :CUX_CRVAL.END_DATE IS NULL then
  9. FND_MESSAGE.SET_STRING('请输入截至日期!');
  10. FND_MESSAGE.ERROR;
  11. RAISE Form_Trigger_Failure;
  12. elsif :CUX_CRVAL.ATTRIBUTE1 ='Y' and :CUX_CRVAL.credit_values = 0 then
  13. FND_MESSAGE.SET_STRING('临时信用额度不能为0!');
  14. FND_MESSAGE.ERROR;
  15. RAISE Form_Trigger_Failure;
  16. ELSE
  17. if :CUX_CRVAL.STATUS='已输入' then
  18. :CUX_CRVAL.STATUS:='处理中';
  19. if :CUX_CRVAL.ATTRIBUTE1 is null then
  20. --FND_MESSAGE.DEBUG(:CUX_CRVAL.CREDIT_ID);
  21. --FND_MESSAGE.DEBUG(:CUX_CRVAL.CUSTOMER_ID);
  22. update cux_credit_control_all a
  23. set a.STATUS='失效',a.active_flag='N',a.end_date=trunc(sysdate)
  24. where (a.credit_id!=:CUX_CRVAL.CREDIT_ID or :CUX_CRVAL.CREDIT_ID is null)
  25. and a.customer_id=:CUX_CRVAL.CUSTOMER_ID
  26. and a.group_number=:CUX_CRVAL.group_number
  27. and a.STATUS='处理中' and a.ATTRIBUTE1 is null ;
  28. commit;
  29. end if;
  30. else
  31. FND_MESSAGE.SET_STRING('当前记录不能提交!');
  32. FND_MESSAGE.ERROR;
  33. RAISE Form_Trigger_Failure;
  34. end if;
  35. END IF;
  36. /* set_block_property('CUX_CRVAL',UPDATE_ALLOWED,property_false);
  37. set_block_property('CUX_CRVAL',DELETE_ALLOWED,property_false);*/
  38. end summit;
  39. procedure approve is
  40. begin
  41. if :CUX_CRVAL.STATUS='处理中' then
  42. :CUX_CRVAL.STATUS:='生效';
  43. :CUX_CRVAL.START_DATE:=trunc(sysdate);
  44. :CUX_CRVAL.ATTRIBUTE2 := TO_CHAR(sysdate,'YYYY-MM-DD HH24:MI:SS');
  45. if :CUX_CRVAL.ATTRIBUTE1 is null then
  46. update cux_credit_control_all a
  47. set a.STATUS='失效',a.active_flag='N',a.end_date=trunc(sysdate)
  48. where a.credit_id!=:CUX_CRVAL.CREDIT_ID
  49. and a.customer_id=:CUX_CRVAL.CUSTOMER_ID
  50. and a.group_number=:CUX_CRVAL.group_number
  51. and a.STATUS='生效'
  52. and a.ATTRIBUTE1 is null ;
  53. end if;
  54. else
  55. FND_MESSAGE.SET_STRING('当前记录不能审批!');
  56. FND_MESSAGE.ERROR;
  57. RAISE Form_Trigger_Failure;
  58. end if;
  59. end approve;
  60. procedure reject is
  61. begin
  62. if :CUX_CRVAL.STATUS='处理中' then
  63. :CUX_CRVAL.STATUS:='拒绝';
  64. :CUX_CRVAL.ATTRIBUTE2 := TO_CHAR(sysdate,'YYYY-MM-DD HH24:MI:SS');
  65. else
  66. FND_MESSAGE.SET_STRING('当前记录不能拒绝!');
  67. FND_MESSAGE.ERROR;
  68. RAISE Form_Trigger_Failure;
  69. end if;
  70. end reject;
  71. procedure botton_control(p_event in varchar2) is
  72. v_user_id number;
  73. v_approve_user_id number;
  74. begin
  75. if (p_event='when-new-form') then
  76. :PARAMETER.P_USER_ID:=FND_GLOBAL.USER_ID;
  77. v_approve_user_id:=fnd_profile.value('CUX_CREDIT_APPROVE_USER');
  78. if :PARAMETER.P_USER_ID=v_approve_user_id then
  79. app_item_property.set_property('BOTTON_CONTROL.SUMMIT',ENABLED,PROPERTY_FALSE);
  80. app_item_property.set_property('BOTTON_CONTROL.APPROVE',ENABLED,PROPERTY_TRUE);
  81. app_item_property.set_property('BOTTON_CONTROL.REJECT',ENABLED,PROPERTY_TRUE);
  82. app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',INSERT_ALLOWED,PROPERTY_TRUE);
  83. app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',UPDATE_ALLOWED,PROPERTY_TRUE);
  84. else
  85. app_item_property.set_property('BOTTON_CONTROL.SUMMIT',ENABLED,PROPERTY_TRUE);
  86. app_item_property.set_property('BOTTON_CONTROL.APPROVE',ENABLED,PROPERTY_FALSE);
  87. app_item_property.set_property('BOTTON_CONTROL.REJECT',ENABLED,PROPERTY_FALSE);
  88. app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',INSERT_ALLOWED,PROPERTY_FALSE);
  89. app_item_property.set_property('CUX_CRVAL.ACTIVE_FLAG',UPDATE_ALLOWED,PROPERTY_FALSE);
  90. end if;
  91. end if;
  92. end botton_control;
  93. procedure record_control is
  94. begin
  95. if :CUX_CRVAL.STATUS='已输入' then
  96. /* app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER', ENTERABLE,PROPERTY_ON);
  97. -- app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER',UPDATE_ALLOWED,PROPERTY_TRUE);
  98. app_item_property.set_property('CUX_CRVAL.CUSTOMER_NAME',ENTERABLE,PROPERTY_TRUE);
  99. app_item_property.set_property('CUX_CRVAL.CREDIT_VALUES',ENTERABLE,PROPERTY_TRUE);
  100. --set_block_property('CUX_CRVAL',UPDATE_ALLOWED,PROPERTY_TRUE); */
  101. set_block_property('CUX_CRVAL',DELETE_ALLOWED,PROPERTY_TRUE);
  102. if :CUX_CRVAL.ATTRIBUTE1 = 'Y' then
  103. app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_TRUE);
  104. app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_TRUE);
  105. ELSE
  106. app_item_property.set_property('CUX_CRVAL.END_DATE',INSERT_ALLOWED,PROPERTY_FALSE);
  107. app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
  108. END IF;
  109. null;
  110. else
  111. --set_block_property('CUX_CRVAL',UPDATE_ALLOWED,PROPERTY_FALSE);
  112. app_item_property.set_property('CUX_CRVAL.CUSTOMER_NUMBER',UPDATE_ALLOWED,PROPERTY_FALSE);
  113. app_item_property.set_property('CUX_CRVAL.CUSTOMER_NAME',UPDATE_ALLOWED,PROPERTY_FALSE);
  114. app_item_property.set_property('CUX_CRVAL.CREDIT_VALUES',UPDATE_ALLOWED,PROPERTY_FALSE);
  115. app_item_property.set_property('CUX_CRVAL.END_DATE',UPDATE_ALLOWED,PROPERTY_FALSE);
  116. app_item_property.set_property('CUX_CRVAL.ATTRIBUTE1',UPDATE_ALLOWED,PROPERTY_FALSE);
  117. set_block_property('CUX_CRVAL',DELETE_ALLOWED,PROPERTY_FALSE);
  118. end if;
  119. end ;
  120. END cux_control;

编写CUX_EVENT包

  1. PACKAGE BODY CUX_EVENT IS
  2. PROCEDURE SUM_TRX_QTY IS
  3. BEGIN
  4. :BOTTON_CONTROL.SUM_TRX_QTY := 0;
  5. GO_BLOCK('CUX_CRVAL');
  6. first_record;
  7. LOOP
  8. if :CUX_CRVAL.STATUS='生效' and :CUX_CRVAL.ACTIVE_FLAG='Y' then
  9. :BOTTON_CONTROL.SUM_TRX_QTY := :BOTTON_CONTROL.SUM_TRX_QTY +
  10. nvl(:CUX_CRVAL.CREDIT_VALUES, 0);
  11. end if;
  12. IF :system.last_record = 'FALSE' THEN
  13. ----判断当前记录是否为最后一条
  14. next_record;
  15. ELSE
  16. EXIT;
  17. END IF;
  18. END LOOP;
  19. first_record;
  20. END SUM_TRX_QTY;
  21. END;

编写CUX_PRIVATE包

  1. PACKAGE BODY cux_private IS
  2. procedure per_insert is
  3. begin
  4. select cux_credit_control_all_s.NEXTVAL
  5. into :CUX_CRVAL.CREDIT_ID
  6. from dual;
  7. FND_STANDARD.SET_WHO;
  8. end per_insert;
  9. procedure per_update is
  10. begin
  11. /* if :CUX_CRVAL.STATUS='生效' then
  12. FND_MESSAGE.SET_STRING('当前记录不允许修改!');
  13. FND_MESSAGE.ERROR;
  14. RAISE Form_Trigger_Failure;
  15. else
  16. FND_STANDARD.SET_WHO;
  17. end if; */
  18. FND_STANDARD.SET_WHO;
  19. end per_update;
  20. procedure per_delete is
  21. begin
  22. /* if :CUX_CRVAL.STATUS='生效' then
  23. FND_MESSAGE.SET_STRING('当前记录不允许删除!');
  24. FND_MESSAGE.ERROR;
  25. RAISE Form_Trigger_Failure;
  26. end if; */
  27. null;
  28. end per_delete;
  29. END;

发表评论

表情:
评论列表 (有 0 条评论,67人围观)

还没有评论,来说两句吧...

相关阅读