-
Notifications
You must be signed in to change notification settings - Fork 0
/
MGTEP.pkb
7518 lines (7147 loc) · 387 KB
/
MGTEP.pkb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
CREATE OR REPLACE PACKAGE BODY APPS.MK_GL_TRANSFER_ENGINE_PKG AS
P_USER_ID NUMBER := APPS.FND_GLOBAL.USER_ID; --FND_PROFILE.VALUE ('USER_ID');
P_LOGIN_ID NUMBER := FND_PROFILE.VALUE ('LOGIN_ID');
G_STATUS GL_JE_HEADERS.STATUS%TYPE := FND_PROFILE.VALUE ('ATK_JOURNAL_STATUS');
P_ERP_USER VARCHAR2 (20);
G_ERR_STRING VARCHAR2 (3000);
-- G_CONVERSION_TYPE_AV VARCHAR2 (30) := 'Accounting Rate';
G_CONVERSION_TYPE_AV VARCHAR2 (30) := 'Average Rate';
G_CONVERSION_TYPE_AC VARCHAR2 (30) := 'Average Rate'; --'Accounting Rate';
G_USER_NAME VARCHAR2 (30) := 'JIMBOCHANG';
G_USER_ID NUMBER := 36361;
G_TPV_SOB_ID NUMBER := 22;
G_MSG VARCHAR2 (32767);
G_PREFIX VARCHAR2 (30) := '2891';
G_CON VARCHAR2 (1) := '_';
G_GCC GL_CODE_COMBINATIONS_KFV%ROWTYPE;
-- G_LINE LINE_CT;
TYPE LINE_CT IS TABLE OF GL_JE_LINES%ROWTYPE
INDEX BY BINARY_INTEGER;
TYPE R_REC IS RECORD
(
P_BATCH_NAME GL_INTERFACE.REFERENCE1%TYPE,
P_JOURNAL_ENTRY_NAME GL_INTERFACE.REFERENCE4%TYPE,
P_PERIOD_NAME GL_INTERFACE.PERIOD_NAME%TYPE,
P_USER_JE_SOURCE_NAME GL_INTERFACE.USER_JE_SOURCE_NAME%TYPE,
P_USER_JE_CATEGORY_NAME GL_INTERFACE.USER_JE_CATEGORY_NAME%TYPE,
P_CURRENCY_CODE GL_INTERFACE.CURRENCY_CODE%TYPE,
P_CURRENCY_CONVERSION_DATE GL_INTERFACE.CURRENCY_CONVERSION_DATE%TYPE,
P_EXCHANGE_RATE GL_INTERFACE.CURRENCY_CONVERSION_RATE%TYPE,
P_CCID GL_INTERFACE.CODE_COMBINATION_ID%TYPE,
P_DESCRIPTION GL_INTERFACE.REFERENCE10%TYPE,
P_DATE GL_INTERFACE.ACCOUNTING_DATE%TYPE,
P_USER_ID NUMBER,
P_SET_OF_BOOKS_ID GL_INTERFACE.SET_OF_BOOKS_ID%TYPE,
P_GROUP_ID GL_INTERFACE.GROUP_ID%TYPE,
P_DR GL_INTERFACE.ENTERED_DR%TYPE,
P_CR GL_INTERFACE.ENTERED_CR%TYPE,
P_DR_ACC GL_INTERFACE.ACCOUNTED_DR%TYPE,
P_CR_ACC GL_INTERFACE.ACCOUNTED_CR%TYPE,
P_ATTRIBUTE1 GL_INTERFACE.ATTRIBUTE1%TYPE, --異損編號
P_ATTRIBUTE2 GL_INTERFACE.ATTRIBUTE2%TYPE, --Style
P_ATTRIBUTE3 GL_INTERFACE.ATTRIBUTE3%TYPE, --Customer
P_ATTRIBUTE4 GL_INTERFACE.ATTRIBUTE4%TYPE, --Supplier
P_ATTRIBUTE5 GL_INTERFACE.ATTRIBUTE5%TYPE, --Account Num
P_ATTRIBUTE6 GL_INTERFACE.ATTRIBUTE6%TYPE, --Ecolot End Buyer
P_ATTRIBUTE7 GL_INTERFACE.ATTRIBUTE7%TYPE, --外幣
P_ATTRIBUTE8 GL_INTERFACE.ATTRIBUTE8%TYPE, --Ecolot Customer
P_ATTRIBUTE9 GL_INTERFACE.ATTRIBUTE9%TYPE, --IDR Amount
P_ATTRIBUTE10 GL_INTERFACE.ATTRIBUTE10%TYPE, --備註
P_ATTRIBUTE11 GL_INTERFACE.ATTRIBUTE11%TYPE, --Ecolot Sales Dept
P_ATTRIBUTE12 GL_INTERFACE.ATTRIBUTE12%TYPE, --付款日(DD-MON-YYYY)
P_ATTRIBUTE13 GL_INTERFACE.ATTRIBUTE13%TYPE, --PO NO/Contract no
P_ATTRIBUTE14 GL_INTERFACE.ATTRIBUTE14%TYPE, --科目分類
P_ATTRIBUTE15 GL_INTERFACE.ATTRIBUTE15%TYPE
);
----------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTION GET_CC_ID (V_REC GL_CODE_COMBINATIONS%ROWTYPE)
RETURN NUMBER AS
V_CODE_COMBINATION_ID GL_CODE_COMBINATIONS.CODE_COMBINATION_ID%TYPE;
BEGIN
SELECT CODE_COMBINATION_ID
INTO V_CODE_COMBINATION_ID
FROM GL_CODE_COMBINATIONS
WHERE 1 = 1
AND SEGMENT1 = V_REC.SEGMENT1
AND SEGMENT2 = V_REC.SEGMENT2
AND SEGMENT3 = V_REC.SEGMENT3
AND SEGMENT4 = V_REC.SEGMENT4
AND SEGMENT5 = V_REC.SEGMENT5
AND SEGMENT6 = V_REC.SEGMENT6;
RETURN NVL (V_CODE_COMBINATION_ID, -1);
EXCEPTION
WHEN OTHERS THEN
V_CODE_COMBINATION_ID := -1; --TO_NUMBER (NULL);
RETURN -1;
-- g_err_string :=
-- v_rec.segment1
-- || '.'
-- || v_rec.segment2
-- || '.'
-- || v_rec.segment3
-- || '.'
-- || v_rec.segment4
-- || '.'
-- || v_rec.segment5
-- || '.'
-- || v_rec.segment6
-- || ' 會計科目未產生';
END GET_CC_ID;
----------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTION GEN_CC_ID (V_REC GL_CODE_COMBINATIONS%ROWTYPE, P_SET_OF_BOOKS_ID NUMBER)
RETURN NUMBER AS
V_CODE_COMBINATION_ID GL_CODE_COMBINATIONS.CODE_COMBINATION_ID%TYPE;
V_MSG VARCHAR2 (32767);
V_CCID NUMBER;
BEGIN
V_CCID := GET_CC_ID (V_REC);
IF V_CCID = -1 THEN
MK_GL_PUB.CREATE_GL_ACCOUNT (
P_SET_OF_BOOKS_ID,
V_REC.SEGMENT1
|| '.'
|| V_REC.SEGMENT2
|| '.'
|| V_REC.SEGMENT3
|| '.'
|| V_REC.SEGMENT4
|| '.'
|| V_REC.SEGMENT5
|| '.'
|| V_REC.SEGMENT6,
G_ERR_STRING);
V_CCID := GET_CC_ID (V_REC);
END IF;
RETURN V_CCID;
EXCEPTION
WHEN OTHERS THEN
G_ERR_STRING := 'E' || SQLERRM;
RETURN NULL;
END GEN_CC_ID;
----------------------------------------------------------------------------------------------------------------------------------------------------
FUNCTION RATE_CONVERSION (IN_FROM_CURRENCY VARCHAR2,
IN_TO_CURRENCY VARCHAR2,
IN_RATE_TYPE VARCHAR2,
IN_RATE_DATE DATE,
IN_AMOUNT NUMBER DEFAULT 1)
RETURN NUMBER IS
V_RETURN NUMBER;
BEGIN
IF (IN_FROM_CURRENCY = 'VND'
AND IN_TO_CURRENCY = 'TWD')
OR (IN_FROM_CURRENCY = 'TWD'
AND IN_TO_CURRENCY = 'VND') THEN
RETURN MK_GL_PUB.GET_ACTUAL_RATE_AMOUNT (IN_AMOUNT,
IN_FROM_CURRENCY,
IN_TO_CURRENCY,
IN_RATE_TYPE,
IN_RATE_DATE);
ELSE
V_RETURN := IN_AMOUNT * MIC_PO_RATE_PKG.GET_RATE (IN_FROM_CURRENCY, IN_TO_CURRENCY, IN_RATE_TYPE, IN_RATE_DATE);
END IF;
RETURN V_RETURN;
END RATE_CONVERSION;
----------------------------------------------------------------------------------------------------------------------------------------------------
PROCEDURE IMP_GI (P_REC IN OUT R_REC) IS
BEGIN
--INSERT GL INTERFACE
P_REC.P_DR := NVL (P_REC.P_DR, 0);
P_REC.P_CR := NVL (P_REC.P_CR, 0);
ATK_GL_COMMON_PKG.INSERT_GL_INTERFACE_ALL (P_BATCH_NAME => P_REC.P_BATCH_NAME,
P_JOURNAL_ENTRY_NAME => P_REC.P_JOURNAL_ENTRY_NAME,
P_PERIOD_NAME => P_REC.P_PERIOD_NAME,
P_USER_JE_SOURCE_NAME => P_REC.P_USER_JE_SOURCE_NAME,
P_USER_JE_CATEGORY_NAME => P_REC.P_USER_JE_CATEGORY_NAME,
P_CURRENCY_CODE => P_REC.P_CURRENCY_CODE,
P_CCID => P_REC.P_CCID,
P_DESCRIPTION => P_REC.P_DESCRIPTION,
P_DATE => P_REC.P_DATE,
P_USER_ID => P_REC.P_USER_ID,
P_SET_OF_BOOKS_ID => P_REC.P_SET_OF_BOOKS_ID,
P_GROUP_ID => P_REC.P_GROUP_ID,
P_DR => P_REC.P_DR,
P_CR => P_REC.P_CR,
P_ATTRIBUTE1 => P_REC.P_ATTRIBUTE1,
P_ATTRIBUTE2 => P_REC.P_ATTRIBUTE2,
P_ATTRIBUTE3 => P_REC.P_ATTRIBUTE3,
P_ATTRIBUTE4 => P_REC.P_ATTRIBUTE4,
P_ATTRIBUTE5 => P_REC.P_ATTRIBUTE5,
P_ATTRIBUTE6 => P_REC.P_ATTRIBUTE6,
P_ATTRIBUTE7 => P_REC.P_ATTRIBUTE7,
P_ATTRIBUTE8 => P_REC.P_ATTRIBUTE8,
P_ATTRIBUTE9 => P_REC.P_ATTRIBUTE9,
P_ATTRIBUTE10 => P_REC.P_ATTRIBUTE10,
P_ATTRIBUTE11 => P_REC.P_ATTRIBUTE11,
P_ATTRIBUTE12 => P_REC.P_ATTRIBUTE12,
P_ATTRIBUTE13 => P_REC.P_ATTRIBUTE13,
P_ATTRIBUTE14 => P_REC.P_ATTRIBUTE14,
P_ATTRIBUTE15 => P_REC.P_ATTRIBUTE15);
COMMIT;
END IMP_GI;
PROCEDURE INSERT_GL_INTERFACE_ALL_CURR (P_BATCH_NAME VARCHAR2,
P_JOURNAL_ENTRY_NAME VARCHAR2,
P_PERIOD_NAME VARCHAR2,
P_USER_JE_SOURCE_NAME VARCHAR2,
P_USER_JE_CATEGORY_NAME VARCHAR2,
P_CURRENCY_CODE VARCHAR2,
P_CURRENCY_CONVERSION_DATE DATE,
P_EXCHANGE_RATE NUMBER,
P_CCID NUMBER,
P_DESCRIPTION VARCHAR2,
P_DATE DATE,
P_USER_ID NUMBER,
P_SET_OF_BOOKS_ID NUMBER,
P_GROUP_ID NUMBER,
P_DR NUMBER,
P_CR NUMBER,
P_DR_ACC NUMBER,
P_CR_ACC NUMBER,
P_ATTRIBUTE1 VARCHAR2 DEFAULT NULL, --異損編號
P_ATTRIBUTE2 VARCHAR2 DEFAULT NULL, --Style
P_ATTRIBUTE3 VARCHAR2 DEFAULT NULL, --Customer
P_ATTRIBUTE4 VARCHAR2 DEFAULT NULL, --Supplier
P_ATTRIBUTE5 VARCHAR2 DEFAULT NULL, --Account Num
P_ATTRIBUTE6 VARCHAR2 DEFAULT NULL, --Ecolot End Buyer
P_ATTRIBUTE7 VARCHAR2 DEFAULT NULL, --外幣
P_ATTRIBUTE8 VARCHAR2 DEFAULT NULL, --Ecolot Customer
P_ATTRIBUTE9 VARCHAR2 DEFAULT NULL, --IDR Amount
P_ATTRIBUTE10 VARCHAR2 DEFAULT NULL, --備註
P_ATTRIBUTE11 VARCHAR2 DEFAULT NULL, --Ecolot Sales Dept
P_ATTRIBUTE12 VARCHAR2 DEFAULT NULL, --付款日(DD-MON-YYYY)
P_ATTRIBUTE13 VARCHAR2 DEFAULT NULL,
P_ATTRIBUTE14 VARCHAR2 DEFAULT NULL,
P_ATTRIBUTE15 VARCHAR2 DEFAULT NULL) IS
NTOTAL NUMBER;
NDR NUMBER;
NCR NUMBER;
NDR_ACC NUMBER;
NCR_ACC NUMBER;
NTOTAL_ACC NUMBER;
BEGIN
IF P_DR = 0 THEN
NDR := NULL;
NCR := P_CR;
NTOTAL := NCR;
ELSE
NCR := NULL;
NDR := P_DR;
NTOTAL := NDR;
END IF;
IF P_DR_ACC = 0 THEN
NDR_ACC := NULL;
NCR_ACC := P_CR_ACC;
NTOTAL_ACC := NCR_ACC;
ELSE
NCR_ACC := NULL;
NDR_ACC := P_DR_ACC;
NTOTAL_ACC := NDR_ACC;
END IF;
INSERT INTO GL_INTERFACE (STATUS,
SET_OF_BOOKS_ID,
USER_JE_SOURCE_NAME,
USER_JE_CATEGORY_NAME,
ACCOUNTING_DATE,
CURRENCY_CODE,
DATE_CREATED,
CREATED_BY,
ACTUAL_FLAG,
USER_CURRENCY_CONVERSION_TYPE,
CURRENCY_CONVERSION_DATE,
CURRENCY_CONVERSION_RATE,
CODE_COMBINATION_ID,
ENTERED_DR,
ENTERED_CR,
ACCOUNTED_DR,
ACCOUNTED_CR,
REFERENCE1,
REFERENCE4,
REFERENCE10,
GROUP_ID,
PERIOD_NAME,
INVOICE_DATE,
INVOICE_AMOUNT,
ATTRIBUTE1,
ATTRIBUTE2,
ATTRIBUTE3,
ATTRIBUTE4,
ATTRIBUTE5,
ATTRIBUTE6,
ATTRIBUTE7,
ATTRIBUTE8,
ATTRIBUTE9,
ATTRIBUTE10,
ATTRIBUTE11,
ATTRIBUTE12,
ATTRIBUTE13,
ATTRIBUTE14,
ATTRIBUTE15)
VALUES ('NEW',
P_SET_OF_BOOKS_ID,
TRIM (P_USER_JE_SOURCE_NAME),
TRIM (P_USER_JE_CATEGORY_NAME),
P_DATE,
TRIM (P_CURRENCY_CODE),
SYSDATE,
P_USER_ID,
'A',
'Average Rate', --'Accounting Rate',
P_CURRENCY_CONVERSION_DATE,
P_EXCHANGE_RATE,
P_CCID,
NDR,
NCR,
NDR_ACC,
NCR_ACC,
TRIM (P_BATCH_NAME),
TRIM (P_JOURNAL_ENTRY_NAME),
P_DESCRIPTION,
P_GROUP_ID,
TRIM (P_PERIOD_NAME),
P_DATE,
NTOTAL,
P_ATTRIBUTE1,
P_ATTRIBUTE2,
P_ATTRIBUTE3,
P_ATTRIBUTE4,
P_ATTRIBUTE5,
P_ATTRIBUTE6,
P_ATTRIBUTE7,
P_ATTRIBUTE8,
P_ATTRIBUTE9,
P_ATTRIBUTE10,
P_ATTRIBUTE11,
P_ATTRIBUTE12,
P_ATTRIBUTE13,
P_ATTRIBUTE14,
P_ATTRIBUTE15);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('ATK Error:' || SQLERRM);
END INSERT_GL_INTERFACE_ALL_CURR;
----------------------------------------------------------------------------------------------------------------------------------------------------
PROCEDURE IMP_GI_CURR (P_REC IN OUT R_REC) IS
BEGIN
P_REC.P_DR := NVL (P_REC.P_DR, 0);
P_REC.P_CR := NVL (P_REC.P_CR, 0);
P_REC.P_DR_ACC := NVL (P_REC.P_DR_ACC, 0);
P_REC.P_CR_ACC := NVL (P_REC.P_CR_ACC, 0);
--INSERT GL INTERFACE
-- ATK_GL_COMMON_PKG.
INSERT_GL_INTERFACE_ALL_CURR (P_BATCH_NAME => P_REC.P_BATCH_NAME,
P_JOURNAL_ENTRY_NAME => P_REC.P_JOURNAL_ENTRY_NAME,
P_PERIOD_NAME => P_REC.P_PERIOD_NAME,
P_USER_JE_SOURCE_NAME => P_REC.P_USER_JE_SOURCE_NAME,
P_USER_JE_CATEGORY_NAME => P_REC.P_USER_JE_CATEGORY_NAME,
P_CURRENCY_CODE => P_REC.P_CURRENCY_CODE,
P_CURRENCY_CONVERSION_DATE => P_REC.P_CURRENCY_CONVERSION_DATE,
P_EXCHANGE_RATE => P_REC.P_EXCHANGE_RATE,
P_CCID => P_REC.P_CCID,
P_DESCRIPTION => P_REC.P_DESCRIPTION,
P_DATE => P_REC.P_DATE,
P_USER_ID => P_REC.P_USER_ID,
P_SET_OF_BOOKS_ID => P_REC.P_SET_OF_BOOKS_ID,
P_GROUP_ID => P_REC.P_GROUP_ID,
P_DR => P_REC.P_DR,
P_CR => P_REC.P_CR,
P_DR_ACC => P_REC.P_DR_ACC,
P_CR_ACC => P_REC.P_CR_ACC,
P_ATTRIBUTE1 => P_REC.P_ATTRIBUTE1,
P_ATTRIBUTE2 => P_REC.P_ATTRIBUTE2,
P_ATTRIBUTE3 => P_REC.P_ATTRIBUTE3,
P_ATTRIBUTE4 => P_REC.P_ATTRIBUTE4,
P_ATTRIBUTE5 => P_REC.P_ATTRIBUTE5,
P_ATTRIBUTE6 => P_REC.P_ATTRIBUTE6,
P_ATTRIBUTE7 => P_REC.P_ATTRIBUTE7,
P_ATTRIBUTE8 => P_REC.P_ATTRIBUTE8,
P_ATTRIBUTE9 => P_REC.P_ATTRIBUTE9,
P_ATTRIBUTE10 => P_REC.P_ATTRIBUTE10,
P_ATTRIBUTE11 => P_REC.P_ATTRIBUTE11,
P_ATTRIBUTE12 => P_REC.P_ATTRIBUTE12,
P_ATTRIBUTE13 => P_REC.P_ATTRIBUTE13,
P_ATTRIBUTE14 => P_REC.P_ATTRIBUTE14,
P_ATTRIBUTE15 => P_REC.P_ATTRIBUTE15);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
G_MSG := 'IMP_GI_CURR Error!' || SQLERRM;
END IMP_GI_CURR;
FUNCTION GET_BATCH_NAME (P_STRING VARCHAR2, P_PERIOD VARCHAR2, P_SOB_NAME VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN G_PREFIX || G_CON || P_SOB_NAME || G_CON || P_STRING || G_CON || P_PERIOD || G_CON;
END GET_BATCH_NAME;
FUNCTION GET_JOURNAL_NAME (P_STRING VARCHAR2, P_PERIOD VARCHAR2, P_SOB_NAME VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN GET_BATCH_NAME (P_STRING, P_PERIOD, P_SOB_NAME);
-- RETURN G_PREFIX || G_CON || P_STRING || G_CON || P_SOB_NAME || G_CON || TO_CHAR (P_PERIOD, 'MON-YY') || G_CON;
END GET_JOURNAL_NAME;
FUNCTION GET_SOB (P_SOB_ID NUMBER)
RETURN GL_SETS_OF_BOOKS%ROWTYPE IS
R_SOB GL_SETS_OF_BOOKS%ROWTYPE;
BEGIN
BEGIN
SELECT *
INTO R_SOB
FROM GL_SETS_OF_BOOKS
WHERE 1 = 1
AND SET_OF_BOOKS_ID = P_SOB_ID;
EXCEPTION
WHEN OTHERS THEN
R_SOB := NULL;
END;
RETURN R_SOB;
END GET_SOB;
----------------------------------------------------------------------------------------------------------------------------------------------------
PROCEDURE PRE_SETTING (P_SOB_ID IN NUMBER,
P_PERIOD IN VARCHAR2,
P_SET_OF_BOOKS_ID OUT NUMBER,
P_PERIOD_NAME OUT VARCHAR2,
P_USER_JE_SOURCE_NAME OUT VARCHAR2,
P_USER_JE_CATEGORY_NAME OUT VARCHAR2,
P_BASE_CURRENCY_CODE OUT VARCHAR2,
P_ACCOUNTING_DATE OUT DATE,
P_GROUP_ID OUT NUMBER,
P_BATCH_NAME OUT VARCHAR2) IS
R_GSOB GL_SETS_OF_BOOKS%ROWTYPE;
BEGIN
P_SET_OF_BOOKS_ID := P_SOB_ID;
P_PERIOD_NAME := P_PERIOD;
P_USER_JE_SOURCE_NAME := 'Dos-Accounting';
P_USER_JE_CATEGORY_NAME := 'Transfer';
R_GSOB := GET_SOB (P_SOB_ID);
BEGIN
SELECT CURRENCY_CODE
INTO P_BASE_CURRENCY_CODE
FROM GL_SETS_OF_BOOKS
WHERE 1 = 1
AND SET_OF_BOOKS_ID = P_SOB_ID;
EXCEPTION
WHEN OTHERS THEN
P_BASE_CURRENCY_CODE := NULL;
END;
SELECT TO_DATE (P_PERIOD, 'MON-RR') INTO P_ACCOUNTING_DATE FROM DUAL;
SELECT GL_INTERFACE_CONTROL_S.NEXTVAL INTO P_GROUP_ID FROM DUAL;
-- P_BATCH_NAME := G_PREFIX || '樣品中心' || TO_CHAR (P_ACCOUNTING_DATE, 'yyyymmdd') || P_GROUP_ID;
P_BATCH_NAME := GET_BATCH_NAME ('SAMPLE OH', P_PERIOD, R_GSOB.SHORT_NAME);
END PRE_SETTING;
FUNCTION IMP_AD_SAMPLE_FAC (P_PERIOD VARCHAR2, P_SOB_ID NUMBER)
RETURN VARCHAR2 IS
CURSOR JOU (
P_PERIOD VARCHAR2,
P_SOB_ID NUMBER) IS
SELECT A.PERIOD_NAME,
LAST_DAY (TO_DATE (A.PERIOD_NAME, 'MON-RR')) ACCOUNTING_DATE,
A.FACTORY_ERP,
A.FACTORY,
G.SHORT_NAME,
G.SET_OF_BOOKS_ID,
SUM (A.AMOUNT) AMOUNT,
SUM (
A.AMOUNT
* RATE_CONVERSION ('USD',
DECODE (SHORT_NAME, 'CPV', 'CNY', 'VTX', 'VND', 'VPV', 'VND', 'USD'),
G_CONVERSION_TYPE_AV,
LAST_DAY (TO_DATE (A.PERIOD_NAME, 'MON-RR'))))
ACCOUNTED_AMOUNT
FROM ATK_AD_FACTORY_AMT_V A, ESB.MAPPING_MANUFACTORY M, GL_SETS_OF_BOOKS G
WHERE A.PERIOD_NAME = P_PERIOD
AND A.FACTORY_ERP = M.ERP_NAME
AND M.ATTRIBUTE4 = G.SHORT_NAME
AND A.AMOUNT IS NOT NULL
AND M.ATTRIBUTE5 = 'AD Sample'
AND G.SET_OF_BOOKS_ID = P_SOB_ID
GROUP BY A.PERIOD_NAME,
G.SHORT_NAME,
G.SET_OF_BOOKS_ID,
A.FACTORY,
A.FACTORY_ERP
ORDER BY G.SET_OF_BOOKS_ID;
LN_ORG_ID NUMBER;
LC_USER_NAME VARCHAR2 (100);
LC_USER_JE_SOURCE_NAME VARCHAR2 (255);
LC_USER_JE_CATEGORY_NAME VARCHAR2 (255);
LC_PERIOD_NAME VARCHAR2 (255);
LC_BASE_CURRENCY_CODE VARCHAR2 (15);
LC_BATCH_NAME VARCHAR2 (255);
LN_SET_OF_BOOKS_ID NUMBER;
LN_GROUP_ID NUMBER;
LC_JOURNAL_ENTRY_NAME VARCHAR2 (255);
LN_REQ_ID NUMBER;
X_DR_ACCT_CCID NUMBER;
X_CR_ACCT_CCID NUMBER;
V_DESCRIPTION VARCHAR2 (3000) := '一級樣品室/產區二級樣品室支援製樣/專案';
R_SOB GL_SETS_OF_BOOKS%ROWTYPE;
V_TXN_TYPE_CODE VARCHAR2 (30) := 'AD SAMPLE';
BEGIN
R_SOB := GET_SOB (P_SOB_ID);
LC_BASE_CURRENCY_CODE := R_SOB.CURRENCY_CODE;
LC_BATCH_NAME := GET_BATCH_NAME (V_TXN_TYPE_CODE, P_PERIOD, R_SOB.SHORT_NAME);
LC_JOURNAL_ENTRY_NAME := GET_JOURNAL_NAME (V_TXN_TYPE_CODE, P_PERIOD, R_SOB.SHORT_NAME);
--取得 GROUP_ID,BATCH_NAME
/* APPS.ATK_GL_COMMON_PKG.GET_COMMON_INFO(LN_ORG_ID,TO_DATE(P_PERIOD,'MON-RR') ,1206,
LC_USER_JE_SOURCE_NAME,LC_USER_JE_CATEGORY_NAME,
LC_PERIOD_NAME ,
LC_BASE_CURRENCY_CODE ,
LC_BATCH_NAME ,
LN_SET_OF_BOOKS_ID,
LN_GROUP_ID ) ; */
--- BATCH NAME 需大於 50 個字, 否則 BATCH NAME 將會使用 ORACLE DEFAULT.
-- SELECT G_PREFIX || 'AD SAMPLE' || '-' || P_PERIOD || '-' || 'Dos-Accounting' || '/' || 'Transfer' INTO LC_BATCH_NAME FROM DUAL;
-- BEGIN
-- SELECT G_PREFIX
-- || 'AD SAMPLE'
-- || '-'
-- || TO_CHAR (LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')), 'YYYYMMDD')
-- || LPAD (TO_NUMBER (NVL (MAX (SUBSTR (NAME, 19, 2)), '00')) + 1, 2, '0')
-- INTO LC_JOURNAL_ENTRY_NAME
-- FROM GL_JE_HEADERS
-- WHERE JE_SOURCE = '3' --Dos-Accounting
-- AND SET_OF_BOOKS_ID = P_SOB_ID
-- AND SUBSTR (NAME, 1, 18) LIKE G_PREFIX || 'AD SAMPLE' || '-' || TO_CHAR (LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')), 'YYYYMMDD') || '%';
-- EXCEPTION
-- WHEN OTHERS THEN
-- DBMS_OUTPUT.PUT_LINE ('Get sqlno Error!');
-- END;
SELECT GL_INTERFACE_CONTROL_S.NEXTVAL INTO LN_GROUP_ID FROM DUAL;
FOR AA IN JOU (P_PERIOD, P_SOB_ID) LOOP
/* DR.2891.00
CR.6210.96 ADM-Indirect Labor-AD Sample Support */
/*Step1-處理借方 */
BEGIN
SELECT ACCT_CCID
INTO X_DR_ACCT_CCID
FROM MK_AD_SAMPLE_ACCT_S
WHERE SHORT_NAME = AA.SHORT_NAME
AND DEPT_CODE = AA.FACTORY_ERP
AND DR_CR = 'DR';
EXCEPTION
WHEN OTHERS THEN
X_DR_ACCT_CCID := NULL;
END;
--DR INSERT GL INTERFACE
ATK_GL_COMMON_PKG.INSERT_GL_INTERFACE_ALL (LC_BATCH_NAME,
LC_JOURNAL_ENTRY_NAME,
AA.PERIOD_NAME,
'Dos-Accounting',
'Transfer',
LC_BASE_CURRENCY_CODE,
X_DR_ACCT_CCID,
V_DESCRIPTION,
AA.ACCOUNTING_DATE,
P_USER_ID,
P_SOB_ID,
LN_GROUP_ID,
AA.ACCOUNTED_AMOUNT,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
/*Step2-處理貸方 */
BEGIN
SELECT ACCT_CCID
INTO X_CR_ACCT_CCID
FROM MK_AD_SAMPLE_ACCT_S
WHERE SHORT_NAME = AA.SHORT_NAME
AND DEPT_CODE = AA.FACTORY_ERP
AND DR_CR = 'CR';
EXCEPTION
WHEN OTHERS THEN
X_CR_ACCT_CCID := NULL;
END;
-- CR INSERT GL INTERFACE
ATK_GL_COMMON_PKG.INSERT_GL_INTERFACE_ALL (LC_BATCH_NAME,
LC_JOURNAL_ENTRY_NAME,
AA.PERIOD_NAME,
'Dos-Accounting',
'Transfer',
LC_BASE_CURRENCY_CODE,
X_CR_ACCT_CCID,
V_DESCRIPTION,
AA.ACCOUNTING_DATE,
P_USER_ID,
P_SOB_ID,
LN_GROUP_ID,
0,
AA.ACCOUNTED_AMOUNT,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
COMMIT;
/* Lock由FORM控制,Lock後再拋傳票,避免資料異動*/
/* UPDATE ATK_AD_SAMPLE_QTY
SET LOCK_FLAG='Y'
WHERE PERIOD_NAME=AA.PERIOD_NAME
AND FACTORY=AA.FACTORY;
COMMIT; */
END LOOP;
-- Run Journal Import
LN_REQ_ID := ATK_GL_COMMON_PKG.INSERT_GL_CONTROL_PASS_SOURCE (P_SOB_ID, P_USER_ID, LN_GROUP_ID, 'Dos-Accounting');
IF LN_REQ_ID = -1 THEN
DBMS_OUTPUT.PUT_LINE ('AD Sample Failure!! GROUP ID:' || LN_GROUP_ID);
RETURN 'AD Sample Failure!! GROUP ID:' || LN_GROUP_ID;
ELSE
DBMS_OUTPUT.PUT_LINE ('AD Sample Success!! Concurrent ID:' || LN_REQ_ID);
RETURN 'AD Sample Success!! Concurrent ID:' || LN_REQ_ID;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RETURN 'AD Sample Error:' || SQLERRM;
END IMP_AD_SAMPLE_FAC;
FUNCTION IMP_AD_SAMPLE_TPE (P_PERIOD VARCHAR2, P_SOB_ID NUMBER DEFAULT NULL)
RETURN VARCHAR2 IS
CURSOR JOU (
P_PERIOD VARCHAR2,
P_SET_OF_BOOKS_ID NUMBER) IS
SELECT A.PERIOD_NAME,
A.SET_OF_BOOKS_ID,
MK_GL_PUB.SOB2SEG3 (MK_GL_PUB.GET_SHORT_NAME (A.SET_OF_BOOKS_ID)) SEGMENT3,
A.CUSTOMER_NAME,
A.FACTORY,
A.FACTORY_ERP,
A.CURRENCY_CODE,
LAST_DAY (TO_DATE (A.PERIOD_NAME, 'MON-RR')) ACCOUNTING_DATE,
CASE
WHEN A.FACTORY_ERP NOT LIKE 'S%'
AND A.FACTORY LIKE '%SVN-TPL%' THEN
'SVN-TPL'
WHEN A.FACTORY_ERP NOT LIKE 'S%'
AND (A.FACTORY LIKE '%SVN-LR%'
OR A.FACTORY LIKE 'LR-%') THEN
'SVN-LR'
WHEN A.FACTORY_ERP LIKE 'S%'
AND A.CUSTOMER_NAME NOT IN ('DSH', 'MST', 'WOW') THEN
'TPV'
WHEN A.FACTORY_ERP LIKE 'S%'
AND A.CUSTOMER_NAME IN ('DSH', 'MST', 'WOW') THEN
'TPV'
ELSE
SUBSTR (A.FACTORY, 1, INSTR (A.FACTORY, '-') - 1)
END
ORIGIN_COUNTRY,
A.DEPT_NAME,
M.ERP_NAME,
RATE_CONVERSION (A.CURRENCY_CODE, 'TWD', G_CONVERSION_TYPE_AV, LAST_DAY (TO_DATE (A.PERIOD_NAME, 'MON-RR'))) RATE,
SUM (A.AMOUNT) AMOUNT,
SUM (
A.AMOUNT
* RATE_CONVERSION (A.CURRENCY_CODE, 'TWD', G_CONVERSION_TYPE_AV, LAST_DAY (TO_DATE (A.PERIOD_NAME, 'MON-RR'))))
AS ACCOUNTED_AMOUNT
FROM APPS.ATK_AD_SAMPLE_AMT_V A, ESB.PLN_MAPPING_DEPT M
WHERE A.DEPT_NAME = M.ATTRIBUTE4
AND M.ATTRIBUTE5 = 'AD Sample'
AND A.PERIOD_NAME = P_PERIOD
AND A.AMOUNT IS NOT NULL
AND A.FACTORY_ERP IS NOT NULL
AND NVL (A.SET_OF_BOOKS_ID, -1) = NVL (P_SET_OF_BOOKS_ID, NVL (A.SET_OF_BOOKS_ID, -1))
GROUP BY A.PERIOD_NAME,
A.SET_OF_BOOKS_ID,
A.CUSTOMER_NAME,
A.FACTORY,
A.FACTORY_ERP,
A.CURRENCY_CODE,
CASE
WHEN A.FACTORY_ERP NOT LIKE 'S%'
AND A.FACTORY LIKE '%SVN-TPL%' THEN
'SVN-TPL'
WHEN A.FACTORY_ERP NOT LIKE 'S%'
AND (A.FACTORY LIKE '%SVN-LR%'
OR A.FACTORY LIKE 'LR-%') THEN
'SVN-LR'
WHEN A.FACTORY_ERP LIKE 'S%'
AND A.CUSTOMER_NAME NOT IN ('DSH', 'MST', 'WOW') THEN
'TPV'
WHEN A.FACTORY_ERP LIKE 'S%'
AND A.CUSTOMER_NAME IN ('DSH', 'MST', 'WOW') THEN
'TPV'
ELSE
SUBSTR (A.FACTORY, 1, INSTR (A.FACTORY, '-') - 1)
END,
A.DEPT_NAME,
M.ERP_NAME
ORDER BY M.ERP_NAME;
LN_ORG_ID NUMBER;
LC_USER_NAME VARCHAR2 (100);
LC_USER_JE_SOURCE_NAME VARCHAR2 (255);
LC_USER_JE_CATEGORY_NAME VARCHAR2 (255);
LC_PERIOD_NAME VARCHAR2 (255);
LC_BASE_CURRENCY_CODE VARCHAR2 (15);
LC_BATCH_NAME VARCHAR2 (255);
LN_SET_OF_BOOKS_ID NUMBER;
LN_GROUP_ID NUMBER;
LC_JOURNAL_ENTRY_NAME VARCHAR2 (255);
LN_REQ_ID NUMBER;
X_DR_ACCT_CCID NUMBER;
X_CR_ACCT_CCID NUMBER;
P_CURRENCY_CODE VARCHAR2 (30) := 'USD';
V_DESCRIPTION VARCHAR2 (3000) := '一級樣品室/產區二級樣品室支援製樣/專案';
R_SOB GL_SETS_OF_BOOKS%ROWTYPE;
V_TXN_TYPE_CODE VARCHAR2 (30) := 'AD SAMPLE';
BEGIN
R_SOB := GET_SOB (P_SOB_ID);
-- LC_BASE_CURRENCY_CODE := R_SOB.CURRENCY_CODE;
SELECT ORGANIZATION_ID
INTO LN_ORG_ID
FROM ORG_ORGANIZATION_DEFINITIONS
WHERE ORGANIZATION_CODE = 'TPV';
--取得 GROUP_ID,BATCH_NAME
APPS.ATK_GL_COMMON_PKG.GET_COMMON_INFO (LN_ORG_ID,
TO_DATE (P_PERIOD, 'MON-RR'),
P_USER_ID,
LC_USER_JE_SOURCE_NAME,
LC_USER_JE_CATEGORY_NAME,
LC_PERIOD_NAME,
LC_BASE_CURRENCY_CODE,
LC_BATCH_NAME,
LN_SET_OF_BOOKS_ID,
LN_GROUP_ID);
LC_BATCH_NAME := GET_BATCH_NAME (V_TXN_TYPE_CODE, P_PERIOD, R_SOB.SHORT_NAME);
LC_JOURNAL_ENTRY_NAME := GET_JOURNAL_NAME (V_TXN_TYPE_CODE, P_PERIOD, R_SOB.SHORT_NAME);
--- BATCH NAME 需大於 50 個字, 否則 BATCH NAME 將會使用 ORACLE DEFAULT.
-- SELECT G_PREFIX || 'AD SAMPLE' || '-' || P_PERIOD INTO LC_BATCH_NAME FROM DUAL;
--
-- BEGIN
-- SELECT G_PREFIX
-- || 'AD SAMPLE'
-- || '-'
-- || TO_CHAR (LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')), 'YYYYMMDD')
-- || LPAD (TO_NUMBER (NVL (MAX (SUBSTR (NAME, 19, 2)), '00')) + 1, 2, '0')
-- INTO LC_JOURNAL_ENTRY_NAME
-- FROM GL_JE_HEADERS
-- WHERE JE_SOURCE = '3' --Dos-Accounting
-- AND SET_OF_BOOKS_ID = LN_SET_OF_BOOKS_ID
-- AND SUBSTR (NAME, 1, 18) LIKE G_PREFIX || 'AD SAMPLE' || '-' || TO_CHAR (LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')), 'YYYYMMDD') || '%';
-- EXCEPTION
-- WHEN OTHERS THEN
-- DBMS_OUTPUT.PUT_LINE ('Get sqlno Error!');
-- END;
FOR AA IN JOU (P_PERIOD, P_SOB_ID) LOOP
/* DR.15.01.XXXXX.6144.55.000 XXXXX:部門別
DR. 15.01.00000.6144.50.097 DSH
DR. 15.01.00000.6144.50.052 WOW
DR. 15.01.01530.6144.50.000 MST
CR.15.01.09901.2891.00.619 PHL菲
CR.15.01.09902.2891.00.669 CHN中
CR.15.01.09910.2891.00.629 CAB柬
CR.15.01.09915.2891.00.640 NVN北越
CR.15.01.09909.2891.00.650 SVN-TPL
CR.15.01.09909.2891.00.651 SVN-LR
CR.15.01.09917.2891.00.639 IND印
CR.15.01.SXXXX.6144.55.000 自製樣品中心 /外發 */
/*Step1-處理借方 */
IF AA.ORIGIN_COUNTRY = 'TPV' THEN
IF AA.CUSTOMER_NAME = 'DSH' THEN /*15.01.00000.6144.55.097*/
X_DR_ACCT_CCID := 167637;
ELSIF AA.CUSTOMER_NAME = 'WOW' THEN
X_DR_ACCT_CCID := 167467; /*15.01.00000.6144.55.052*/
ELSIF AA.CUSTOMER_NAME = 'MST' THEN
X_DR_ACCT_CCID := 71348; /*15.01.01530.6144.55.000*/
ELSE
BEGIN
SELECT ACCT_CCID
INTO X_DR_ACCT_CCID
FROM MK_AD_SAMPLE_ACCT_S
WHERE SHORT_NAME = 'TPV'
AND DEPT_CODE = AA.ERP_NAME
AND DR_CR = 'DR';
EXCEPTION
WHEN OTHERS THEN
X_DR_ACCT_CCID := NULL;
END;
END IF;
ELSE
BEGIN
SELECT ACCT_CCID
INTO X_DR_ACCT_CCID
FROM MK_AD_SAMPLE_ACCT_S
WHERE SHORT_NAME = 'TPV'
AND DEPT_CODE = AA.ERP_NAME
AND DR_CR = 'DR';
EXCEPTION
WHEN OTHERS THEN
X_DR_ACCT_CCID := NULL;
END;
END IF;
--DR INSERT GL INTERFACE
-- atk_gl_common_pkg.insert_gl_interface_all_curr
INSERT_GL_INTERFACE_ALL_CURR (LC_BATCH_NAME,
LC_JOURNAL_ENTRY_NAME,
AA.PERIOD_NAME,
LC_USER_JE_SOURCE_NAME,
LC_USER_JE_CATEGORY_NAME,
AA.CURRENCY_CODE,
LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')),
AA.RATE,
X_DR_ACCT_CCID,
V_DESCRIPTION,
AA.ACCOUNTING_DATE,
P_USER_ID,
LN_SET_OF_BOOKS_ID,
LN_GROUP_ID,
AA.AMOUNT,
0,
AA.ACCOUNTED_AMOUNT,
0,
NULL,
NULL,
AA.CUSTOMER_NAME,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
/*Step2-處理貸方 ;直接Assign CCID*/
IF AA.ORIGIN_COUNTRY = 'TPV' THEN
BEGIN
SELECT ACCT_CCID
INTO X_CR_ACCT_CCID
FROM MK_AD_SAMPLE_ACCT_S
WHERE SHORT_NAME = 'TPV'
AND DEPT_CODE = AA.FACTORY_ERP
AND DR_CR = 'CR';
EXCEPTION
WHEN OTHERS THEN
X_CR_ACCT_CCID := NULL;
END;
ELSE
G_GCC.SEGMENT1 := '15';
G_GCC.SEGMENT2 := '01';
G_GCC.SEGMENT3 := AA.SEGMENT3;
G_GCC.SEGMENT4 := '2891';
G_GCC.SEGMENT5 := '00';
IF AA.ORIGIN_COUNTRY = 'SVN-TPL' THEN
G_GCC.SEGMENT6 := MK_GL_PUB.SOB2SEG6 (MK_GL_PUB.GET_SHORT_NAME (AA.SET_OF_BOOKS_ID), 'TPM', '64');
ELSIF AA.ORIGIN_COUNTRY = 'SVN-LR' THEN
G_GCC.SEGMENT6 := MK_GL_PUB.SOB2SEG6 (MK_GL_PUB.GET_SHORT_NAME (AA.SET_OF_BOOKS_ID), 'TPM', '65');
ELSE
G_GCC.SEGMENT6 := MK_GL_PUB.SOB2SEG6 (MK_GL_PUB.GET_SHORT_NAME (AA.SET_OF_BOOKS_ID), 'TPM', NULL);
END IF;
G_GCC.CONCATENATED_SEGMENTS :=
G_GCC.SEGMENT1
|| '.'
|| G_GCC.SEGMENT2
|| '.'
|| G_GCC.SEGMENT3
|| '.'
|| G_GCC.SEGMENT4
|| '.'
|| G_GCC.SEGMENT5
|| '.'
|| G_GCC.SEGMENT6;
X_CR_ACCT_CCID := MK_GL_PUB.GET_CCID (LN_SET_OF_BOOKS_ID, G_GCC.CONCATENATED_SEGMENTS, G_MSG);
END IF;
-- IF AA.ORIGIN_COUNTRY = 'PHL' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09901.2891.00.619');
-- -- X_CR_ACCT_CCID := 118515;
-- ELSIF AA.ORIGIN_COUNTRY = 'CHN' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09902.2891.00.669');
-- -- X_CR_ACCT_CCID := 120499;
-- ELSIF AA.ORIGIN_COUNTRY = 'CAB' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09910.2891.00.629');
-- -- X_CR_ACCT_CCID := 118511;
-- ELSIF AA.ORIGIN_COUNTRY = 'NVN' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09915.2891.00.640');
-- -- X_CR_ACCT_CCID := 118513;
-- ELSIF AA.ORIGIN_COUNTRY = 'SVN-TPL' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09915.2891.00.650');
-- -- X_CR_ACCT_CCID := 118514;
-- ELSIF AA.ORIGIN_COUNTRY = 'SVN-LR' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09915.2891.00.651');
-- -- X_CR_ACCT_CCID := 133832;
-- ELSIF AA.ORIGIN_COUNTRY = 'IND' THEN
-- x_cr_acct_ccid := mk_gl_pub.get_ccid ('15.01.09905.2891.00.639');
-- -- X_CR_ACCT_CCID := 118776;
-- ELSIF AA.ORIGIN_COUNTRY = 'TPV' THEN
-- BEGIN
-- SELECT ACCT_CCID
-- INTO X_CR_ACCT_CCID
-- FROM MK_AD_SAMPLE_ACCT_S
-- WHERE SHORT_NAME = 'TPV'
-- AND DEPT_CODE = AA.FACTORY_ERP
-- AND DR_CR = 'CR';
-- EXCEPTION
-- WHEN OTHERS THEN
-- X_CR_ACCT_CCID := NULL;
-- END;
-- END IF;
-- CR INSERT GL INTERFACE
-- atk_gl_common_pkg.insert_gl_interface_all_curr
INSERT_GL_INTERFACE_ALL_CURR (LC_BATCH_NAME,
LC_JOURNAL_ENTRY_NAME,
AA.PERIOD_NAME,
LC_USER_JE_SOURCE_NAME,
LC_USER_JE_CATEGORY_NAME,
AA.CURRENCY_CODE,
LAST_DAY (TO_DATE (P_PERIOD, 'MON-RR')),
AA.RATE,
X_CR_ACCT_CCID,
V_DESCRIPTION,
AA.ACCOUNTING_DATE,
P_USER_ID,
LN_SET_OF_BOOKS_ID,
LN_GROUP_ID,
0,
AA.AMOUNT,
0,
AA.ACCOUNTED_AMOUNT,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
COMMIT;
END LOOP;
-- Run Journal Import
LN_REQ_ID := ATK_GL_COMMON_PKG.INSERT_GL_CONTROL (LN_SET_OF_BOOKS_ID, P_USER_ID, LN_GROUP_ID);
IF LN_REQ_ID = -1 THEN
DBMS_OUTPUT.PUT_LINE ('TPV-AD Sample Failure!! GROUP ID:' || LN_GROUP_ID);
RETURN ' TPV-AD Sample Failure!! GROUP ID:' || LN_GROUP_ID;
ELSE
DBMS_OUTPUT.PUT_LINE ('(TPV-AD Sample Success!! Concurrent ID:' || LN_REQ_ID);
RETURN 'TPV-AD Sample Success!! Concurrent ID:' || LN_REQ_ID || ' ; Group ID: ' || LN_GROUP_ID;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
RETURN 'TPV-AD Sample Error:' || SQLERRM;
END IMP_AD_SAMPLE_TPE;
FUNCTION IMP_FA_SPECIAL_EXP_FAC (P_PERIOD VARCHAR2, P_SOB_ID NUMBER)
RETURN VARCHAR2 IS
CURSOR JOU (P_SOB_ID NUMBER) IS