Friday, January 2, 2009

ITEM VALIDNS IN PO_LINES BLOCK(CUSTOM.pll)


Item validation in PO_LINES block using custom.pll

Question: form_name = 'POXPOEPO'
block_name = 'PO_LINES' in purchase orders form..
I have a PO Lines form for purchase orders, There in the ITEMS tabbed form, The block name for ITEMS is PO_LINES, you can see items like NUM,TYPE,ITEM,REV,CATEGORY AND etc.. Suppose user enters a new record, The REV field should be validated against ITEM field when user clicks the save button on the top. ( validaton is REV field should not be null when item field is filled up)
Can you help me on this issue??
I am little confused about what trigger I am supposed to use in the custom.pll, When I use "event_name = 'WHEN_VALIDATE_RECORD'" , this is not getting fired.I am not sure about whether PRE_COMMIT event would be appropriate one for this kinda validation.. The following I have written in custom.pll
--item_revision check PO_ITEM_REVISION_CHECK in PO_FORM
procedure po_item_revision_check is
l_error_message varchar2(150);
l_item_number number;
l_ship_to_org_id number;
l_item_revision varchar2(3);
l_revision_code number;
BEGIN
IF (form_name = 'POXPOEPO') AND (block_name = 'PO_LINES') THEN
-- IF (event_name = 'WHEN_VALIDATE_RECORD') THEN
IF (event_name = 'PRE_COMMIT') THEN
l_item_number := name_in('PO_LINES.ITEM_NUMBER');
l_item_revision := name_in('PO_LINES.ITEM_REVISION');
GO_BLOCK('PO_HEADERS');
l_ship_to_org_id := name_in('PO_HEADERS.SHIP_TO_ORG_ID'); IF (l_item_number IS NOT NULL) THEN
SELECT MSI.REVISION_QTY_CONTROL_CODE
INTO l_revision_code FROM MTL_SYSTEM_ITEMS MSI WHERE MSI.SEGMENT1 = l_item_number
AND MSI.ORGANIZATION_ID = l_ship_to_org_id; FND_MESSAGE.SET_STRING('Item Number: 'l_item_number' Revision Code: 'l_revision_code);
FND_MESSAGE.SHOW;
IF (l_revision_code = 2 AND l_item_revision IS NULL) THEN FND_MESSAGE.SET_STRING('Please enter Item Revision Number'); FND_MESSAGE.SHOW;
raise form_trigger_failure;
END IF;
END IF;
END IF;
END IF;
EXCEPTION
when others then
l_error_message := SUBSTR(SQLERRM,1,140);
COPY (l_error_message,'PO_LINES.ATTRIBUTE15'); END po_item_revision_check;

No comments:

View My Stats