在开发的时候发现这样一个问题,当切换不同BLOCK的时候弹出需要保存的窗口,于是想在切换record的时候,自动commit一下,结果发现很多触发器都不允许commit_form的函数.于是就有了两个思路:
1.利用KEY-NEXT-ITEM
Declare
l_LINE_record Number;
l_MID_record Number;
l_MEND_record Number;
Begin
If :MEND.MEND_SCORE Is Not Null Then
:PARAMETER.CURRENT_KEY_MODE := 'KEY-NEXT-ITEM';
APP_CUSTOM.open_window('LINES');
Go_Block('MID');
l_MID_record := :MID.LINE_NUMBER;
:PARAMETER.CUR_MID_REC := l_MID_record+1;
l_MID_record := :PARAMETER.CUR_MID_REC;
if :PARAMETER.CUR_MID_REC > :MID.MAX_LINE_NUMBER THEN
FND_MESSAGE.SET_STRING('该项已完成评价!');
FND_MESSAGE.HINT;
ELSE NULL;
END IF;
Go_record(l_MID_record);
clear_message;
Go_Block('MEND');
GO_ITEM('MEND.MEND_SCORE');
:PARAMETER.CURRENT_KEY_MODE := 'WHEN-VALIDATE-ITEM';
End If;
End;
在item的WHEN-VALIDATE-ITEM加入
Begin
---当有变更,而且CURRENT_KEY_MODE(输入之后的导航类型)不是KEY-NEXT-ITEM的时候,必须用tab按键或者enter导航!
--FND_MESSAGE.DEBUG('WHEN-VALIDATE-ITEM1');
IF :MEND.MEND_SCORE IS NOT NULL AND NVL(:PARAMETER.CURRENT_KEY_MODE,'WHEN-VALIDATE-ITEM') <> 'KEY-NEXT-ITEM' THEN
FND_MESSAGE.SET_STRING('请注意:该栏位输入之后,请按Tab按键或者Enter按键导航!');
FND_MESSAGE.HINT;
--RAISE FORM_TRIGGER_FAILURE;---禁止用户用鼠标点击导航!
END IF;
--FND_MESSAGE.DEBUG('WHEN-VALIDATE-ITEM2');
End;
代码这里可能存在一点问题,依据自己的需要进行修改.
2.利用POST-RECORD
这里利用函数:
/*后来直接在post-record中写ddl语句,
如果record_status是INSERT或者CHANGED就触发,
然后form_ddl('commit');再把record_status设为query,就完成了自动保存*/
declare CURSOR row_id IS SELECT rowid FROM CUX_HRPE_MEND_T WHERE MEND_ID = :MEND.MEND_ID; BEGIN if GET_RECORD_PROPERTY(:SYSTEM.CURSOR_RECORD,'MEND',Status ) = 'INSERT' THEN --MEND_DATA.LOCK_ROW; --FND_MESSAGE.DEBUG('插入'); IF :LINES.LINE_ID IS NULL THEN SELECT CUX_HRPE_LINES_t_S.NEXTVAL INTO :LINES.LINE_ID FROM SYS.DUAL; :MEND.LINE_ID := :LINES.LINE_ID; END IF; IF :MID.MID_ID IS NULL THEN SELECT CUX_HRPE_MID_t_S.NEXTVAL INTO :MID.MID_ID FROM SYS.DUAL; :MEND.MID_ID := :MID.MID_ID; END IF; IF :MEND.MEND_ID IS NULL THEN SELECT CUX_HRPE_MEND_T_S.NEXTVAL INTO :MEND.MEND_ID FROM SYS.DUAL; END IF; fnd_standard.set_who; INSERT INTO CUX_HRPE_MEND_T ( MEND_ID, MID_ID, LINE_ID, HEADER_ID, MEND_ORGANIZATION_ID, MEND_PERSON_ID, MEND_SCORE, MEND_VALUE, MEND_CAUSE, MEND_DATE, MEND_SUBMIT_FLAG, CREATED_BY, CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE, LAST_UPDATE_LOGIN, ATTRIBUTE_CATEGORY, ATTRIBUTE1, ATTRIBUTE2, ATTRIBUTE3, ATTRIBUTE4, ATTRIBUTE5, PEOPLE_COUNT, SCD_PERCENT) VALUES ( :MEND.MEND_ID, :MEND.MID_ID, :MEND.LINE_ID, :MEND.HEADER_ID, :MEND.MEND_ORGANIZATION_ID, :MEND.MEND_PERSON_ID, :MEND.MEND_SCORE, :MEND.MEND_VALUE, :MEND.MEND_CAUSE, :MEND.MEND_DATE, :MEND.MEND_SUBMIT_FLAG, :MEND.CREATED_BY, :MEND.CREATION_DATE, :MEND.LAST_UPDATED_BY, :MEND.LAST_UPDATE_DATE, :MEND.LAST_UPDATE_LOGIN, :MEND.ATTRIBUTE_CATEGORY, :MEND.ATTRIBUTE1, :MEND.ATTRIBUTE2, :MEND.ATTRIBUTE3, :MEND.ATTRIBUTE4, :MEND.ATTRIBUTE5, :MEND.PEOPLE_COUNT, :MEND.SCD_PERCENT); OPEN row_id; FETCH row_id INTO :MEND.row_id; IF (row_id%NOTFOUND) THEN CLOSE row_id; RAISE NO_DATA_FOUND; END IF; CLOSE row_id; forms_ddl('COMMIT'); set_record_property(:system.trigger_record,:system.trigger_block, STATUS,QUERY_STATUS); ELSIF GET_RECORD_PROPERTY(:SYSTEM.CURSOR_RECORD,'MEND',Status ) = 'CHANGED' THEN IF :MEND.MEND_ID IS NOT NULL THEN fnd_standard.set_who; UPDATE CUX_HRPE_MEND_T SET MEND_ID = :MEND.MEND_ID, MID_ID = :MEND.MID_ID, LINE_ID = :MEND.LINE_ID, HEADER_ID = :MEND.HEADER_ID, MEND_ORGANIZATION_ID = :MEND.MEND_ORGANIZATION_ID, MEND_PERSON_ID = :MEND.MEND_PERSON_ID, MEND_SCORE = :MEND.MEND_SCORE, MEND_VALUE = :MEND.MEND_VALUE, MEND_CAUSE = :MEND.MEND_CAUSE, MEND_DATE = :MEND.MEND_DATE, MEND_SUBMIT_FLAG = :MEND.MEND_SUBMIT_FLAG, CREATED_BY = :MEND.CREATED_BY, CREATION_DATE = :MEND.CREATION_DATE, LAST_UPDATED_BY = :MEND.LAST_UPDATED_BY, LAST_UPDATE_DATE = :MEND.LAST_UPDATE_DATE, LAST_UPDATE_LOGIN = :MEND.LAST_UPDATE_LOGIN, ATTRIBUTE_CATEGORY = :MEND.ATTRIBUTE_CATEGORY, ATTRIBUTE1 = :MEND.ATTRIBUTE1, ATTRIBUTE2 = :MEND.ATTRIBUTE2, ATTRIBUTE3 = :MEND.ATTRIBUTE3, ATTRIBUTE4 = :MEND.ATTRIBUTE4, ATTRIBUTE5 = :MEND.ATTRIBUTE5, PEOPLE_COUNT = :MEND.PEOPLE_COUNT, SCD_PERCENT = :MEND.SCD_PERCENT WHERE ROWID = :MEND.row_id; IF (SQL%NOTFOUND) THEN RAISE NO_DATA_FOUND; END IF; forms_ddl('COMMIT'); set_record_property(:system.trigger_record,:system.trigger_block, STATUS,QUERY_STATUS); else FND_MESSAGE.DEBUG('UPDATE插change的时候没有mendid'); END IF; else null; end if; END;