最近研究了一下 Pick Release 的做法, 總覺得, 標準畫面上有很多設定跟功能可以選擇, 為什麼用 API 就不行呢? 原來有新的做法呢!

1. WSH_DELIVERIES_PUB.DELIVERY_ACTION

這是從 11i 用到現在的, 功能不多, 如果只是要用來產生 Move Order 然後等等再去 Transact 那 OK, 因為它連 Pick Release Rule 都沒辦法指定, 但是可以指定 Ship Confirm Rule... 還有如果你的需求是要"馬上"得到結果, 那這個 API 也不沒辦法做到, 你可以把它視為標準畫面中按下 "Concurrent".

 

2. WSH_PICK_LIST.RELEASE_BATCH_SRS

這個是參考標準功能 "Release Sales Order SRS" 所使用的 Package, 顯而易見地, 它能夠讓你指定已經設好的 Pick Release Rule 以及 Ship Confirm Rule. 但也是要等 Concurrent 跑完才會有結果.

 

3. WSH_PICKING_BATCHES_PUB

看名字就知道, 這是專門給 Pick Release 用的 API 阿~~ 也不用太多解釋, 標準畫面上有的它都有, 你在標準畫面怎麼用, 它通通沒問題 :D

--== Pick release ==========
FND_FILE.PUT_LINE (FND_FILE.LOG, '** Calling WSH_DELIVERIS_PUB to Perform Pick Release of SO **');
--
L_BATCH_INFO_REC.BACKORDERS_ONLY_FLAG       := 'I'; /* E: Unrelease, O: Backordered, I: All, M: Replenishment Completed */
L_BATCH_INFO_REC.EXISTING_RSVS_ONLY_FLAG    := 'Y'; --'N';
--L_BATCH_INFO_REC.CUSTOMER_ID                := K.SOLD_TO_ORG_ID;
L_BATCH_INFO_REC.ORDER_HEADER_ID            := K.HEADER_ID;
--L_BATCH_INFO_REC.DELIVERY_ID                := P_DELIVERY_ID;
--L_BATCH_INFO_REC.DELIVERY_DETAIL_ID         := P_DETAIL_ID;
L_BATCH_INFO_REC.FROM_SCHEDULED_SHIP_DATE   := NULL;
L_BATCH_INFO_REC.ORGANIZATION_ID            := K.ORG_ID;
L_BATCH_INFO_REC.INCLUDE_PLANNED_LINES      := 'N';
L_BATCH_INFO_REC.AUTOCREATE_DELIVERY_FLAG   := 'Y';
L_BATCH_INFO_REC.AUTODETAIL_PR_FLAG         := 'Y';
L_BATCH_INFO_REC.ALLOCATION_METHOD          := 'I'; /* I: Inventory Only */
L_BATCH_INFO_REC.PICK_FROM_SUBINVENTORY     := J.SUBINVENTORY;
L_BATCH_INFO_REC.PICK_FROM_LOCATOR_ID       := V_LOCATOR_ID;
L_BATCH_INFO_REC.DEFAULT_STAGE_SUBINVENTORY := 'STG';
L_BATCH_INFO_REC.DEFAULT_STAGE_LOCATOR_ID   := NULL;
L_BATCH_INFO_REC.AUTO_PICK_CONFIRM_FLAG     := 'Y';
L_BATCH_INFO_REC.AUTOPACK_FLAG              := 'N';
L_BATCH_INFO_REC.PICK_GROUPING_RULE_NAME    := 'Default: Order Number';
L_BATCH_INFO_REC.PICK_SEQUENCE_RULE_NAME    := 'Default: Order Number';
L_BATCH_INFO_REC.SHIP_CONFIRM_RULE_NAME     := 'TEST ISO Ship Confirm'; --FIX ME
L_BATCH_INFO_REC.ACTUAL_DEPARTURE_DATE      := SYSDATE;

