Skip to main content

Hello,

Sometimes our project engineers need to make some changes on started project delivables. For example; project started and customer wanting to remove one material. The material is under a manufactued(shop order) part. Engineer is picking part from project deliverables tree and move it to which is non-materail named spare_part object.

At that point project deliverables and shop order is coming different stuation. Moved part is already in shop order materails.

We tried Calculate Gross Requirements function but shop order is not updating.

Are there any way to update shop order as project deliverables in standard from screens? Or should we add a development in Delivery_Structure_API.Move_Item.

We are using IFS10 update 10.

 

This silence indicates that this cannot be done with IFS's standard solutions. Therefore, it seems that we need to go off-road and make development.


Hi,

this is a requirement I see with other customers as well.

In the ideas this is basically the same request:

Project deliverables, issues with structure changes (Evolving BOM) | IFS Community

maybe you can also vote for it

Regards Erik

 


Hi Erik,

I upvoted which you suggested post. 

I started to make a development about this subject. If IFS Global makes a solution, I will remove my solution. 

 

I will add below prosedure to a custom API. And customize Delivery_Structure_API.Move_Item prosedure with Override method. Then add my Update_SO_Like_PrjDel prosedure after source code.

 

It is not finished yet. I will send last running version to this post. I just sent it to give you an idea. Such a solution can be produce like that.

 

