DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_PRINT

Source


1 package body FND_PRINT as
2 /* $Header: AFPRGPIB.pls 120.3 2006/03/06 13:21:39 pferguso ship $ */
3 
4 
5 
6 /*
7 **  STYLE_INFORMATION  -
8 */
9 function STYLE_INFORMATION(style    in varchar2,
10                            p_width  out nocopy number,
11                            p_length out nocopy number) return boolean is
12 
13 begin
14 
15     if (style is null)
16     then
17         return false;
18     end if;
19 
20     select width, length
21       into p_width, p_length
22       from fnd_printer_styles
23       where printer_style_name = style;
24 
25     return true;
26 
27 exception
28    when others then
29      return false;
30 
31 end STYLE_INFORMATION;
32 
33 
34 
35 /*
36 **  PRINTER_INFORMATION -
37 */
38 function PRINTER_INFORMATION(printer in varchar2,
39                              style   in varchar2) return boolean is
40 
41    dummy    fnd_printer.printer_name%TYPE;
42 begin
43 
44    select fp.printer_name
45      into dummy
46      from fnd_printer fp, fnd_printer_information fpi
47      where fp.printer_name = printer
48      and fp.printer_type = fpi.printer_type
49      and fpi.printer_style = style;
50 
51    return true;
52 
53 exception
54    when others then
55      return false;
56 
57 end PRINTER_INFORMATION;
58 
59 
60 
61 
62 procedure SET_INVALID_STYLE( STYLE     in varchar2, PRINTER in varchar2,
63                              MINWIDTH  in number,   MAXWIDTH  in number,
64                              MINLENGTH in number,   MAXLENGTH in number) is
65 
66 begin
67         FND_MESSAGE.SET_NAME('FND', 'PRT-Invalid style');
68         FND_MESSAGE.SET_TOKEN('STYLE', style, FALSE);
69 
70         if (minwidth <> 0)
71         then
72             FND_MESSAGE.SET_TOKEN('MINWIDTH', minwidth, FALSE);
73         else
74             FND_MESSAGE.SET_TOKEN('MINWIDTH', 'FND-None', TRUE);
75         end if;
76 
77         if (maxwidth <> 0)
78         then
79             FND_MESSAGE.SET_TOKEN('MAXWIDTH', maxwidth, FALSE);
80         else
81             FND_MESSAGE.SET_TOKEN('MAXWIDTH', 'FND-None', TRUE);
82         end if;
83 
84         if (minlength <> 0)
85         then
86             FND_MESSAGE.SET_TOKEN('MINLENGTH', minlength, FALSE);
87         else
88             FND_MESSAGE.SET_TOKEN('MINLENGTH', 'FND-None', TRUE);
89         end if;
90 
91         if (maxlength <> 0)
92         then
93             FND_MESSAGE.SET_TOKEN('MAXLENGTH', maxlength, FALSE);
94         else
95             FND_MESSAGE.SET_TOKEN('MAXLENGTH', 'FND-None', TRUE);
96         end if;
97 
98         FND_MESSAGE.SET_TOKEN('PRINTER', printer, FALSE);
99 
100 end SET_INVALID_STYLE;
101 
102 
103 /*
104  **   GET_STYLE -
105 */
106 function GET_STYLE(STYLE      in  varchar2,
107                    MINWIDTH   in number,  MAXWIDTH  in number,
108                    MINLENGTH  in number,  MAXLENGTH in number,
109                    REQUIRED   in boolean, PRINTER in varchar2,
110                    VALIDSTYLE out nocopy varchar2) return boolean is
111 
112 cursor C1(MINW number, MAXW number, MINL number, MAXL number) is
113     select  printer_style_name
114             from fnd_printer_styles
115         where width >= minw
116         and (maxw is null or width <= maxw)
117         and length >= minl
118         and (maxl is null or length <= maxl)
119         order by sequence;
120 
121 width  number(4) := 0;
122 length number(4) := 0 ;
123 valid  boolean := FALSE;
124 print_style varchar2(30);
125 
126 begin
127 
128     validstyle := NULL;
129 
130     valid := STYLE_INFORMATION(style, width, length);
131 
132     if ((valid = FALSE) and ( (width = 0) or (length = 0) ) )
133     then  -- could not find a valid style.
134         return FALSE;
135     end if;
136 
137     if ( (minwidth is not null and minwidth > width)    or
138          (maxwidth is not null and maxwidth < width)    or
139          (minlength is not null and minlength > length) or
140              (maxlength is not null and maxlength < length)
141        )
142     then
143         -- set valid to FALSE
144         -- couldnt find a valid printer
145         valid := FALSE;
146     end if;
147 
148     if (valid = TRUE)
149     then    -- copy if found
150         validstyle := style;
151         return TRUE;
152     end if;
153 
154     if (required = TRUE)
155     then
156 
157         set_invalid_style(style, printer, minwidth, maxwidth, minlength, maxlength);
158         return FALSE;
159 
160     end if;
161 
162      ----------------------------------------------------------------------
163      --   Style is invalid but not required.                             --
164      --   Find a valid style w/ the lowest preference sequence.          --
165      ----------------------------------------------------------------------
166 
167      if (printer is not null and  PRINTER_INFORMATION(printer, style) = FALSE) then
168        set_invalid_style(style, printer, minwidth, maxwidth, minlength, maxlength);
169        return FALSE;
170      end if;
171 
172      open C1(minwidth, maxwidth, minlength, maxlength);
173      fetch C1 into print_style;
174      if C1%NOTFOUND then
175         close C1;
176         set_invalid_style(style, printer, minwidth, maxwidth, minlength, maxlength);
177         return FALSE;
178      end if;
179 
180      close C1;
181      validstyle := print_style;
182      return TRUE;
183 
184 exception
185     when OTHERS then
186         if C1%ISOPEN then
187           close C1;
188         end if;
189         return FALSE;
190 
191 end GET_STYLE;
192 
193 
194 
195 end FND_PRINT;