Monday 16 December 2019

EGO/EFF - User Defined Attributes -- Useful tables

ego_attrs_v -- All info about User-defined attributes.

ego_fnd_dsc_flx_ctx_ext -- Metadata about Attribute Groups. This is extension to FND_DESCR_FLEX_CONTEXTS.

JPX Import command for loading VO Substiution

Steps:
1. Generate JPX file from JDev
2. Copy the file to instance middle-tier
3. Execute below command to load the JPX

java oracle.jrad.tools.xml.importer.JPXImporter $XXCUST_TOP/mds/XXVOTEST.jpx -username APPS -password $apps_pwd -dbconnection $tns_string 

Sunday 15 December 2019

Transact move order using API

Steps:
Create Move Order and approve --> Allocate Qty to move order lines --> Run API to transact material from the allocated sub inventory


DECLARE
    p_org_id             NUMBER := &p_org_id;
    p_invorg_id          NUMBER := &p_invorg_id;
    p_sales_order_num    VARCHAR2 (200) := &p_sales_order_num;
    l_api_version        NUMBER := 1.0;
    l_init_msg_list      VARCHAR2 (2) := FND_API.G_TRUE;
    l_commit             VARCHAR2 (2) := FND_API.G_FALSE;
    x_return_status      VARCHAR2 (2);
    x_msg_count          NUMBER := 0;
    x_msg_data           VARCHAR2 (20000);
    l_return_status      VARCHAR2 (2);
    l_msg_data           VARCHAR2 (255);
    l_idx                NUMBER := 0;
    l_from_date          DATE;
    l_to_date            DATE;


    -- API variable declarations
    l_move_order_type    NUMBER := 1;
    l_transaction_mode   NUMBER := 1;
    l_tmoline_tbl        INV_MOVE_ORDER_PUB.trolin_tbl_type;
    l_mold_tbl           INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
    x_mmtt_tbl           INV_MO_LINE_DETAIL_UTIL.g_mmtt_tbl_type;
    x_trolin_tbl         INV_MOVE_ORDER_PUB.trolin_tbl_type;
    l_transaction_date   DATE := SYSDATE;

    CURSOR trans_move_order_cur (cp_org_id       NUMBER,
                                 cp_inv_org_id   NUMBER,
                                 cp_order_num    VARCHAR2)
    IS
        SELECT oola.line_id,
               oola.line_number,
               wdd.released_status,
               wdd.move_order_line_id,
               oola.ship_from_org_id
          FROM oe_order_lines_all            oola,
               wsh_delivery_details          wdd,
               org_organization_definitions  mtlp,
               hr_operating_units            hou
         WHERE     1 = 1
               AND mtlp.operating_unit = cp_org_id
               AND mtlp.operating_unit = hou.organization_id
               AND hou.organization_id = cp_org_id
               AND mtlp.organization_id =
                   NVL (cp_inv_org_id, mtlp.organization_id)
               AND wdd.organization_id = mtlp.organization_id
               AND wdd.source_code = 'OE'
               AND wdd.source_line_id = oola.line_id
               AND wdd.released_status = 'S'
               AND wdd.oe_interfaced_flag = 'N'
               AND wdd.inv_interfaced_flag = 'N'
               AND oola.flow_status_code = 'AWAITING_SHIPPING'
               AND EXISTS
                       (SELECT '1'
                          FROM ont.oe_order_headers_all ooha
                         WHERE     header_id = wdd.source_header_id
                               AND ooha.order_number + 0 =
                                   NVL (cp_order_num, ooha.order_number));

    TYPE trans_move_order_tab IS TABLE OF trans_move_order_cur%ROWTYPE;

    cr_move_order_tbl    trans_move_order_tab;
BEGIN
    fnd_global.apps_initialize (fnd_global.user_id, fnd_global.resp_id, 665); -- 665-- WSH


    OPEN trans_move_order_cur (p_org_id, p_invorg_id, p_sales_order_num);

    FETCH trans_move_order_cur BULK COLLECT INTO cr_move_order_tbl;

    CLOSE trans_move_order_cur;


    DBMS_OUTPUT.put_line (
        'Orders -- move from Released to Warehouse to Ship Confirm');

    FOR i IN 1 .. cr_move_order_tbl.COUNT
    LOOP
        l_tmoline_tbl (l_idx).line_id :=
            cr_move_order_tbl (i).move_order_line_id;
        l_idx := NVL (l_tmoline_tbl.COUNT, 0) + 1;
    END LOOP;



    IF (l_tmoline_tbl.COUNT > 0)
    THEN
        INV_PICK_WAVE_PICK_CONFIRM_PUB.Pick_Confirm (
            p_api_version_number   => l_api_version,
            p_init_msg_list        => l_init_msg_list,
            p_commit               => l_commit,
            x_return_status        => x_return_status,
            x_msg_count            => x_msg_count,
            x_msg_data             => x_msg_data,
            p_move_order_type      => l_move_order_type,
            p_transaction_mode     => l_transaction_mode,
            p_trolin_tbl           => l_tmoline_tbl,
            p_mold_tbl             => l_mold_tbl,
            x_mmtt_tbl             => x_mmtt_tbl,
            x_trolin_tbl           => x_trolin_tbl,
            p_transaction_date     => l_transaction_date);

        IF (x_return_status <> FND_API.G_RET_STS_SUCCESS)
        THEN
            DBMS_OUTPUT.put_line ('Message count: ' || x_msg_count);

            IF (x_msg_count > 1)
            THEN
                FOR i IN 1 .. x_msg_count
                LOOP
                    x_msg_data :=
                        fnd_msg_pub.get (p_msg_index   => i,
                                         p_encoded     => FND_API.G_FALSE);
                    DBMS_OUTPUT.put_line ('message :' || x_msg_data);
                END LOOP;
            END IF;
        END IF;
    END IF;

    COMMIT;
EXCEPTION
    WHEN OTHERS
    THEN
        DBMS_OUTPUT.put_line (
            'Error in XX_WSH_TRANSACT_MOVE_ORDER_PKG.' || SQLERRM);
END;

Move Order Types


Value Move Order Type
1 Requisition
2 Replenishment
3 Pick Wave
4 Receipt
5 Manufacturing Component Pick
6 Put Away

Data fix to insert missing move order header

DECLARE
    CURSOR missing_mtrh_cur IS
        SELECT mtrl.header_id, --move order header id
               wdd.organization_id,
               enforce_ship_set_and_smc,
               wpb.pick_grouping_rule_id,
               wpb.name --
          FROM wsh_delivery_details     wdd,
               wsh_shipping_parameters  wsp,
               mtl_txn_request_lines    mtrl,
               wsh_picking_batches      wpb
         WHERE     line_id = move_order_line_id
               AND source_code = 'OE'
               AND wdd.move_order_line_id IS NOT NULL
               AND wsp.organization_id = wdd.organization_id
               AND wdd.batch_id = wpb.batch_id
               AND released_status = 'S'
               AND NOT EXISTS
                       (SELECT 1
                          FROM mtl_txn_request_headers mtrh
                         WHERE mtrh.header_id = mtrl.header_id);

    l_counter   NUMBER := 0;
    l_count      NUMBER;
BEGIN
    FOR missing_mtrh_rec IN missing_mtrh_cur
    LOOP
        SELECT COUNT (*)
          INTO l_count
          FROM mtl_txn_request_headers
         WHERE header_id = missing_mtrh_rec.header_id;

        IF (l_count = 0)
        THEN
            INSERT INTO mtl_txn_request_headers (created_by,
                                                 creation_date,
                                                 header_id,
                                                 header_status,
                                                 last_updated_by,
                                                 last_update_date,
                                                 last_update_login,
                                                 organization_id,
                                                 request_number,
                                                 move_order_type,
                                                 transaction_type_id,
                                                 grouping_rule_id)
                 VALUES (-1,
                         SYSDATE,
                         missing_mtrh_rec.header_id,
                         7,
                         -1,
                         SYSDATE,
                         0,
                         missing_mtrh_rec.organization_id,
                         missing_mtrh_rec.name,
                         3, -- Pick Wave
                         52, -- Sales Order Pick
                         missing_mtrh_rec.pick_grouping_rule_id);
        END IF;

        l_counter := l_counter + 1;
    END LOOP;

    DBMS_OUTPUT.put_line ('Number of Records Processed : ' || l_counter);
    COMMIT;
END;
/

Script to check for Move Order lines with missing Move Order headers

SELECT mtrl.header_id,
                   wdd.organization_id,
                   wsp.enforce_ship_set_and_smc,
                   wpb.pick_grouping_rule_id,
                   wpb.NAME
              FROM wsh_delivery_details     wdd,
                   wsh_shipping_parameters  wsp,
                   mtl_txn_request_lines    mtrl,
                   wsh_picking_batches      wpb
             WHERE     mtrl.line_id = wdd.move_order_line_id
                   AND wdd.source_code = 'OE'
                   AND wdd.move_order_line_id IS NOT NULL
                   AND wsp.organization_id = wdd.organization_id
                   AND wdd.batch_id = wpb.batch_id
                   AND wdd.released_status = 'S'
                   AND NOT EXISTS
                           (SELECT 1
                              FROM mtl_txn_request_headers mtrh
                             WHERE mtrh.header_id = mtrl.header_id);

Issues when download file with more than 2GB in Java

Use below code to download content with more than 2 GB



    long length = fileObj.length();
    if (length <= Integer.MAX_VALUE)
    {
      response.setContentLength((int)length);
    }
    else
    {
      response.addHeader("Content-Length", Long.toString(length));
    }