DECLARE

  PROCEDURE Update_SO_Like_PrjDel(SourceNodeItem_     number,
                                  SourceNodeItemRev_  varchar2,
                                  TargetNodeItem_     number,
                                  TargetNodeItemRev_  varchar2)
    IS
      order_no_      Shop_Material_Alloc_Tab.Order_No%type;
      release_no_    Shop_Material_Alloc_Tab.Release_No%type;
      objid_         VARCHAR2(50);
      objversion_    VARCHAR2(50);
      
      CURSOR Check_Shop_Order(NodeItem number)
      IS
      SELECT s.order_no, s.release_no, s.objid, s.objversion
        FROM shop_material_alloc_uiv s
       WHERE s.structure_line_no = NodeItem
         AND s.objstate != 'Cancelled';
       
      CURSOR Check_Material_Supply(NodeItem number)
      IS
      SELECT p.source_ref1 order_no
        FROM planning_procured_ext p
       WHERE p.item_no = NodeItem
         AND p.supply_option_db = 'SHOP_ORDER';
     
     
     PROCEDURE Remove_Shop_Order_Line(objid_       varchar2,
                                     objversion_  varchar2)
      IS
      
      p0_ VARCHAR2(32000) := NULL;
      p3_ VARCHAR2(32000) := 'NOTE_TEXT'||chr(31)||'PjdDeletion'||chr(30);

      BEGIN
         IFSAPP.SHOP_MATERIAL_ALLOC_API.MODIFY__( p0_ , objid_ , objversion_ , p3_ , 'DO' );
         IFSAPP.SHOP_MATERIAL_ALLOC_API.REMOVE__( p0_ , objid_ , objversion_ , 'DO' );
      
      END Remove_Shop_Order_Line;
      
      
      PROCEDURE New_Shop_Order_Line(order_no_  Varchar2)
      IS
      
      p0_ VARCHAR2(32000) := NULL;
      p1_ VARCHAR2(32000) := NULL;
      p2_ VARCHAR2(32000) := NULL;
      p3_ VARCHAR2(32000) := NULL;
      
      BEGIN

         client_sys.Clear_Attr(p3_);
         client_sys.Add_To_Attr(
      
         IFSAPP.SHOP_MATERIAL_ALLOC_API.New__( p0_ , p1_ , p2_ , p3_ , 'DO' );

      
      END New_Shop_Order_Line;
       
    
    
    BEGIN
      --Aksiyon No: 176, 177, 178
      
      --Kaynak item, bir is emrine bagli mi?
      --Is SourceItem connected a ShopOrder?
       OPEN Check_Shop_Order(SourceNodeItem_);
      FETCH Check_Shop_Order INTO order_no_, release_no_, objid_, objversion_;
      CLOSE Check_Shop_Order;
      
      --is emri Varsa bu item i is emrinden sil.
      --if there is a shopOrder, remove ShopOrder Line.
      IF order_no_ IS NOT NULL THEN
        Remove_Shop_Order_Line(objid_, objversion_);
        
        order_no_    := null;
      
        --Hedef item bir is emri mi?
        --Is the Destination Structure a ShopOrder?
         OPEN Check_Material_Supply(TargetNodeItem_);
        FETCH Check_Material_Supply INTO order_no_;
        
        --Is emri ise on tasinan item i ekle.
        --Add moved item to destination ShopOrder.
        IF order_no_ IS NOT NULL Then
          New_Shop_Order_Line(order_no_);
          
        End If;
        CLOSE Check_Material_Supply;
      
      
      
      END IF;
            
    END Update_SO_Like_PrjDel;


BEGIN
  Update_SO_Like_PrjDel('132991',
                                             'R1',
                                             '138539',
                                             'R1');


END;


 


Hi Erik,

I changed code. I copied some parts from standard code. Becouse there should be some control mechanisims while adding material to shop order.

I added Move_Item_Between_SO procedure to a utility API package and call it from Delivery_Structure_API.Move_Item procedure. 

At the IFS-TEST environment in IFS 10.10 it is running.

 

 

 

Declare


  Procedure Move_Item_Between_SO(SourceNodeItem_     number,
                                 SourceNodeItemRev_  varchar2,
                                 TargetNodeItem_     number,
                                 TargetNodeItemRev_  varchar2)
  IS
    order_no_       Varchar2(10);
    release_no_     Varchar2(10);
    Sequence_no_    Varchar2(10);
  
    CURSOR Check_Shop_Order(NodeItem number)
      IS
      SELECT s.order_no, s.release_no, s.sequence_no
        FROM shop_material_alloc_uiv s
       WHERE s.structure_line_no = NodeItem
         AND s.objstate != 'Cancelled';
    
    CURSOR Check_Material_Supply(NodeItem number)
      IS
      SELECT p.source_ref1 order_no
        FROM planning_procured_ext p --if shop order created from pmrp, it is not shown here. This is a problem.
       WHERE p.item_no = NodeItem
         AND p.supply_option_db = 'SHOP_ORDER';
    
    Procedure Add_Material_to_SO(item_no_ Varchar2,
                               order_no_ Varchar2)
    Is
    
    source_                VARCHAR2(30);   
      pd_item_no_            NUMBER;
      qty_required_          NUMBER;
      next_line_no_          NUMBER;
      date_required_         DATE;
      site_                  VARCHAR2(5);
      owner_                 PROJECT_TAB.customer_id%TYPE;
      local_supply_code_db_  VARCHAR2(5);
      local_activity_seq_    NUMBER;
      local_project_id_      VARCHAR2(10);
      local_qty_factor_      NUMBER;
      supply_option_db_      VARCHAR2(20);
      part_no_               VARCHAR2(25);
      planning_item_qty_     NUMBER;
      issued_qty_           NUMBER;
      configuration_id_      VARCHAR2(50);   
      shop_ord_rec_          Shop_Ord_API.Public_Rec;
      release_no_            VARCHAR2(50):= '*';   
      sequence_no_           VARCHAR2(50):= '*';   
    
    CURSOR get_project_deliverables_str(item_no_ NUMBER) IS
            SELECT ds.item_no, ds.item_name, ds.position_no, ds.part_no, ds.item_type_db, ds.part_ownership_db, ds.note, ds.quantity, ds.operation_no, ds.phantom_item_db
            FROM delivery_structure ds
            --WHERE ds.parent_item_no = item_no_
            WHERE ds.item_no = item_no_
            AND ds.objstate='Approved'
            ORDER BY sorting_code ASC;
    pd_rec_ get_project_deliverables_str%Rowtype;
            
    
    CURSOR get_planning_item(item_no_ NUMBER) IS
            SELECT pi.part_no, pi.activity_seq, pi.supply_option_db, pi.required_qty, pi.configuration_id
            FROM planning_item pi
            WHERE pi.item_no = item_no_
            AND pi.execution_type_db = Type_Execution_Option_API.DB_MATERIAL; 
  
  Begin
    shop_ord_rec_ := Shop_Ord_API.Get(order_no_, release_no_, sequence_no_);
    site_ := shop_ord_rec_.contract;
    
    source_       := shop_ord_rec_.source;
    pd_item_no_   := item_no_;
    local_qty_factor_ := 1;
    
     Open get_project_deliverables_str(pd_item_no_);
    Fetch get_project_deliverables_str Into pd_rec_;
    Close get_project_deliverables_str;
    
    -- Get material details from the planning item
     OPEN get_planning_item(pd_rec_.item_no);
    FETCH get_planning_item INTO part_no_, local_activity_seq_, supply_option_db_, planning_item_qty_, configuration_id_;
    CLOSE get_planning_item;
   
    IF (planning_item_qty_ >= 0  ) THEN
       IF (part_no_ IS NULL) THEN
          Return;
       END IF;

       issued_qty_          := NVL(Planning_Procured_API.Get_Issued_Qty_By_Item_No(pd_rec_.item_no), 0);              
       qty_required_         := ROUND((planning_item_qty_ - issued_qty_), 6);

       local_project_id_     := Activity_API.Get_Project_Id(local_activity_seq_);
       next_line_no_         := Shop_Material_Alloc_API.Get_Max_Line_Item_No(order_no_, release_no_, sequence_no_) + 1;
       date_required_        := NVL( shop_ord_rec_.revised_start_date, shop_ord_rec_.revised_due_date);                         
   
       IF pd_rec_.part_ownership_db = 'CUSTOMER OWNED' THEN
          owner_ := Project_API.Get_Customer_Id(local_project_id_);
       ELSE
          owner_ := NULL;
       END IF;            
   
       -- Set supply codes for project deliverables items.
       IF (supply_option_db_ IN (Type_Supply_Option_API.DB_PURCHASE, Type_Supply_Option_API.DB_SHOP_ORDER)) THEN
          local_supply_code_db_ := 'PJD';              
       ELSIF (supply_option_db_ = Type_Supply_Option_API.DB_PROJECT_MRP) THEN                  
          local_supply_code_db_ := 'PI';                
       ELSE
          local_supply_code_db_ := 'IO';
          local_activity_seq_   := NULL;
          local_project_id_     := NULL;                  
       END IF;
         Shop_Material_Alloc_API.New_Material_Line(order_no_             => order_no_,
                                                   release_no_           => shop_ord_rec_.release_no,
                                                   sequence_no_          => shop_ord_rec_.sequence_no,
                                                   line_item_no_         => next_line_no_,
                                                   part_no_              => part_no_,
                                                   contract_             => site_,
                                                   order_code_db_        => shop_ord_rec_.order_code,
                                                   date_required_        => shop_ord_rec_.revised_start_date,
                                                   qty_per_assembly_     => pd_rec_.quantity * local_qty_factor_,
                                                   shrinkage_factor_     => NULL,
                                                   component_scrap_      => NULL,
                                                   qty_required_         => qty_required_,
                                                   supply_code_db_       => local_supply_code_db_,
                                                   issue_to_loc_         => NULL,
                                                   leadtime_offset_      => NULL,
                                                   consumption_item_     => NULL,
                                                   operation_no_         => pd_rec_.operation_no,
                                                   structure_line_no_    => pd_rec_.item_no,
                                                   ps_note_id_           => NULL,
                                                   note_text_            => pd_rec_.note,
                                                   activity_seq_         => local_activity_seq_,
                                                   draw_pos_no_          => pd_rec_.position_no ,
                                                   configuration_id_     => configuration_id_,
                                                   component_print_unit_ => NULL,
                                                   part_ownership_db_    => pd_rec_.part_ownership_db,
                                                   owner_                => owner_,
                                                   vim_structure_source_ => NULL,
                                                   project_id_           =>local_project_id_);
                                                               
    END IF;
  
  
  End Add_Material_to_SO;
  
  Begin
     --Aksiyon No: 176, 177, 178
     
     --Is SourceItem connected a ShopOrder?
      OPEN Check_Shop_Order(SourceNodeItem_);
     FETCH Check_Shop_Order INTO order_no_, release_no_, Sequence_no_;
     --if yes, remove it
     If Check_Shop_Order%Found Then
        Shop_Material_Alloc_API.Remove_Allocation_From_Pjd(order_no_, release_no_, Sequence_no_, SourceNodeItem_);
     End if;  
     CLOSE Check_Shop_Order;
     
          
     --Is the Destination Structure a ShopOrder?
      OPEN Check_Material_Supply(TargetNodeItem_);
     FETCH Check_Material_Supply INTO order_no_;
     CLOSE Check_Material_Supply;  
     --Add moved item to destination ShopOrder.
     IF order_no_ IS NOT NULL Then
       Add_Material_to_SO(SourceNodeItem_, order_no_);
          
     End If;
    
  End Move_Item_Between_SO;


Begin
  Move_Item_Between_SO ('132979',
                        'R1',
                        '132909',
                        'R1');

End;


Hi Erik,

I developed this code and solved my problem.

If any one who need a solution in short term, can use this codes. 


Reply