Decode variant data w/o using 'Variant To Data' function.
I need to decode variant data w/o having foreknowledge of the type used to create it. That is, I'm using the 'Flattened String To Variant' function which gives me the info I need, but it's all contained within one indicator. I need some way to break this info down into its constituent elements.
For instance, let's say I have the flattened data and type descriptor from a cluster with two elements, a boolean and a string, but not the structure itself. Passing this flattened data and/or the type descriptor into a function, I would get a 2D array (or the like) as output containing the name of the boolean (its label), its value, and the name of the string and its corresponding value.
There must be a way to
do this, and I suspect it's been done already, but I can't find any reference to it.
I have attached a file named Test.vi which demostrates this problem.
Remember, even though I know the name of the control, I won't know the type, so I cannot use the 'Variant To Data' function to deference these values. I can make ready use of DLLs, CINs, or LabVIEW code for the solution.
Thanks ahead of time for any help! Greg
Attachments:
Test.vi 26 KB
You might be able to take advantage of the Variant to Flattened String VI from the Advanced>>Data Manipulation>>Variants pallette. This VI converts a Variant to a flattened data string and a type descriptor. The type descriptor is explained in ap note 154. You might be able to create a VI that would parse data from the flattened data string using the type descriptor. You might have to represent each piece of data as a flattened string to work around the data flow issues in LabVIEW.
Similar Messages
-
How to data log graphs using front panel data logging?
Hello I have a VI that collects data from DAQmx thermocouple readings and graphs the temperature vs time using a while loop to collect data and graph. I have 9 control operators that define the correction factor of the thermocouples.
I want to create a datalogging using the option under Operations>Data Logging
When I retrieve the data the only information that is present are the control operators correction factors that I defined. The graphed data that was created is not retrieved.
Is there a solution to show the graphed data plots that were created on the front panel? They remain unchanged from the last run of the VI or blank if I open the VI without having ran the program.
Thank you.This is expected for the Data Logging in LabVIEW. If you want to record the signla data, use the Write to Measurement File Express VI. Here's a link with a walk-through:
http://www.ni.com/academic/students/learn-daq/data-logging/
The Data Logging from the Operate Menu is for recording front panel control(s), as you have observed.
Mark P.
Applications Engineer
National Instruments
www.ni.com/support -
Generating Data for INSERT using a Stored Procedure, Function and Cursor
I've written a function that I finally got to compile, but was not successful in importing and inserting the data needed to populate a table with at least 1800 rows. Here's what I needed to do:
-- Generate a random test score ranging from 20 to 100 (already done)
-- Generate a random final grade for the course ranging from 4 to 0 (representing A to F) (already done, but question below.
-- Use conditional statements based on the counter to assign three courses (already done -- see SQL statements)
-- Process no more than 95% of the students (300) for test 1.
-- For test 2, process no more than 80% of the students who took test 1. Student cannot take test 2 unless the student takes test 1 (does this require a trigger? If so, how would I go about doing this?)
-- Use a function or another subprocedure to process the grade using IF-ELSIF statements
For example, I've tried the following statements:
For procedures
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 6;
AND for functions:
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
RETURN (6);
RETURN;
- or -
IF birth_date BETWEEN to_date('01-Jan-89','dd-Mon-yy') AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 9
RETURN school_grade;
-- Read the birth_date into the main procedure so that the value returned from the subprocedure or function can populate the birth_date column.
To give you an idea of what I've already done:
SQL>
SQL> CREATE OR REPLACE PROCEDURE add_tests (v_school_grade IN NUMBER) AS
2
3 v_counter NUMBER(3) := 0;
4 v_num_students CONSTANT NUMBER(3) := 300;
5 v_students_test1 NUMBER := 0;
6 v_students_test2 NUMBER := 0;
7 v_student_id VARCHAR2(5);
8 v_course1 VARCHAR2(2);
9 v_course2 VARCHAR2(2);
10 v_course3 VARCHAR2(2);
11 v_course4 VARCHAR2(2);
12 v_student_grade NUMBER(1) := 0;
13 v_test_score NUMBER(3) := 0;
14 v_course_final_grade NUMBER(1) := 0;
15 v_birth_date DATE;
16
17 FUNCTION pkg_get_grade RETURN NUMBER
18 IS
19
20 v_birth_date DATE;
21 v_school_grade NUMBER(1) :=0;
22
23 CURSOR grade_cur IS
24 SELECT birth_date FROM students;
25
26 BEGIN
27 OPEN grade_cur;
28 LOOP
29 FETCH grade_cur INTO v_birth_date;
30
31 EXIT WHEN grade_cur%NOTFOUND;
32
33 -- Assign student grade
34
35 -- 9th Grade
36
37 IF v_birth_date < TO_DATE('01-Jan-87','DD-Mon-YY') THEN
38 v_school_grade := 9;
39
40 -- 8th grade
41
42 ELSIF v_birth_date BETWEEN
43 TO_DATE('01-Jan-87','DD-Mon-YY') AND
44 TO_DATE('31-Dec-87','DD-Mon-YY') THEN
45
46 v_school_grade := 8;
47
48 -- 7th grade
49
50 ELSIF v_birth_date BETWEEN
51 TO_DATE('01-Jan-88','DD-Mon-YY') AND
52 TO_DATE('31-Dec-88','DD-Mon-YY') THEN
53
54 v_school_grade := 7;
55
56 -- 6th grade
57
58 ELSIF v_birth_date BETWEEN
59 TO_DATE('01-Jan-89','DD-Mon-YY') AND
60 TO_DATE('31-Dec-89','DD-Mon-YY') THEN
61
62 v_school_grade := 6;
63
64 -- 5th grade
65
66 ELSIF v_birth_date > TO_DATE('31-Dec-89','DD-Mon-YY') THEN
67
68 v_school_grade := 5;
69
70 END IF; -- end if loop for student's grade
71 END LOOP; -- end loop for grade_cur
72 CLOSE grade_cur; -- close cursor for assigning grade
73 RETURN v_school_grade;
74
75 END pkg_get_grade;
76
77 PROCEDURE delete_test_info AS
78
79 BEGIN
80
81 DELETE FROM student_facts;
82
83 END delete_test_info;
84
85 BEGIN
86
87 -- Process student for tests
88
89 WHILE (v_counter <= v_num_students) LOOP
90 v_counter := v_counter + 1; -- initialize counter
91
92 -- Set student id
93
94 v_student_id := 'S'| |v_counter;
95
96 -- portion of students taking beginning of year tests
97
98 v_students_test1 := v_num_students * .95;
99
100
101 -- Portion of students taking end of year tests
102
103 v_students_test2 := v_students_test1 * .80;
104
105
106 -- Est. test scores between 20 and 100
107
108 v_test_score := random.rand_max(80) + 20;
109
110
111 -- Est. final grade for course between 0 and 4
112
113 v_course_final_grade := random.rand_max(4);
114
115
116 -- Process tests for courses
117
118 IF v_counter < ROUND(v_num_students * .20) THEN
119 v_course1 := 'C1';
120 v_course2 := 'C2';
121 v_course3 := 'C3';
122
123 ELSIF v_counter BETWEEN ROUND(v_num_students * .20)
124 AND ROUND(v_num_students * .40) THEN
125
126 v_course1 := 'C2';
127 v_course2 := 'C1';
128 v_course3 := 'C3';
129
130 ELSE IF v_counter BETWEEN ROUND(v_num_students * .40)
131 AND ROUND(v_num_students * .60) THEN
132
133 v_course1 := 'C3';
134 v_course2 := 'C1';
135 v_course3 := 'C2';
136
137 ELSE IF v_counter BETWEEN (v_num_students * .60)
138 AND ROUND(v_num_students * .80) THEN
139
140 v_course1 := 'C3';
141 v_course2 := 'C1';
142 v_course3 := 'C2';
143
144 ELSE
145 v_course1 := 'C4';
146 v_course2 := 'C2';
147 v_course3 := 'C3';
148
149 END IF;
150 END IF;
151 END IF;
152
153 -- Input test information for students
154
155 -- Beginning of year test for Course 1
156
157 IF v_counter <= v_students_test1 THEN
158 INSERT INTO studentfacts
159 VALUES(v_student_id, v_course1, 'ACH1999',
160 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
161 v_student_grade, v_course_final_grade, v_test_score);
162 ELSE
163 INSERT INTO studentfacts
164 VALUES(v_student_id, v_course1, 'ACH1999',
165 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
166 v_student_grade, v_course_final_grade, NULL);
167 END IF;
168
169
170 -- End of year test for Course 1
171
172 IF v_counter <= v_students_test2 THEN
173 INSERT INTO studentfacts
174 VALUES(v_student_id, v_course1,'ACH2000',
175 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
176 v_student_grade, v_course_final_grade, v_test_score);
177 ELSE
178 INSERT INTO studentfacts
179 VALUES(v_student_id, v_course1, 'ACH2000',
180 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
181 v_student_grade, v_course_final_grade, NULL);
182 END IF;
183
184
185 -- Beginning of year test for Course 2
186
187 IF v_counter <= v_students_test1 THEN
188 INSERT INTO studentfacts
189 VALUES(v_student_id, v_course2, 'ACH1999',
190 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
191 v_student_grade, v_course_final_grade,
192 v_test_score);
193 ELSE
194 INSERT INTO studentfacts
195 VALUES(v_student_id, v_course2, 'ACH1999',
196 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
197 v_student_grade, v_course_final_grade, NULL);
198 END IF;
199
200
201 -- End of year test for Course 2
202
203 IF v_counter <= v_students_test2 THEN
204 INSERT INTO studentfacts
205 VALUES(v_student_id, v_course2,'ACH2000',
206 TO_DATE('01-JUN-2001''DD-MON-YYYY'),
207 v_student_grade, v_course_final_grade,
208 v_test_score);
209 ELSE
210 INSERT INTO studentfacts
211 VALUES(v_student_id, v_course2, 'ACH2000',
212 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
213 v_student_grade, v_course_final_grade, NULL);
214 END IF;
215
216
217 -- Beginning of year test for Course 3
218
219 IF v_counter <= v_students_test1 THEN
220 INSERT INTO studentfacts
221 VALUES(v_student_id, v_course3, 'ACH1999',
222 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
223 v_student_grade, v_course_final_grade,
224 v_test_score);
225 ELSE
226 INSERT INTO studentfacts
227 VALUES(v_student_id, v_course3, 'ACH1999',
228 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
229 v_student_grade, v_course_final_grade, NULL);
230 END IF;
231
232
233 -- End of year test for Course 3
234
235 IF v_counter <= v_students_test2 THEN
236 INSERT INTO studentfacts
237 VALUES(v_student_id, v_course3,'ACH2000',
238 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
239 v_student_grade, v_course_final_grade,
240 v_test_score);
241 ELSE
242 INSERT INTO studentfacts
243 VALUES(v_student_id, v_course3, 'ACH2000',
244 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
245 v_student_grade, v_course_final_grade, NULL);
246 END IF;
247
248
249 -- Beginning of year test for Course 4
250
251 IF v_counter <= v_students_test1 THEN
252 INSERT INTO studentfacts
253 VALUES(v_student_id, v_course4, 'ACH1999',
254 TO_DATE('01-SEP-1999','DD-MON-Y YYY'),
255 v_student_grade, v_course_final_grade,
256 v_test_score);
257 ELSE
258 INSERT INTO studentfacts
259 VALUES(v_student_id, v_course4, 'ACH1999',
260 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
261 v_student_grade, v_course_final_grade, NULL);
262 END IF;
263
264
265 -- End of year test for Course 4
266
267 IF v_counter <= v_students_test2 THEN
268 INSERT INTO studentfacts
269 VALUES(v_student_id, v_course4,'ACH2000',
270 TO_DATE('01-JUN-2001', 'DD-MON-YYYY'),
271 v_student_grade, v_course_final_grade, v_test_score);
272 ELSE
273 INSERT INTO studentfacts
274 VALUES(v_student_id, v_course4, 'ACH2000',
275 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
276 v_student_grade, v_course_final_grade, NULL);
277
278 END IF;
279 END LOOP;
280 END add_tests;
281 /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL> Input truncated to 9 characters
spool off
When I executed the main procedure, no data populated the student_table. I've tried several things, but I was not still able to populate the student_fact table (I've been at this for more than a week now, but haven't figured a way to populate the student_facts table with at least 1800 rows). Can you tell me what I need to change (if anything) whether if I need to structure things differently? I'm thinking that I missed something in calling the birth_date into the main procedure or returning the value from either a function or subprocedure. Related to the random final grade -- is there a way to sum the totals of the test scores (each student will have three), and generate a final grade from these values.
I also compiled successfully a package containing this same information, but don't know how to execute it to see whether this approach works.
Many thanks to anyone who can help.
nullldsw,
I am not sure if I totally understand everything that you are trying to do, but I tried to clean up your code and what is listed below is what I came up with. Please see if you can make use of any of it.
SQL> EDIT ldsw
CREATE OR REPLACE PACKAGE ldsw
AS
CURSOR grade_cur
IS
SELECT birth_date
FROM students;
PROCEDURE delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (get_grade, WNDS, WNPS, RNDS, RNPS);
PROCEDURE add_tests;
END ldsw;
CREATE OR REPLACE PACKAGE BODY ldsw
AS
v_student_grade NUMBER (1) := 0;
PROCEDURE delete_test_info
IS
BEGIN
DELETE FROM studentfacts;
END delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER
IS
v_school_grade NUMBER (1) := 0;
BEGIN
IF v_birth_date < TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 9;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 8;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1988', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1988', 'DD-Mon-YYYY')
THEN
v_school_grade := 7;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1989', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 6;
ELSIF v_birth_date > TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 5;
END IF;
RETURN v_school_grade;
END get_grade;
PROCEDURE add_tests
IS
v_num_students CONSTANT NUMBER (3) := 300;
v_students_test1 NUMBER := 0;
v_students_test2 NUMBER := 0;
v_counter NUMBER (3) := 0;
v_student_id VARCHAR2 (5);
v_test_score NUMBER (3) := 0;
v_course_final_grade NUMBER (1) := 0;
v_course1 VARCHAR2 (2) := NULL;
v_course2 VARCHAR2 (2) := NULL;
v_course3 VARCHAR2 (2) := NULL;
v_course4 VARCHAR2 (2) := NULL;
BEGIN
ldsw.delete_test_info;
v_students_test1 := v_num_students * .95;
v_students_test2 := v_students_test1 * .80;
FOR rec IN grade_cur
LOOP
v_counter := v_counter + 1;
IF v_counter <= v_num_students
THEN
v_student_id := 'S' | | TO_CHAR (v_counter);
v_test_score := random.rand_max (80) + 20;
v_course_final_grade := random.rand_max (4);
IF v_counter < ROUND (v_num_students * .20)
THEN
v_course1 := 'C1';
v_course2 := 'C2';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .20) AND ROUND (v_num_students * .40)
THEN
v_course1 := 'C2';
v_course2 := 'C1';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .40) AND ROUND (v_num_students * .60)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSIF v_counter BETWEEN ROUND (v_num_students * .60) AND ROUND (v_num_students * .80)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSE
v_course1 := 'C4';
v_course2 := 'C2';
v_course3 := 'C3';
END IF;
SELECT ldsw.get_grade (rec.birth_date)
INTO v_student_grade
FROM DUAL;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
END IF;
END LOOP;
END add_tests;
END ldsw;
Save the file.
SQL> START ldsw
Package created.
Package body created.
SQL> EXECUTE ldsw.add_tests
PL/SQL procedure successfully completed.
SQL> SELECT * FROM student_facts;
null -
Using unstructured TS data and labview variants
I want to create a generic step to pass data from TS to LabVIEW but I'm pulling my hair. Why can't I use a Variant input on a VI to accept unstructured data fro TS? Is this possible? How can I flatten TS data into a LabVIEW Variant? In LV when you need to pass an unknown data type between a VI boundry, you use a variant. In TS you can do the same with an unstructured container. Is there anyway to pass unknown data between the two platforms? Actually correction: A variant output from a VI actually will show up on the TS side if you use an unstructured container but doesn't work the other way around.
I think the TS developers should get together with the LV developers over at NI and actually sit down over a few beers and talk. No I mean really talk. WTF?
Michael Aivaliotis
VI Shots LLCIt seems that there is a limitation that I've come across. When the variant data is passed through the results data of a step it becomes invalid. I've modified the original code you submitted and was able to reproduce my problem. When you run the attached code, you will see a type mismatch error. Also, if you break it and look at the results variant data it does not contain the structure.
Using LV8.5 and TS 4.0.1
Message Edited by Michael Aivaliotis on 02-11-2008 02:12 AM
Michael Aivaliotis
VI Shots LLC
Attachments:
LV Variant2.zip 27 KB
2.png 21 KB -
Not able to Submit CJI5 report in background using Variant
Hi Experts,
Is it possible to fill the multiple screens through FM rs_create_variant.
Reagrds,
NavaHi Ramesh,
I am trying to submit the CJI5 report in back ground through variant. The varaint was created using FM RS_CREATE_VARIANT. it's throughing an error .
IF I create variant directly via selectin screen then it's working fine.
FYI.
REPORT z_co99_cji5
NO STANDARD PAGE HEADING
MESSAGE-ID 00
LINE-SIZE 290.
PROGRAM : Z_CO99_CJI5 *
TITLE : CJI5 In Background *
AUTHOR. : Raja Nesanoor *
DATE WRITTEN : 27-Feb_2007 *
REVTRAC : xxxxxx *
PROGRAM FUNCTION: *
To DISPLAY CJI5 Report in background *
PROGRAM TYPE : Executable program *
DEV. CLASS : XXXXXX *
LOGICAL DB : NA *
AUHTORIZATION CHECKS *
Object Authorization Fields ABAP Fields *
S_TCODE *
BUKRS v_BUKRS *
CHANGE HISTORY *
Date Id Name Indicator Description *
DATA : v_repid LIKE sy-repid VALUE 'ZRKPEP005' ,
v_variant LIKE varid-variant VALUE 'V_CJI5' .
DATA: BEGIN OF w_varid.
INCLUDE STRUCTURE varid.
DATA: END OF w_varid.
DATA: BEGIN OF i_rsparams OCCURS 10.
INCLUDE STRUCTURE rsparams.
DATA: END OF i_rsparams.
DATA: BEGIN OF i_rsparams1 OCCURS 10.
INCLUDE STRUCTURE rsparams.
DATA: END OF i_rsparams1.
DATA: BEGIN OF i_varit OCCURS 2.
INCLUDE STRUCTURE varit.
DATA: END OF i_varit.
DATA: BEGIN OF i_vscreens OCCURS 2.
INCLUDE STRUCTURE rsdynnr.
DATA: END OF i_vscreens.
start-of-Selection
START-OF-SELECTION.
SET PARAMETER ID 'CAC' FIELD 'GC10'.
SET PARAMETER ID 'PDB' FIELD '000000000001'.
PERFORM populate_var_table.
PERFORM create_variant.
PERFORM submit_cji5.
*& Form POPULATE_VAR_TABLE
text
--> p1 text
<-- p2 text
FORM populate_var_table .
CLEAR w_varid .
REFRESH i_varit .
REFRESH i_rsparams .
i_rsparams-selname = 'CN_NETNR'.
i_rsparams-kind = 'S'.
i_rsparams-sign = 'I'.
i_rsparams-option = 'EQ'.
i_rsparams-low = '90273536'.
i_rsparams-high = space.
APPEND i_rsparams.
CLEAR : i_rsparams .
i_rsparams-selname = 'CN_NETNR'.
i_rsparams-kind = 'S'.
i_rsparams-sign = 'I'.
i_rsparams-option = 'EQ'.
i_rsparams-low = '90274010'.
i_rsparams-high = space.
APPEND i_rsparams.
CLEAR : i_rsparams .
i_rsparams-selname = 'R_OBDAT'.
i_rsparams-kind = 'S'.
i_rsparams-sign = 'I'.
i_rsparams-option = 'BT'.
i_rsparams-low = space .
i_rsparams-high = space.
APPEND i_rsparams.
CLEAR : i_rsparams .
i_rsparams-selname = 'P_DISVAR'.
i_rsparams-kind = 'P'.
i_rsparams-sign = 'I'.
i_rsparams-option = 'EQ'.
i_rsparams-low = '1SAP' .
APPEND i_rsparams.
CLEAR : i_rsparams .
i_rsparams-selname = 'P_USEDB'.
i_rsparams-kind = 'P'.
i_rsparams-sign = 'I'.
i_rsparams-option = 'EQ'.
i_rsparams-low = SPACE.
APPEND i_rsparams.
w_varid-mandt = sy-mandt.
w_varid-report = v_repid.
w_varid-variant = v_variant.
w_varid-flag1 = space.
w_varid-flag2 = space.
w_varid-transport = space.
w_varid-environmnt = 'A'. "Variant for batch and online
w_varid-protected = space.
w_varid-secu = space.
w_varid-version = '0'.
w_varid-ename = sy-uname.
w_varid-edat = sy-datum.
w_varid-etime = sy-uzeit.
w_varid-aename = space.
w_varid-aedat = space.
w_varid-aetime = space.
w_varid-mlangu = sy-langu.
i_varit-mandt = sy-mandt.
i_varit-langu = sy-langu.
i_varit-report = w_varid-report.
i_varit-variant = w_varid-variant.
i_varit-vtext = 'CO99-OUTPUT'.
APPEND i_varit.
ENDFORM. " POPULATE_VAR_TABLE
*& Form CREATE_VARIANT
text
--> p1 text
<-- p2 text
FORM create_variant .
data: h_rc like sy-subrc.
*Check variant exists.
CALL FUNCTION 'RS_VARIANT_EXISTS'
EXPORTING
report = v_repid
variant = v_variant
IMPORTING
R_C = h_rc
EXCEPTIONS
not_authorized = 01
no_report = 02
report_not_existent = 03
report_not_supplied = 04.
IF h_rc = 0.
CALL FUNCTION 'RS_CHANGE_CREATED_VARIANT'
EXPORTING
curr_report = v_repid
curr_variant = v_variant
vari_desc = w_varid
TABLES
vari_contents = i_rsparams
vari_text = i_varit
EXCEPTIONS
illegal_report_or_variant = 01
illegal_variantname = 02
not_authorized = 03
not_executed = 04
report_not_existent = 05
report_not_supplied = 06
variant_doesnt_exist = 07
variant_locked = 08
selections_no_match = 09.
COMMIT WORK.
ELSE.
CALL FUNCTION 'RS_CREATE_VARIANT'
EXPORTING
curr_report = v_repid
curr_variant = v_variant
vari_desc = w_varid
TABLES
vari_contents = i_rsparams
vari_text = i_varit
EXCEPTIONS
illegal_report_or_variant = 1
illegal_variantname = 2
not_authorized = 3
not_executed = 4
report_not_existent = 5
report_not_supplied = 6
variant_exists = 7
variant_locked = 8
OTHERS = 9.
COMMIT WORK.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " CREATE_VARIANT
*& Form submit_cji5
text
--> p1 text
<-- p2 text
FORM submit_cji5 .
CALL FUNCTION 'SUBST_START_REPORT_IN_BATCH'
EXPORTING
iv_jobname = 'TEST_JOB'
iv_repname = v_repid
iv_varname = v_variant
iv_authcknam = sy-uname
iv_language = sy-langu
iv_varianttext = 'CO99-OUTPUT'
TABLES
tt_reportparam = i_rsparams
EXCEPTIONS
variant_exist_check_failed = 1
variant_update_failed = 2
variant_update_not_authorized = 3
variant_update_no_report = 4
variant_update_no_variant = 5
variant_update_variant_locked = 6
variant_insert_failed = 7
variant_insert_not_authorized = 8
variant_insert_no_report = 9
variant_insert_variant_exists = 10
variant_insert_variant_locked = 11
variant_write_failed = 12
no_batch_service = 13
no_server_list = 14
batch_scheduling_failed = 15
OTHERS = 16.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
Thanks
Nava -
Variant to data: Need info regarding type of data
Hello,
What I want to do is very basic. I will acquire the image using CCD camera. The
image is a raw data type: 2D array of type long (4 bytes per element) or integer (2 bytes per element). I can save the image even as .tiff file. Using Variant To Data, I am converting the image so that labview can handle it (I am not sure whether I really need this) before I write that data to some file and save it. I have to define data type for Variant To Data. I tried to define the data type. However, I am confused. Would anybody give me some suggestion?
Thanks a lot,
DushyantHrm, you'll need to be more specific about your actual question in order for us to give you a good answer, but, without more information, I'd say you should just define the type as a 2-d array of either longs or words. (i.e. get an array constant, place a numeric constant inside of it, right click the numeric constant, and select Representation->Long or Representation->Word then wire the constant to the Type input of the Variant to Data).
If you're dealing with variants, I'd guess you are probably calling an ActiveX control or server to communicate with your camera?
Regards,
Ryan K. -
What the data type of this variant? (in the following)
What's the datatype of the following variant (use probe and indicator):
value -> 1356.00
I want to tranfer it to numerical data. When I tranfer it using "variant to data" function (the datatype used is string or numerical), An error occured:
ERROR 91 occured at Variant to Data. The data type is not compatible with the data type wired to the type input."
Thank you very much!You can investigate any Variant by using the 'Variant Probe' for download from LAVA.
It will tell you what the actual contents of the Variant were.
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be! -
Database Variant to Data.vi not working for the Date datatype with LV 8.2?
I'm moving a large body of LV database code from LV 7.1 to 8.2 and find that the Database Variant to Data.vi is not working correctly when used with the Date datatype. It works fine with 8.0, and the common Variant to Data works also. Am I missing something? Thanks in advance for any assistance. Wes
Thanks for the prompt reply Crystal,
The data is stored in an Oracle database using the DATE type. I'm querying many rows along with other columns and converting each of the values as necessary for each column with the 'Database Variant to Data' vi. Only conversion to Timestamp is no longer working as of version 8.2. I recognize that plain Variant to Data works but I have many (100's) of VIs to change if that is the only solution (not the end of the world). Most often the dates are originally generated in the database using PL/SQL procedures calling SYSDATE which look like: 5/1/2006 11:56:26 AM (in TOAD anyway) which I then need to read into LV as type Timestamp.
Regards, Wes. -
Dynamic date selections in a variant
Hi All,
I need to dynamically change the date field of a report which runs every month end. Our working calendar is designed such that the last working day is the last Friday of the current period and hence the first working day is the last Saturday of the previous period. Now we have Fiscal Calendar variant which takes care of the last Friday part. I also know we have to select 'D' in the variant screen but my problem is in assigning the Last Saturday of the previous period in the date range field. Any hints or suggestions on this would be highly appreciated and of course rewarded generously.
Thanks & Regards,
RajeshHi Rajesh,
After seecting Selection Variable "D" you have to carry out following things to cater your requirements;
(a) Goto Name of Variable (input only using F4)
(b) Select your variable depending upon your business requirement.
Current Date
From month start to today
Current date +/- ??? days
current date +/- ??? work days
First day of current month
<b>nth working day of current month</b>
First day of next month
First day of previous month
Last day of previous month
Last Day of the Current Month
First quarter ????
Second quarter ????
Third quarter ????
Fourth quarter ????
Current date - xxx,current date + yyy
Date - xxx, Date + yyy (work days)
Previous month
Current period
(Beginning of mth-xx months, end of mth+yy months)
I think nth working day of current month is suitable for your requirement.
Bye,
Muralidhara -
Why are variants sometimes better to use than clusters?
I am using variants in a driver I am developing to avoid having to pass a ton of wires between subVIs. My mentor asked me why I was doing this. He wanted to know why I wasn't just using clusters. The only answer I could come up with was that is was convenient to be able to "dereference" (I'm not sure if this is the correct term) the variant for attributes with the Get Variant Attribute VI and a string associated with the attribute of interest. Are there any other advantages of using variants?
Yes! Variants are great when you are trying to write code that must operate on many different data types. However there are caveats that make error handling more difficult and critical. Take a look at the OpenG LabVIEW Data Tools, which make Varaint usage practical. This library is part of the OpenG Toolkit.
LabVIEW Data Tools Presentation - variants, run-time type checking, and data manipulation design patterns
Examples:
Get Object Attributes as XML
<
A HREF=http://www.openg.org/tiki/tiki-index.php?page=EXAMPLE%20-%20OpenG%20Flatten%20to%20XML>OpenG Flatten to XML
Python Client to LabVIEW Server
Universal Probe -
How do I extract data from an OLE variant?
I am trying to retrieve a string from a Dot Net function. What I get out is a Labview variant.
From my research, I suspect that what Labview is giving me in this variant is a pointer to the string that I need to dereference. Problem is that I can't even get the pointer value out of the variant.
If I view the variant as an indicator, I see that it has a value but no matter what type I wire to the Variant to Data function, I get a type mismatch error.
The value is there, why can't Labview give it to me?MoveBlock() won't help you here much. VT_DISPATCH indeed contains a pointer, but not a pointer to data but instead a pointer to an IDispatch COM object. This is basically a pointer to an object containing internally one (and typically more) so called COM virtual method dispatch tables. The only safe way to get at the information is by using the COM QueryInterface() method in that object to retrieve the IDispatch interface, then calling the IDispatch methods to inspect the data contents the object contains and then retrieving the actual data.
This is impossible to do on your own in a LabVIEW diagram but requires quite a bit of C(++) code. However if you know what the IDispatch is really holding internally (and your VBA.ICollection sounds like a plausible idea) then you can create a compatible Automation refnum by dropping one on your front panel and then browsing to the according ActiveX object type (here most like in the Visual Basic typelibrary) and then using Variant to Data, let LabVIEW comvert the contained IDispatch to the actual Automation refnum to the data object. Variant to Data will return an error if you selected the wrong ActiveX refnum type.
An VBA.ICollection is however not a string or numeric data already but more like an Array like container, so you would then have to use the VBA.ICollection methods to enumerate the elements in it as variants and convert them to the actual datatype using Variant to Data again.
Also note that pointers are 32 bit in LabVIEW 32 Bit and 64 bit in LabVIEW for 64 bit. This is independent if you run on 32 bit or 64 bit Windows, since a 32 Bit version of LabVIEW runs in a 32 bit environment even on 64 bit Windows.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
How to create Variants in Web Dynpro using ABAP
Can anyone please tell how to create and save variants in a Web DynPro application using ABAP.
Also state the steps involved in saving and loading the variants.hi,
For calender control, there is Date Navigator under "complex tab". You can just click and drag it and provide calender control.
One more easy way is to create a input field. In the context, create a node and attribute of type "D"(which means DATE). And bind the context to your input field under "values" in property window. While running the program, you will see an calender attached to lt on the input field.
Regards,
Jithin -
Fiscal year variants in co.code have inconsistent start date.Msg no AC531
Hi Experts
We went with 24 periods after Go live. I am trying to assign the TAX basis fiscal year variant(TX) at Depreciation area level. But it's not letting to add with the following error message.
Fiscal year variants in co.code have inconsistent start date
Message no. AC531
Diagnosis
The first day of the fiscal year for variant TX (24periods) in company code in Asset Accounting differs from the first day of the fiscal year for variant D1(12 periods) in General Ledger Accounting.
However, both variants must have the same start and end date! Only the periods within the fiscal year can be different in the two variants.
Please guide me how to fix this error message.
Thanks in advance
Meenakshi.N
Edited by: Meenakshi.Nakshatrula on May 3, 2010 5:45 AMHi,
Message no. AC531 says:
The first day of the fiscal year for variant K4 in company code in Asset
Accounting differs from the first day of the fiscal year for variant NL
in General Ledger Accounting.
However, both variants must have the same start and end date! Only the
periods within the fiscal year can be different in the two variants.
The error is described in note 844029 :-
In the NewGL in Asset Accounting, it is still not possible for
depreciation areas to have fiscal year variants with different start and
finish dates. If you try to assign a fiscal year variant to an area,
whereby the fiscal year variant infringes this restriction, the system
issues error message AC 531.
Regards Bernhard -
Hello,
our customer plans to use a Non-SAP solution for variant configuration (Camos) in SAP ERP (ECC 6.0) and in SAP CRM 7.0 EHP1 as well.
ERP sales orders (and ERP quotations) should be created in SAP CRM (CRM WebUI).
Is it possible to use variant configuration (with an external variant configuration tool) when creating ERP sales orders and quotations in the SAP CRM WebUI or do we have to implement SAP IPC for this?
Thanks in advance.
Regards,
AEVDear AEV,
I think LORD (lean orders) should work with variant configuration as well. In the note 1236015 there is not restriction listed. However you need lord2 activated in ECC, and ECC system should be on EHP4.
Best regards
Rene -
Using variants to set/get container variables?
I am trying to determine if there is a way to retreive TestStand container variables into CVI using variants. The goal is to not have to get each member of the container separately. I am not seeing a way to do this - if it can please done can you please provide an example? Thanks.
Hi Snood1,
There are several ways to pass containers to and from code modules, one
of which is the same method you are currently employing.
I've found an old discussion forum that still is relevant to your question - you can find it here:
http://forums.ni.com/ni/board/message?board.id=270&message.id=1001&requireLogin=False
Hope this helps! If you have more questions feel free to let us know.
Have a good one Snood1,
Dan Weiland
Maybe you are looking for
-
[JS][CS3] Create new swatch
Hi all, I'm writing a script that reads an xml file and then converts the contents to InDesign Objects. Most of this I can do, but I'm having problems with the colors and swatches in InDesign. Simple said, what I'm trying to do is the following: 1. C
-
Why won't websites I visit stay the way I set them up when I use Firefox?
As an example: When I go to MSNBC I set the number of articles for different subjects and they revert to default every time I open firefox. This does not happen with IE. Another is I have to log in to get to my hotmail & Gmail account every time I re
-
Calling a PL/SQL function returning Netsed Table Rows
Hi, I am trying to call a Function which returns Nested Table rows (as Out Parameter) in Java . When I am trying to use pstmt.registerOutParameter(3, OracleTypes.OTHER); to capture the Out parameter in Java code , I get the follwoing error : java.sql
-
Distribution Channel and Division in STO
Hi All, We are have a STO senario.We are also using the common distribution channel and common division.However when we create an Invoice with the delivery created the system is picking up the common division not the material division. In delivery a
-
Message ID CPF7024, reason Code # 2
Hi Guys, In our SCM production system, we use the the program given by SAP for managing the journal receivers..It deletes an old journal from the journal library and saves it to a another library, which we back off everynight... Now all of a sudden,