DBA Data[Home] [Help]

PACKAGE BODY: APPS.AR_FLEXBUILDER_WF_PKG

Source


1 PACKAGE BODY AR_FLEXBUILDER_WF_PKG AS
2 /* $Header: ARFLBMAB.pls 115.9 2002/11/18 21:44:20 anukumar ship $  */
3 
4 FUNCTION SUBSTITUTE_BALANCING_SEGMENT ( X_ARFLEXNUM IN NUMBER
5                                        ,X_ARORIGCCID IN NUMBER
6                                        ,X_ARSUBSTICCID IN NUMBER
7                                        ,X_return_ccid IN OUT NOCOPY number
8                                        ,X_concat_segs IN OUT NOCOPY varchar2
9                                        ,X_concat_ids  IN OUT NOCOPY varchar2
10                                        ,X_concat_descrs IN OUT NOCOPY varchar2
11                                        ,X_ARERROR IN OUT NOCOPY VARCHAR2 ) RETURN BOOLEAN IS
12 
13 itemtype varchar2(30) := 'ARSBALSG';
14 itemkey  varchar2(30);
15 result   boolean;
16 l_itemkey  varchar2(30); -- Bug 1936354.
17 l_new_combination  boolean;  -- Bug 1936354.
18 l_insert_if_new varchar2(10); -- Bug 1936354
19 l_insert_new boolean; -- Bug 1936354
20 
21 BEGIN
22    --arp_standard.debug('AR_FLEXBUILDER_WF_PKG.SUBSTITUTE_BALANCING_SEGMENT (+) ');
23    --arp_standard.debug('Orig Ccid = ' || to_char(X_ARORIGCCID));
24    --arp_standard.debug('Substi Ccid = ' || to_Char(X_ARSUBSTICCID));
25 
26 
27    itemkey := FND_FLEX_WORKFLOW.INITIALIZE ( 'SQLGL'
28                                              ,'GL#'
29                                              ,X_ARFLEXNUM
30                                              ,'ARSBALSG');
31 
32    -- Initialize the WorkFlow Item Attributes
33 
34    wf_engine.SetItemAttrNumber ( itemtype => itemtype
35                                 ,itemkey  => itemkey
36                                 ,aname    => 'CHART_OF_ACCOUNTS_ID'
37                                 ,avalue   => X_ARFLEXNUM );
38 
39    wf_engine.SetItemAttrNumber ( itemtype => itemtype
40                                 ,itemkey  => itemkey
41                                 ,aname    => 'ARORIGCCID'
42                                 ,avalue   => X_ARORIGCCID);
43 
44    wf_engine.SetItemAttrNumber ( itemtype => itemtype
45                                 ,itemkey  => itemkey
46                                 ,aname    => 'ARSUBSTICCID'
47                                 ,avalue   => X_ARSUBSTICCID);
48 
49  -- Bug 1936354 : Comment the below code, added the new code below comments.
50 
51 /*
52    result := FND_FLEX_WORKFLOW.GENERATE('ARSBALSG'
53                                        ,itemkey
54                                        ,X_return_ccid
55                                        ,X_concat_segs
56                                        ,X_concat_ids
57                                        ,X_concat_descrs
58                                        ,X_ARERROR);
59 */
60 
61      --  Bug 1936354
62 
63            BEGIN
64 		SELECT 	DYNAMIC_INSERTS_ALLOWED_FLAG
65 		INTO   	l_insert_if_new
66 		FROM 	fnd_id_flex_Structures ffs,
67 		       	ar_system_parameters asp,
68      			gl_sets_of_books glsob
69 		WHERE   ffs.APPLICATION_ID = 101
70 		AND   	ffs.ID_FLEX_CODE = 'GL#'
71 		AND   	ffs.ID_FLEX_NUM = glsob.chart_of_accounts_id
72 		AND   	glsob.set_of_books_id = asp.set_of_books_id;
73 
74 	    EXCEPTION
75   			WHEN OTHERS THEN l_insert_if_new := 'N';
76        	    END;
77 
78   IF l_insert_if_new = 'Y' THEN
79        l_insert_new := TRUE;
80   ELSE
81        l_insert_new := FALSE;
82   END IF;
83 
84      result := FND_FLEX_WORKFLOW.GENERATE(itemtype => 'ARSBALSG',
85                                           itemkey => itemkey,
86                                           insert_if_new => l_insert_new,
87                                           ccid => x_return_ccid,
88                                           concat_segs => x_concat_segs,
89                                           concat_ids => x_concat_ids,
90                                           concat_descrs => x_concat_descrs,
91                                           error_message => X_ARERROR,
92                                           new_combination => l_new_combination
93 					  );
94 
95 
96    --arp_standard.debug('Return Ccid = ' || to_Char(X_return_ccid));
97 
98    IF X_return_ccid = -1 THEN
99    -- This means new ccid has to be generated
100 
101      X_return_ccid := FND_FLEX_EXT.GET_CCID ( 'SQLGL'
102                                       ,'GL#'
103                                       ,X_ARFLEXNUM
104                                       ,TO_CHAR(sysdate,'YYYY/MM/DD HH24:MI:SS')
105                                       ,X_concat_segs
106                                       );
107 
108      --arp_standard.debug('Return Ccid After GetCCid = ' || to_Char(X_return_ccid));
109 
110      IF X_return_ccid = 0 THEN
111      -- error ocurred in flex package
112 
113        APP_EXCEPTION.RAISE_EXCEPTION;
114      END IF;
115 
116    END IF;
117 
118    return result;
119 
120    --arp_standard.debug('AR_FLEXBUILDER_WF_PKG.SUBSTITUTE_BALANCING_SEGMENT (-) ');
121 EXCEPTION
122   WHEN OTHERS THEN
123     --arp_standard.debug('AR_FLEXBUILDER_WF_PKG.SUBSTITUTE_BALANCING_SEGMENT - Exception ' );
124     RAISE;
125 END;
126 END;