Criar Ordens de Movimentações via API

Neste post irei mostrar API para criar ordens de movimentações Cabeçalho e Linha.

DECLARE
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2 (2) := FND_API.G_TRUE;
l_return_values VARCHAR2 (2) := FND_API.G_FALSE;
l_commit VARCHAR2 (2) := FND_API.G_FALSE;
x_return_status VARCHAR2 (2);
x_msg_count NUMBER := 0;
x_msg_data VARCHAR2 (255);

-- WHO columns
l_user_id NUMBER := -1;
l_resp_id NUMBER := -1;
l_application_id NUMBER := -1;
l_user_name VARCHAR2 (30) := 'MFG';
l_resp_name VARCHAR2 (50) := 'Manufacturing and Distribution Manager';
l_row_cnt NUMBER := 1;

-- API specific declarations
l_trohdr_rec INV_MOVE_ORDER_PUB.trohdr_rec_type;
l_trohdr_val_rec INV_MOVE_ORDER_PUB.trohdr_val_rec_type;
x_trohdr_rec INV_MOVE_ORDER_PUB.trohdr_rec_type;
x_trohdr_val_rec INV_MOVE_ORDER_PUB.trohdr_val_rec_type;
l_validation_flag VARCHAR2 (2) := INV_MOVE_ORDER_PUB.g_validation_yes;
l_trolin_tbl INV_MOVE_ORDER_PUB.trolin_tbl_type;
l_trolin_val_tbl INV_MOVE_ORDER_PUB.trolin_val_tbl_type;
x_trolin_tbl INV_MOVE_ORDER_PUB.trolin_tbl_type;
x_trolin_val_tbl INV_MOVE_ORDER_PUB.trolin_val_tbl_type;
l_validation_flag_1 VARCHAR2(2) := INV_MOVE_ORDER_PUB.g_validation_yes;

BEGIN

FND_GLOBAL.apps_initialize (1139, 20634, 401);

-- Initialize the variables
l_trohdr_rec.date_required := SYSDATE;
l_trohdr_rec.organization_id := 102;
l_trohdr_rec.from_subinventory_code := 'MPE';
l_trohdr_rec.to_subinventory_code := 'PAG';
l_trohdr_rec.status_date := SYSDATE;
l_trohdr_rec.header_status := INV_GLOBALS.g_to_status_preapproved; -- preApproved
l_trohdr_rec.transaction_type_id := INV_GLOBALS.g_type_transfer_order_subxfr; -- INV_GLOBALS.G_TYPE_TRANSFER_ORDER_STGXFR;
l_trohdr_rec.move_order_type := INV_GLOBALS.g_move_order_requisition; -- G_MOVE_ORDER_PICK_WAVE;
l_trohdr_rec.db_flag := FND_API.g_true;
l_trohdr_rec.operation := INV_GLOBALS.g_opr_create;
l_trohdr_rec.created_by := 1139;
l_trohdr_rec.creation_date := SYSDATE;
l_trohdr_rec.last_updated_by := 1139;
l_trohdr_rec.last_update_date := SYSDATE;

INV_MOVE_ORDER_PUB.create_move_order_header ( p_api_version_number => l_api_version,
p_init_msg_list => l_init_msg_list,
p_return_values => l_return_values,
p_commit => l_commit,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
p_trohdr_rec => l_trohdr_rec,
p_trohdr_val_rec => l_trohdr_val_rec,
x_trohdr_rec => x_trohdr_rec,
x_trohdr_val_rec => x_trohdr_val_rec,
p_validation_flag => l_validation_flag);

--- CURSOR DAS LINHAS ----- 
l_trolin_tbl(l_row_cnt).header_id := x_trohdr_rec.header_id; 
l_trolin_tbl(l_row_cnt).date_required := SYSDATE; 
l_trolin_tbl(l_row_cnt).organization_id := 102;
l_trolin_tbl(l_row_cnt).inventory_item_id := 34029;
l_trolin_tbl(l_row_cnt).from_subinventory_code := 'MPE'; 
l_trolin_tbl(l_row_cnt).to_subinventory_code := 'PAG'; 
l_trolin_tbl(l_row_cnt).quantity := 2; 
l_trolin_tbl(l_row_cnt).status_date := SYSDATE; 
l_trolin_tbl(l_row_cnt).uom_code := 'KG'; 
l_trolin_tbl(l_row_cnt).line_number := l_row_cnt; 
l_trolin_tbl(l_row_cnt).line_status := INV_Globals.g_to_status_preapproved; 
l_trolin_tbl(l_row_cnt).db_flag := FND_API.g_true; 
l_trolin_tbl(l_row_cnt).operation := INV_GLOBALS.g_opr_create; 
l_trolin_tbl(l_row_cnt).created_by := 1139; 
l_trolin_tbl(l_row_cnt).creation_date := SYSDATE; 
l_trolin_tbl(l_row_cnt).last_updated_by := 1139; 
l_trolin_tbl(l_row_cnt).last_update_date := SYSDATE; 
--- CURSOR DAS LINHAS ----- 


INV_MOVE_ORDER_PUB.Create_Move_Order_Lines( p_api_version_number => l_api_version
,p_init_msg_list => l_init_msg_list
,p_return_values => l_return_values
,p_commit => l_commit
,x_return_status => x_return_status
,x_msg_count => x_msg_count
,x_msg_data => x_msg_data
,p_trolin_tbl => l_trolin_tbl
,p_trolin_val_tbl => l_trolin_val_tbl
,x_trolin_tbl => x_trolin_tbl
,x_trolin_val_tbl => x_trolin_val_tbl
,p_validation_flag => l_validation_flag_1 );


IF (x_return_status <> FND_API.g_ret_sts_success) THEN
DBMS_OUTPUT.PUT_LINE ('Error Message :' || x_msg_data);
END IF;

IF (x_return_status = FND_API.g_ret_sts_success) THEN
DBMS_OUTPUT.PUT_LINE ('Move Order Created Successfully');
DBMS_OUTPUT.PUT_LINE ( 'Move Order Header ID : ' || x_trohdr_rec.header_id);
END IF;

EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Exception Occured :');
DBMS_OUTPUT.PUT_LINE (SQLCODE || ':' || SQLERRM);
DBMS_OUTPUT.PUT_LINE ('=======================================================');
END;

 

Sem título

Deixe uma resposta

Powered by WordPress.com. Tema: Baskerville 2 por Anders Noren

Acima ↑

%d blogueiros gostam disto: