Introduction:
Work request basically is a request for maintenance on an asset and report any issues that may happen with an asset. A work request requires approval before it is generated into a Work Order.
Goal:
Update a work request using wip_eam_workrequest_pub.work_request_import API
Forms Or Pages:
Example:
API to update work request in oracle apps
API IN/OUT Parameters :
— IN p_api_version IN NUMBER Required
— p_init_msg_list IN VARCHAR2 Optional
— Default = FND_API.G_FALSE
— p_commit IN VARCHAR2 Optional
— Default = FND_API.G_FALSE
— p_validation_level IN NUMBER Optional
— Default = FND_API.G_VALID_LEVEL_FULL
— p_work_request_record_type IN record
— OUT x_return_status OUT VARCHAR2(1)
— x_msg_count OUT NUMBER
— x_msg_data OUT VARCHAR2(2000)
API Parameters clarifications:
- @param p_api_version Version of the API
- @param p_init_msg_list Flag to indicate initialization of message list
- @param p_commit Flag to indicate whether API should commit changes
- @param p_validation_level Validation Level of the API
- @param x_return_status Return status of the procedure call
- @param x_msg_count Count of the return messages that API returns
- @param x_msg_data The collection of the messages.
- @param p_mode The flag indicating the operation is CREATE or UPDATE
- @param p_work_request_rec This is a PL QL record type, it is a ROWTYPE of WIP_EAM_WORK_REQUESTS table
- @param p_request_log This is a reqest log for the current work request, if this is null, it is same as the work request description
- @param p_user_id The user who creates / updates the work request
- @param x_work_request_id This is the unique identifier of newly created work request record.
- @return Returns the unique identifier of newly created record and status of the procedure call as well as the return messages.
API Calling example:
DECLARE
p_api_version NUMBER;
p_init_msg_list VARCHAR2 (32767);
p_commit VARCHAR2 (32767);
p_validation_level NUMBER;
p_mode VARCHAR2 (32767);
p_work_request_rec wip_eam_work_requests%ROWTYPE; --wip_eam_workrequest_pub.wip_eam_work_requests%ROWTYPE;
p_request_log VARCHAR2 (32767);
p_user_id NUMBER;
x_work_request_id NUMBER;
x_return_status VARCHAR2 (32767);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (32767);
BEGIN
p_api_version := 1.0;
p_init_msg_list := fnd_api.g_false;
p_commit := fnd_api.g_true;
p_validation_level := fnd_api.g_valid_level_full;
p_mode := 'UPDATE';
p_work_request_rec.work_request_id := 25224;
p_work_request_rec.work_request_priority_id := 1;
p_work_request_rec.organization_id := 3159;
p_request_log := NULL;
p_user_id := NULL;
x_work_request_id := NULL;
x_return_status := NULL;
x_msg_count := NULL;
x_msg_data := NULL;
wip_eam_workrequest_pub.work_request_import (p_api_version
,p_init_msg_list
,p_commit
,p_validation_level
,p_mode
,p_work_request_rec
,p_request_log
,p_user_id
,x_work_request_id
,x_return_status
,x_msg_count
,x_msg_data);
--
--
IF (x_return_status = 'S') THEN
--
dbms_output.put_line ('***************************');
dbms_output.put_line ('Output information ....');
dbms_output.put_line ('Work Request Updated Successfully ....');
dbms_output.put_line ('x_work_request_id: ' || x_work_request_id);
dbms_output.put_line ('x_return_status: ' || x_return_status);
dbms_output.put_line ('***************************');
--
COMMIT;
--
ELSIF (x_return_status IN ('E', 'U')) THEN
--
dbms_output.put_line ('***************************');
dbms_output.put_line ('Error informations ....');
FOR i IN 1 .. (x_msg_count)
LOOP
x_msg_data := substr (fnd_msg_pub.get (fnd_msg_pub.g_next, fnd_api.g_false), 1, 250);
dbms_output.put_line (x_msg_data);
END LOOP;
--
dbms_output.put_line ('***************************');
--
END IF;
--
END;
Final Result:
Hope this may help.