L_BATCH_PREFIX := NULL;
--
WSH_PICKING_BATCHES_PUB.CREATE_BATCH (
P_API_VERSION   => 1.0
, P_INIT_MSG_LIST => FND_API.G_TRUE
, P_COMMIT        => FND_API.G_TRUE
, X_RETURN_STATUS => L_RETURN_STATUS
, X_MSG_COUNT     => L_MSG_COUNT
, X_MSG_DATA      => L_MSG_DATA
, P_RULE_ID       => NULL
, P_RULE_NAME     => NULL
, P_BATCH_REC     => L_BATCH_INFO_REC
, P_BATCH_PREFIX  => L_BATCH_PREFIX
, X_BATCH_ID      => P_NEW_BATCH_ID
);
--
IF L_RETURN_STATUS = 'S' THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'VVV Pick Release Batch Got Created Sucessfully: ' || P_NEW_BATCH_ID || ' VVV');
ELSE
V_ERROR_FLAG := 1;
V_ERROR_MSG := V_ERROR_MSG || 'XXXXX Failed to Create Pick Release Batch XXXXX';
--
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Message count ' || L_MSG_COUNT);

IF L_MSG_COUNT = 1 THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'L_MSG_DATA ' || L_MSG_DATA);
ELSIF L_MSG_COUNT > 1 THEN
P_COUNT := 0;

LOOP
P_COUNT := P_COUNT + 1;
L_MSG_DATA := FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT, FND_API.G_FALSE);

IF L_MSG_DATA IS NULL THEN
  EXIT;
END IF;

FND_FILE.PUT_LINE(FND_FILE.LOG, 'Message ' || P_COUNT || ': ' || L_MSG_DATA);
END LOOP;
END IF;
END IF;
--
WSH_PICKING_BATCHES_PUB.RELEASE_BATCH(
P_API_VERSION   => 1.0
, P_INIT_MSG_LIST => FND_API.G_TRUE
, P_COMMIT        => FND_API.G_TRUE
, X_RETURN_STATUS => L_RETURN_STATUS
, X_MSG_COUNT     => L_MSG_COUNT
, X_MSG_DATA      => L_MSG_DATA
, P_BATCH_ID      => P_NEW_BATCH_ID
, P_BATCH_NAME    => NULL
, P_LOG_LEVEL     => 1
, P_RELEASE_MODE  => 'ONLINE' -- (ONLINE or CONCURRENT)
, X_REQUEST_ID    => L_REQUEST_ID
);

IF L_RETURN_STATUS = 'S' THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'VVV Pick Selection List Generation ' || L_REQUEST_ID || ' VVV');
ELSIF L_RETURN_STATUS = 'W' THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'XXXXX Warning to Pick Release ' || P_NEW_BATCH_ID || ' XXXXX');
ELSE
V_ERROR_FLAG := 1;
V_ERROR_MSG := V_ERROR_MSG || 'XXXXX Failed to Pick Release ' || P_NEW_BATCH_ID || ' XXXXX';
V_ERROR_MSG := V_ERROR_MSG || 'XXXXX L_RETURN_STATUS = ' || L_RETURN_STATUS || ' XXXXX';
--
FND_FILE.PUT_LINE(FND_FILE.LOG, 'Message count ' || L_MSG_COUNT);

IF L_MSG_COUNT = 1 THEN
FND_FILE.PUT_LINE(FND_FILE.LOG, 'L_MSG_DATA ' || L_MSG_DATA);
ELSIF L_MSG_COUNT > 1 THEN
LOOP
P_COUNT := P_COUNT + 1;
L_MSG_DATA := FND_MSG_PUB.GET(FND_MSG_PUB.G_NEXT, FND_API.G_FALSE);

IF L_MSG_DATA IS NULL THEN
  EXIT;
END IF;

FND_FILE.PUT_LINE(FND_FILE.LOG, 'Message ' || P_COUNT || ' ==> ' || L_MSG_DATA);
END LOOP;
END IF;
END IF;
創作者介紹
創作者 Aloz 的頭像
Aloz

Aloz 的 Oracle ERP 天地

Aloz 發表在 痞客邦 留言(0) 人氣()