Forum Stats

  • 3,824,799 Users
  • 2,260,423 Discussions
  • 7,896,313 Comments

Discussions

import an outsourcing purchase order error Charge Account (Value = 0) is not a valid charge account

User_MPHA5
User_MPHA5 Member Posts: 1 Green Ribbon

I set the value Charge Account and Charge Account ID ,but api return error, when the line type=‘GOODS’ , script can import po success.


DECLARE

 -- Local variables here

 i          INTEGER;

 l_header_rec    po_headers_interface%ROWTYPE;

 l_line_rec     po_lines_interface%ROWTYPE;

 l_line_location_rec po_line_locations_interface%ROWTYPE;

 l_dist_rec     po_distributions_interface%ROWTYPE;

 l_error_message   VARCHAR2(4000);

BEGIN

 -- Test statements here

 l_header_rec := NULL;

 mo_global.init('PO');

 mo_global.set_policy_context('S', 82);

 fnd_global.apps_initialize(user_id   => 1130,

               resp_id   => 50757,

               resp_appl_id => 20003);

 --PO头

 l_header_rec.org_id := 82;


 SELECT po_headers_interface_s.nextval

  INTO l_header_rec.interface_header_id

  FROM dual;


 dbms_output.put_line('HEADER_ID:' || l_header_rec.interface_header_id);

 l_header_rec.batch_id       := l_header_rec.interface_header_id;

 l_header_rec.interface_source_code := 'FTP';

 l_header_rec.process_code     := 'PENDING';

 l_header_rec.action        := 'ORIGINAL';

 l_header_rec.approval_status    := 'APPROVED';

 l_header_rec.document_num     := 'JW003';

 l_header_rec.document_type_code  := 'STANDARD';

 --l_header_rec.po_header_id  := 47054;

 l_header_rec.vendor_id      := 1; --can_ceshi

 l_header_rec.vendor_site_id   := 1;

 l_header_rec.ship_to_location_id := 162;

 l_header_rec.bill_to_location_id := 162;

 l_header_rec.agent_id      := 121;

 l_header_rec.currency_code    := 'CNY'; --USD是本位币

 l_header_rec.last_update_date  := SYSDATE;

 l_header_rec.last_updated_by   := fnd_global.user_id;

 l_header_rec.last_update_login  := fnd_global.login_id;

 l_header_rec.creation_date    := SYSDATE;

 l_header_rec.created_by     := fnd_global.user_id;


 INSERT INTO po_headers_interface VALUES l_header_rec;


 --PO行

 l_dist_rec           := NULL;

 l_line_rec.interface_header_id := l_header_rec.interface_header_id;


 SELECT po_lines_interface_s.nextval

  INTO l_line_rec.interface_line_id

  FROM dual;


 l_line_rec.line_num := 1;

 l_line_rec.action  := 'ADD';

 --l_line_rec.line_type  := '外协加工;

 l_line_rec.line_type_id   := 3; --'外协加工

 l_line_rec.process_code   := 'PENDING';

 l_line_rec.item       := 'FXITEM1'; --F2022052404

 l_line_rec.item_id      := 5; --F2022052404

 l_line_rec.uom_code     := 'pcs';

 l_line_rec.unit_price    := 1;

 l_line_rec.quantity     := 9;

 l_line_rec.promised_date   := SYSDATE;

 l_line_rec.last_update_date := SYSDATE;

 l_line_rec.last_updated_by  := fnd_global.user_id;

 l_line_rec.last_update_login := fnd_global.login_id;

 l_line_rec.creation_date   := SYSDATE;

 l_line_rec.created_by    := fnd_global.user_id;

 --l_line_rec.ship_to_organization_id := 142;

 --l_line_rec.ship_to_location_id  := 142;

 l_line_rec.line_loc_populated_flag := 'Y';

 l_line_rec.shipment_num      := 1;

 l_line_rec.receiving_routing_id  := 3; --直接交货


 INSERT INTO po_lines_interface VALUES l_line_rec;


 SELECT po_line_locations_interface_s.nextval

  INTO l_line_location_rec.interface_line_location_id

  FROM dual;

 l_line_location_rec.interface_header_id   := l_header_rec.interface_header_id;

 l_line_location_rec.interface_line_id    := l_line_rec.interface_line_id;

 l_line_location_rec.ship_to_organization_id := 103;

 l_line_location_rec.ship_to_location_id   := 162;

 l_line_location_rec.quantity        := 9;

 l_line_location_rec.promised_date      := l_line_rec.promised_date;


 INSERT INTO po_line_locations_interface VALUES l_line_location_rec;

 -- PO分配

 l_dist_rec              := NULL;

 l_dist_rec.interface_header_id    := l_header_rec.interface_header_id;

 l_dist_rec.interface_line_id     := l_line_rec.interface_line_id;

 l_dist_rec.interface_line_location_id := l_line_location_rec.interface_line_location_id;

 l_dist_rec.org_id           := 82;


 SELECT po_distributions_interface_s.nextval

  INTO l_dist_rec.interface_distribution_id

  FROM dual;

 l_dist_rec.distribution_num := 1;

 l_dist_rec.quantity_ordered := 9;

 l_dist_rec.charge_account_id := 4001;

 --l_dist_rec.charge_account := '10002.0.140801.0.0.0.0.0.0';

 -- l_dist_rec.destination_type_code  := 'SHOP FLOOR';


 --l_dist_rec.destination_organization_id := 142;

 l_dist_rec.wip_entity_id     := 9; --21001

 l_dist_rec.wip_operation_seq_num := '10';

 l_dist_rec.wip_resource_seq_num := '10';

 --l_dist_rec.bom_resource_id       := 13004;


 l_dist_rec.charge_account_id := 5000;

 /* --l_dist_rec.DEST_CHARGE_ACCOUNT_ID:= 5000;

 l_dist_rec.charge_account := '1001.0.500101.0.0.0.0.0.0';

  

 --l_dist_rec.accrue_on_receipt_flag := 'Y'; --接收时应记

  

 l_dist_rec.accrual_account_id := 3006;

 l_dist_rec.accural_account  := '1001.0.220209.0.0.0.0.0.0';

  

 \* l_dist_rec.charge_account_segment1 := '1001';

 l_dist_rec.charge_account_segment2 := '0';

 l_dist_rec.charge_account_segment3 := '500101';

 l_dist_rec.charge_account_segment4 := '0';

 l_dist_rec.charge_account_segment5 := '0';

 l_dist_rec.charge_account_segment6 := '0';

 l_dist_rec.charge_account_segment7 := '0';

 l_dist_rec.charge_account_segment8 := '0';

 l_dist_rec.charge_account_segment9 := '0';*\

  

 l_dist_rec.variance_account_id := 3002;

 l_dist_rec.variance_account  := '1001.0.140401.0.0.0.0.0.0';*/

 --l_dist_rec.deliver_to_location_id := 142;

 l_dist_rec.last_updated_by    := fnd_global.user_id;

 l_dist_rec.last_update_login   := fnd_global.login_id;

 l_dist_rec.creation_date     := SYSDATE;

 l_dist_rec.created_by       := fnd_global.user_id;


 INSERT INTO po_distributions_interface VALUES l_dist_rec;


 po_docs_interface_sv5.process_po_headers_interface(x_selected_batch_id     => l_header_rec.batch_id,

                           x_buyer_id          => NULL,

                           x_document_type       => l_header_rec.document_type_code,

                           x_document_subtype      => NULL,

                           x_create_items        => 'N',

                           x_create_sourcing_rules_flag => NULL,

                           x_rel_gen_method       => NULL,

                           x_approved_status      => l_header_rec.approval_status,

                           x_commit_interval      => 1,

                           x_process_code        => 'PENDING',

                           x_interface_header_id    => NULL,

                           x_org_id_param        => NULL,

                           x_ga_flag          => NULL);

EXCEPTION

 WHEN OTHERS THEN

  NULL;

  

END;

/*SELECT *

 -- INTO l_error_message

 FROM po_interface_errors pie

 WHERE pie.interface_header_id = 1003;*/

--select * from cux.cux_test_xtb

/* 

select* from po_headers_interface

delete from po_headers_interface;

delete from po_lines_interface;

delete from po_line_locations_interface;

delete from po_distributions_interface;*/

--select * from po_headers_interface


--select * from po_distributions_all t where t.PO_DISTRIBUTION_ID=51008

--select * from po_line_locations_all t where t.LINE_LOCATION_ID=45042


--select * from po_headers_all ph where ph.SEGMENT1='JW001'


select * from po_headers_interface T WHERE T.interface_header_id = 31006;

select * from po_lines_interface T WHERE T.interface_header_id = 31002;

select *

 from po_line_locations_interface T

 WHERE T.interface_header_id = 31002;

select *

 from po_distributions_interface T

 WHERE T.interface_header_id = 31002;


select * from po_headers_all t where t.SEGMENT1 = 'TEST004';

SELECT * FROM PO_HEADERS_ARCHIVE_ALL T WHERE T.SEGMENT1 = 'AA998';


select * from wip_entities we where we.WIP_ENTITY_NAME = 'potest'

Answers