Monday 12 October 2015

ERROR in "Material cost transaction worker" Request - The inter-organization transfer transaction is from and to the same organization (CST_INVALID_INTERORG).

ERROR in "Material cost transaction worker" Request -  The inter-organization transfer transaction is from and to the same organization.

Step 1:   Check the Error Transactions for which the material cost transaction is showing Error.
               SQL Query

SELECT
     MTT.TRANSACTION_TYPE_NAME,
     COUNT(*) "Total"
FROM
     mtl_material_transactions MMT ,   MTL_TRANSACTION_TYPES MTT
WHERE
         mmt.TRANSACTION_SOURCE_TYPE_ID IN (7,13)
     AND mmt.TRANSACTION_ACTION_ID =12
     AND mmt.costed_flag = 'E'
     AND (mmt.ERROR_CODE LIKE '%CST_INVALID_INTERORG%' or mmt.ERROR_EXPLANATION LIKE '%CST_INVALID_INTERORG%')
     AND MMT.TRANSFER_ORGANIZATION_ID =MMT.organization_id
     AND MMT.TRANSACTION_TYPE_ID = MTT.TRANSACTION_TYPE_ID
GROUP BY
     MTT.TRANSACTION_TYPE_NAME;

Step 2:  After that execute this query to solve the Error

DECLARE
CURSOR  incorrect_mmt is
SELECT  rsl.from_organization_id, rsl.to_organization_id,
        mmt.transfer_organization_id, mmt.organization_id,
        mmt.cost_group_id,mmt.transfer_cost_group_id,
        mmt.xfr_owning_organization_id,mmt.xfr_planning_organization_id,
        mmt.transaction_action_id, mmt.transaction_source_type_id,
        mmt.transaction_id,mmt.fob_point
FROM    mtl_material_transactions mmt,
        rcv_shipment_lines rsl,
        rcv_transactions rt
WHERE   mmt.transaction_type_id IN (12,61)
AND     mmt.transaction_action_id =12
AND     mmt.transaction_source_type_id IN (13,7)
AND     mmt.costed_flag = 'E'
AND     (mmt.ERROR_CODE LIKE '%CST_INVALID_INTERORG%' or mmt.ERROR_EXPLANATION LIKE '%CST_INVALID_INTERORG%')
AND     mmt.transfer_organization_id = mmt.organization_id
AND     mmt.rcv_transaction_id = rt.transaction_id                                              
AND     rt.shipment_line_id = rsl.shipment_line_id;


BEGIN
  dbms_output.enable(500000);

  FOR i IN incorrect_mmt LOOP
   IF ( i.fob_point = 1 ) THEN      ---  If fob_point is shipment
     UPDATE  mtl_material_transactions mmt
     SET     TRANSFER_ORGANIZATION_ID     = i.FROM_ORGANIZATION_ID,
             XFR_OWNING_ORGANIZATION_ID   = i.FROM_ORGANIZATION_ID,
             XFR_PLANNING_ORGANIZATION_ID = i.FROM_ORGANIZATION_ID,
             costed_flag = 'N',
             error_code = NULL,
             error_explanation = NULL,
             transaction_group_id = NULL,
             transaction_set_id = NULL,
             last_update_date   = SYSDATE
     WHERE   transaction_id = i.transaction_id
     AND EXISTS --cost group match the CG of receving org
         ( SELECT COST_GROUP_ID
           FROM cst_cost_groups
           WHERE  COST_GROUP_ID  = i.COST_GROUP_ID
           AND   ORGANIZATION_ID = i.TO_ORGANIZATION_ID
         )
     AND EXISTS -- transfer cost group match the CG of receving org
         ( SELECT COST_GROUP_ID
           FROM cst_cost_groups
           WHERE  COST_GROUP_ID= i.TRANSFER_COST_GROUP_ID
           AND   ORGANIZATION_ID = i.TO_ORGANIZATION_ID
         );
   ELSIF ( i.fob_point = 2 ) THEN       ---  If fob_point is Receiving
     UPDATE  mtl_material_transactions mmt
     SET     TRANSFER_ORGANIZATION_ID     = i.FROM_ORGANIZATION_ID,
             XFR_OWNING_ORGANIZATION_ID   = i.FROM_ORGANIZATION_ID,
             XFR_PLANNING_ORGANIZATION_ID = i.FROM_ORGANIZATION_ID,
             costed_flag = 'N',
             error_code = NULL,
             error_explanation = NULL,
             transaction_group_id = NULL,
             transaction_set_id = NULL,
             last_update_date   = SYSDATE
     WHERE   transaction_id = i.transaction_id
     AND EXISTS --cost group match the CG of receving org
         ( SELECT COST_GROUP_ID
           FROM cst_cost_groups
           WHERE  COST_GROUP_ID= i.COST_GROUP_ID
            AND   ORGANIZATION_ID = i.TO_ORGANIZATION_ID
         )
     AND  EXISTS -- transfer cost group match the CG of shipping org
         ( SELECT COST_GROUP_ID
           FROM cst_cost_groups
           WHERE  COST_GROUP_ID   = i.TRANSFER_COST_GROUP_ID
            AND   ORGANIZATION_ID = i.FROM_ORGANIZATION_ID
         );
   END IF;
  END LOOP;
 
    dbms_output.put_line('**********************************');
    dbms_output.put_line('Congratulations! You have successfully executed script');
    dbms_output.put_line('!!! The script does not COMMIT !!!');
    dbms_output.put_line('Please verify in detail about the results before COMMIT.');
    dbms_output.put_line('End of script..');
END ;
/

Then you need to stop and start the cost manager(Inventory>Interface Manager)


No comments:

Post a Comment