CONCATENATE a string a characters into a field
Hi everyone!
Let's say that i want to CONCATENATE a string of characters (for example: 'ABC') into every WTAB-AUFNR record that i retrieve. How do i do that?
Let's assume that WTAB-AUFNR's header currently has the value '50-12345', i want it to be 'ABC50-12345'.
I've got another CONCATENATE question. Here it is:
Let's say i wanna have the values in CTAB-WTJHR to be in brackets, which i am going to hardcode by doing a CONCATENATE. So it should work if i write it like this:
DATA: BEGIN OF CTAB OCCURS 0,
LEDNR LIKE BPJA-LEDNR, "Ledger
OBJNR LIKE BPJA-OBJNR, "Object Number
TRGKZ LIKE BPJA-TRGKZ, "Object Indicator
WRTTP LIKE BPJA-WRTTP, "Value Type
GJAHR LIKE BPJA-GJAHR, "Fiscal Year
VERSN LIKE BPJA-VERSN, "Version
VORGA LIKE BPJA-VORGA, "Budget Type
TWAER LIKE BPJA-TWAER, "Transaction Currency
WTJHV LIKE BPJA-WTJHV, "Original Budget
WTJHR LIKE BPJA-WTJHR, "Amount Utilised YTD
V_BEFORE TYPE I, "Balance Before This Request
V_CURRENT TYPE I, "Current Acquisition Cost
V_BALANCE TYPE I, "Balance Variation
END OF CTAB.
SELECT SINGLE LEDNR OBJNR TRGKZ WRTTP GJAHR VERSN VORGA TWAER WTJHV
WTJHR
INTO CTAB
FROM BPJA
WHERE OBJNR = WTAB-AUFNR AND
WRTTP = '42' AND
GJAHR = ITAB-LFDAT+0(4).
APPEND CTAB.
LOOP AT CTAB.
CONCATENATE '(' CTAB-WTJHR ')' INTO CTAB-WTJHR.
MODIFY CTAB TRANSPORTING WTJHR.
ENDLOOP.
I've looked through it and i can't find any syntax problem or anything else but i keep getting this message when i try to activate my program: "CTAB-WTJHR" must be a character-type data object (data type C, N, D, T or STRING). field string". When i looked at SE11 and i found out that the WTJHR field in BPJA is a type CURR. Is there a way to solve this?
Similar Messages
-
PL/SQL function to read a string of characters into an array
I was wondering if there is an easier way than using the substr function multiple times. Here is the example:
Suppose you have a varchar2 variable that contains the word 'Apple'. The function should take it and produce an array. We would invoke it like this:
<what data structure?> a := stringunpackerfunction(x);
// x is the varchar2 containing 'Apple'.
The resulting a would be such that a[0] is 'A', a[1] is 'p', a[2] is 'p', a[3] is 'l' and a[4] is 'e'.
If there is no direct function to do this in a single invocation, is there a function to simply read a string of characters and return 'the next character'?
Thanks,
Regards,
SriniThere is a procedure out there called PS_PARSE which takes a string and converts to an array provided with an identified separator. Works for us pretty well.
I just grabbed this off of google. I am presuming this should work fine. It has been sometime since we implemented ours that I forget if there were any additional modifications that we made. I think there was one regarding the size of the string that could be handled. I forget precisely. Anyways... take a peek at it. Its makes things easy in that your logic is pretty streamlined.
Barry C
http://www.myoracleportal.com
create or replace PACKAGE PS_Parse
IS
|| PL/SQL table structures to hold atomics retrieved by parse_string.
|| This includes the table type definition, a table (though you can
|| declare your own as well, and an empty table, which you can use
|| to clear out your table which contains atomics.
TYPE atoms_tabtype IS TABLE OF VARCHAR2(60) INDEX BY BINARY_INTEGER;
atoms_table atoms_tabtype;
empty_atoms_table atoms_tabtype;
|| The standard list of delimiters. You can over-ride these with
|| your own list when you call the procedures and functions below.
|| This list is a pretty standard set of delimiters, though.
std_delimiters VARCHAR2 (50) := ' !@#$%^&*()-_=+\|`~{{]};:''",<.>/?';
/* Display contents of table using DBMS_OUTPUT */
PROCEDURE display_atomics
(table_in IN atoms_tabtype, num_rows_in IN NUMBER);
|| The parse_string procedure: I provide two, overloaded definitions.
|| The first version puts all atomics into a PL/SQL table and would
|| be used in a PL/SQL Version 2 environment. The second version places
|| all atomics into a string, separating each atomic by a vertical bar.
|| (My code does NOT do any special handling when it finds a "|" in
|| the string. You have to deal with that when you extract the atomics.
||
|| See the program definition for more details on other parameters.
PROCEDURE parse_string
(string_in IN VARCHAR2,
atomics_list_out OUT atoms_tabtype,
num_atomics_out IN OUT NUMBER,
delimiters_in IN VARCHAR2 := std_delimiters);
PROCEDURE parse_string
(string_in IN VARCHAR2,
atomics_list_out IN OUT VARCHAR2,
num_atomics_out IN OUT NUMBER,
delimiters_in IN VARCHAR2 := std_delimiters);
/* Count the number of atomics in a string */
FUNCTION number_of_atomics
(string_in IN VARCHAR2,
count_type_in IN VARCHAR2 := 'ALL',
delimiters_in IN VARCHAR2 := std_delimiters)
RETURN INTEGER;
/* Return the Nth atomic in the string */
FUNCTION nth_atomic
(string_in IN VARCHAR2,
nth_in IN NUMBER,
count_type_in IN VARCHAR2 := 'ALL',
delimiters_in IN VARCHAR2 := std_delimiters)
RETURN VARCHAR2;
END PS_Parse;
create or replace PACKAGE BODY PS_Parse
IS
/* Package variables used repeatedly throughout the body. */
len_string NUMBER;
start_loc NUMBER;
next_loc NUMBER;
|| Since the PUT_LINE procedure regards a string of one or more
|| spaces as NULL, it will not display a space, which is in
|| PS_Parse a valid atomic. So I save a_blank in the PL/SQL
|| table instead of the space itself.
a_blank CONSTANT VARCHAR2(3) := '" "';
/*--------------------- Private Modules ---------------------------
|| The following functions are available only to other modules in
|| package. No user of PS_Parse can see or use these functions.
FUNCTION a_delimiter
(character_in IN VARCHAR2,
delimiters_in IN VARCHAR2 := std_delimiters)
RETURN BOOLEAN
|| Returns TRUE if the character passsed into the function is found
|| in the list of delimiters.
IS
BEGIN
RETURN INSTR (delimiters_in, character_in) > 0;
END;
FUNCTION string_length (string_in IN VARCHAR2)
RETURN INTEGER
IS
BEGIN
RETURN LENGTH (LTRIM (RTRIM (string_in)));
END;
FUNCTION next_atom_loc
(string_in IN VARCHAR2,
start_loc_in IN NUMBER,
scan_increment_in IN NUMBER := +1)
|| The next_atom_loc function returns the location
|| in the string of the starting point of the next atomic (from the
|| start location). The function scans forward if scan_increment_in is
|| +1, otherwise it scans backwards through the string. Here is the
|| logic to determine when the next atomic starts:
||
|| 1. If current atomic is a delimiter (if, that is, the character
|| at the start_loc_in of the string is a delimiter), then the
|| the next character starts the next atomic since all
|| delimiters are a single character in length.
||
|| 2. If current atomic is a word (if, that is, the character
|| at the start_loc_in of the string is a delimiter), then the
|| next atomic starts at the next delimiter. Any letters or
|| numbers in between are part of the current atomic.
||
|| So I loop through the string a character at a time and apply these
|| tests. I also have to check for end of string. If I scan forward
|| the end of string comes when the SUBSTR which pulls out the next
|| character returns NULL. If I scan backward, then the end of the
|| string comes when the location is less than 0.
RETURN NUMBER
IS
/* Boolean variable which uses private function to determine
|| if the current character is a delimiter or not.
was_a_delimiter BOOLEAN :=
PS_Parse.a_delimiter (SUBSTR (string_in, start_loc_in, 1));
/* If not a delimiter, then it was a word. */
was_a_word BOOLEAN := NOT was_a_delimiter;
/* The next character scanned in the string */
next_char VARCHAR2(1);
|| The value returned by the function. This location is the start
|| of the next atomic found. Initialize it to next character,
|| forward or backward depending on increment.
return_value NUMBER := start_loc_in + scan_increment_in;
BEGIN
LOOP
-- Extract the next character.
next_char := SUBSTR (string_in, return_value, 1);
-- Exit the loop if:
EXIT WHEN
/* On a delimiter, since that is always an atomic */
a_delimiter (next_char)
OR
/* Was a delimiter, but am now in a word. */
(was_a_delimiter AND NOT a_delimiter (next_char))
OR
/* Reached end of string scanning forward. */
next_char IS NULL
OR
/* Reached beginning of string scanning backward. */
return_value < 0;
/* Shift return_value to move the next character. */
return_value := return_value + scan_increment_in;
END LOOP;
-- If the return_value is negative, return 0, else the return_value
RETURN GREATEST (return_value, 0);
END;
PROCEDURE increment_counter
(counter_inout IN OUT NUMBER,
count_type_in IN VARCHAR2,
atomic_in IN CHAR)
|| The increment_counter procedure is used by nth_atomic and
|| number_of_atomics to add to the count of of atomics. Since you
|| can request a count by ALL atomics, just the WORD atomics or
|| just the DELIMITER atomics. I use the a_delimiter function to
|| decide whether I should add to the counter. This is not a terribly
|| complex procedure. I bury this logic into a separate module,
however,
|| to make it easier to read and debug the main body of the programs.
IS
BEGIN
IF count_type_in = 'ALL' OR
(count_type_in = 'WORD' AND NOT a_delimiter (atomic_in)) OR
(count_type_in = 'DELIMITER' AND a_delimiter (atomic_in))
THEN
counter_inout := counter_inout + 1;
END IF;
END increment_counter;
/* ------------------------- Public Modules -----------------------*/
PROCEDURE display_atomics
(table_in IN atoms_tabtype, num_rows_in IN NUMBER)
|| Program to dump out contents of table. Notice I must also pass in
|| the number of rows in the table so that I know when to stop the
|| loop. Otherwise I will raise a NO_DATA_FOUND exception. For a more
|| elaborate display_table module, see Chapter 7 on PL/SQL tables.
IS
BEGIN
FOR table_row IN 1 .. num_rows_in
LOOP
DBMS_OUTPUT.PUT_LINE (NVL (table_in (table_row), 'NULL'));
END LOOP;
END;
PROCEDURE parse_string
(string_in IN VARCHAR2,
atomics_list_out OUT atoms_tabtype,
num_atomics_out IN OUT NUMBER,
delimiters_in IN VARCHAR2 := std_delimiters)
|| Version of parse_string which stores the list of atomics
|| in a PL/SQL table.
||
|| Parameters:
|| string_in - the string to be parsed.
|| atomics_list_out - the table of atomics.
|| num_atomics_out - the number of atomics found.
|| delimiters_in - the set of delimiters used in parse.
IS
BEGIN
/* Initialize variables. */
num_atomics_out := 0;
len_string := string_length (string_in);
IF len_string IS NOT NULL
THEN
|| Only scan the string if made of something more than blanks.
|| Start at first non-blank character. Remember: INSTR returns 0
|| if a space is not found. Stop scanning if at end of string.
start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
WHILE start_loc <= len_string
LOOP
|| Find the starting point of the NEXT atomic. Go ahead and
|| increment counter for the number of atomics. Then have to
|| actually pull out the atomic. Two cases to consider:
|| 1. Last atomic goes to end of string.
|| 2. The atomic is a single blank. Use special constant.
|| 3. Anything else.
next_loc := next_atom_loc (string_in, start_loc);
num_atomics_out := num_atomics_out + 1;
IF next_loc > len_string
THEN
-- Atomic is all characters right to the end of the string.
atomics_list_out (num_atomics_out) :=
SUBSTR (string_in, start_loc);
ELSE
|| Internal atomic. If RTRIMs to NULL, have a blank
|| Use special-case string to stuff a " " in the table.
atomics_list_out (num_atomics_out) :=
NVL (RTRIM (SUBSTR (string_in,
start_loc, next_loc-start_loc)),
a_blank);
END IF;
-- Move starting point of scan for next atomic.
start_loc := next_loc;
END LOOP;
END IF;
END parse_string;
PROCEDURE parse_string
(string_in IN VARCHAR2,
atomics_list_out IN OUT VARCHAR2,
num_atomics_out IN OUT NUMBER,
delimiters_in IN VARCHAR2 := std_delimiters)
|| The version of parse_string which writes the atomics out to a packed
|| list in the format "|A|,|C|". I do not repeat any of the comments
|| from the first iteration of parse_string.
IS
BEGIN
/* Initialize variables */
num_atomics_out := 0;
atomics_list_out := NULL;
len_string := string_length (string_in);
IF len_string IS NOT NULL
THEN
start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
WHILE start_loc <= len_string
LOOP
next_loc := next_atom_loc (string_in, start_loc);
num_atomics_out := num_atomics_out + 1;
IF next_loc > len_string
THEN
atomics_list_out := atomics_list_out || '|' ||
SUBSTR (string_in, start_loc);
ELSE
atomics_list_out :=
atomics_list_out || '|' ||
NVL (RTRIM (SUBSTR (string_in,
start_loc, next_loc-start_loc)),
a_blank);
END IF;
start_loc := next_loc;
END LOOP;
/* Apply terminating delimiter to the string. */
atomics_list_out := atomics_list_out || '|' ;
END IF;
END parse_string;
FUNCTION number_of_atomics
(string_in IN VARCHAR2,
count_type_in IN VARCHAR2 := 'ALL',
delimiters_in IN VARCHAR2 := std_delimiters)
RETURN INTEGER
|| Counts the number of atomics in the string_in. You can specify the
|| type of count you want: ALL for all atomics, WORD to count only the
|| words and DELIMITER to count only the delimiters. You can optionally
|| pass your own set of delimiters into the function.
IS
return_value INTEGER := 0;
BEGIN
/* Initialize variables. */
len_string := string_length (string_in);
IF len_string IS NOT NULL
THEN
|| This loop is much simpler than parse_string. Call the
|| next_atom_loc to move to the next atomic and increment the
|| counter if appropriate. Everything complicated is shifted into
|| sub-programs so that you can read the program "top-down",
|| understand it layer by layer.
start_loc := LEAST (1, INSTR (string_in, ' ') + 1);
WHILE start_loc <= len_string
LOOP
increment_counter (return_value, UPPER (count_type_in),
SUBSTR (string_in, start_loc, 1));
start_loc := next_atom_loc (string_in, start_loc);
END LOOP;
END IF;
RETURN return_value;
END number_of_atomics;
FUNCTION nth_atomic
(string_in IN VARCHAR2,
nth_in IN NUMBER,
count_type_in IN VARCHAR2 := 'ALL',
delimiters_in IN VARCHAR2 := std_delimiters)
RETURN VARCHAR2
|| Find and return the nth atomic in a string. If nth_in is greater
|| the number of atomics, then return NULL. If nth_in is negative the
|| function counts from the back of the string. You can again request
|| a retrieval by ALL atomics, just the WORDs or just the DELIMITER.
|| So you can ask for the third atomic, or the second word from the end
|| of the string. You can pass your own list of delimiters as well.
IS
/* Local copy of string. Supports up to 1000 characters. */
local_string VARCHAR2 (1000) :=
LTRIM (RTRIM (SUBSTR (string_in, 1, 1000)));
/* Running count of atomics so far counted. */
atomic_count NUMBER := 1;
/* Boolean variable which controls the looping logic. */
still_scanning BOOLEAN :=
local_string IS NOT NULL AND nth_in != 0;
/* The amount by which I increment the counter. */
scan_increment INTEGER;
/* Return value of function, maximum length of 100 characters. */
return_value VARCHAR2 (100):= NULL;
BEGIN
IF nth_in = 0
THEN
/* Not much to do here. Find 0th atomic? */
RETURN NULL;
ELSE
/* Initialize the loop variables. */
len_string := string_length (local_string);
IF nth_in > 0
THEN
/* Start at first non-blank character and scan forward. */
next_loc := 1;
scan_increment := 1;
ELSE
/* Start at last non-blank character and scan backward. */
next_loc := len_string;
scan_increment := -1;
END IF;
/* Loop through the string until the Boolean is FALSE. */
WHILE still_scanning
LOOP
/* Move start of scan in string to loc of last atomic. */
start_loc := next_loc;
/* Find the starting point of the next atomic. */
next_loc :=
next_atom_loc (local_string, start_loc, scan_increment);
/* Increment the count of atomics. */
increment_counter
(atomic_count,
UPPER (count_type_in),
SUBSTR (local_string, start_loc, 1));
|| Keep scanning if my count hasn't exceeded the request
|| and I am neither at the beginning nor end of the string.
still_scanning :=
atomic_count <= ABS (nth_in) AND
next_loc <= len_string AND
next_loc >= 1;
END LOOP;
|| Done with the loop. If my count has not exceeded the requested
|| amount, then there weren't enough atomics in the string to
|| satisfy the request.
IF atomic_count <= ABS (nth_in)
THEN
RETURN NULL;
ELSE
|| I need to extract the atomic from the string. If scanning
|| forward, then I start at start_loc and SUBSTR forward.
|| If I am scanning backwards, I start at next_loc+1 (next_loc
|| is the starting point of the NEXT atomic and I want the
|| current one) and SUBSTR forward (when scanning in
|| reverse, next_loc comes before start_loc in the string.
IF scan_increment = +1
THEN
RETURN
SUBSTR (local_string, start_loc, next_loc - start_loc);
ELSE
RETURN
SUBSTR (local_string, next_loc+1, start_loc - next_loc);
END IF;
END IF;
END IF;
END nth_atomic;
END PS_Parse;
/ -
Entering Characters into Numeric Field
Let's say I want to add two numbers with parameters num1 and num2. Now, I want to make sure the user does not enter characters or symbols. If they do I wan to throw an exception. Does anyone know how to do this?
declare
v_num1 number := p_num1;
v_num2 number := p_num2;
v_results number;
begin
if user enters an alphabetic field or symbol
raise error
else
v_results := v_num1 + v_num2;
...No real application should be using SQL Plus as its user interface! And as I said in my first reply, it is no good assigning the values to the variables in the DECLARE section if you want to catch exceptions.
Here is some fully working code:
SET SERVEROUTPUT ON
ACCEPT p_number1 PROMPT 'Enter a number: '
ACCEPT p_number2 PROMPT 'Enter another number: '
DECLARE
v_number1 NUMBER;
v_number2 NUMBER;
v_results NUMBER;
BEGIN
v_number1 := '&p_number1.';
v_number2 := '&p_number2.';
v_results := v_number1 * v_number2;
DBMS_OUTPUT.PUT_LINE('Result='||v_results);
EXCEPTION
WHEN value_error THEN
DBMS_OUTPUT.PUT_LINE('Invalid entry. ');
END;
/ -
Cannot insert Chinese character into nvarchar2 field
I have tested in two environments:
1. Database Character Set: ZHS16CGB231280
National Character Set: AL16UTF8
If the field type of datatable is varchar2 or nvarchar2, the provider can read and write Chinese correctly.
2. Database Character Set:WE8MSWIN1252
National Character Set: AL16UTF8
The provider can not read and write Chinese correctly even the field type of datatable is nvarchar2
I find that for the second one, both MS .NET Managed Provider for Oracle and Oracle Managed Data Provider cannot read and write NCHAR or NVARCHAR2 fields. The data inserted into these fields become question marks.
Even if I changed the NLS_LANG registry to SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280, the result is the same.
For the second situation, only after I change the Database Character Set to ZHS16CGB231280 with ALTER DATABASE CHARACTER SET statement, can I insert Chinese correctly.
Does any know why I cannot insert Chinese characters into Unicode fields when the Database Character Set is WE8MSWIN1252? Thanks.
Regards,
JasonHi Jason,
First of all, I am not familiar with MS .NET Managed Provider for Oracle or Oracle Managed Data Provider.
How did you insert these Simplified Chinese characters into the NVARCHAR2 column ? Are they hardcoded as string literals as part of the SQL INSERT statement ? If so, this could be because, all SQL statements are converted into the database character set before they are parsed by the SQL engine; hence these Chinese characters would be lost if your db character set was WE8MSWIN1252 but not when it was ZHS16CGB231280.
Two workarounds, both involved the removal of hardcoding chinese characters.
1. Rewrite your string literal using the SQL function UNISTR().
2. Use bind variables instead of text literals in the SQL.
Thanks
Nat -
Hello All!
1) I have a form field where a customer can input mileage (e.g. 48,000)
I would like to be able to dynamically place the comma in the proper place as well as add " miles" to the end of the value the user input.
For example:
If the user types "123456" into the field, I would like for it to display as "123,456 miles"
I assume this will require some custom format javascript... I'm familiar with the general syntax of JavaScript, but don't really know specific keywords/object names to use, I have a few custom calculation scripts in the form, and I've done some simple thing like concatenate two fields into one, etc.
But this is a little different, because I'm only working with data from one field. I tried:
event.value += " miles";
However, this causes " miles" to get added everytime ANY field changes... so I end up getting "123,456 miles miles miles miles" as the user makes changes to other fields.
2) Also, to further complicate things, is it possible to "remove" the custom formatting when the field gains focus? For example, if you use Acrobat's default number format ($1,394.00) on a field, when the user selects that field to edit the value, the formatting "disappears" so that the user would only see "1394".
I would like to achieve the same with my custom field, so when the user selected the field that displays "123,456 miles" to change the value, they would only see/edit "123456"
A bit wordy, I know, but thanks for any help!Here's a simple way. Begin by creating a new document-level JavaScript and include the following code:
function my_format() {
// Format number (no decimal point, comma thousands separator, etc.)
AFNumber_Format(0, 0, 0, 0, "", false);
// Add " miles" if there is an entry
event.value = event.value ? event.value + " miles" : "";
function my_keystroke() {
// Restrict entry to characters consistent with a number
AFNumber_Keystroke(0, 0, 0, 0, "", false);
For the field in question, add the following as the custom Format script:
my_format();
and the following as the custom Keystroke script:
my_keystroke();
George -
How to prevent a user from entering characters into a number field
How do you prevent a user from entering characters like A or B into a field that is defined as a numeric field?
Please note that
- we use block validation (for other reasons)
- we are not able to convert these numeric fields to character fields
We want to avoid a user being hasseled with the FRM-40209 ... message.
This message is
- not very helpfull because it does not inform us what the problem field is
- not suppressable
Any hints ?I went back to the drawing board on this one.
You are absolutely right : the message can be catched !
By writing an on-error trigger you can check for the error number. Sadly enough my first attempt on this used the on-message trigger which never fired hence my desperation.
Anyway, the on-error trigger in combination with :SYSTEM.CURRENT_ITEM or :SYSTEM.TRIGGER_ITEM enables me to display a more meaningfull message to my users.
Thanks for the hint. -
What is the idea of having STRING type when you can't write into that field
Hello friends
I am desperately trying to write to a field of a database table with DATA TYPE 'STRING'.
When I try to write it using a program from < SE38> or a function <SE37>, I get following error message, while activating the program.
============================================================
<DATABASE_TABLE> must be a flat structure. You cannot use internal tables,
strings, references, or structures as components.
============================================================
So, I have been going in circle to find out how to write a string into this field.
I can't use the CHAR or any such type with a limited field length, since the requirement from my customer is to use a variable length string.
Has anybody seen this problem before and if you have resolved this issue, I would appreciate if you can please let me know.
Thanks a lot in advance.
RamHi Harish
Thanks for your response.
I can create the table with the data type 'String'. However, the problem is when I try to update the table from a program in SE38 or a Function Module in SE37.
When I try to activate the PROGRAM or FUCNTION, I GET A MESSAGE THAT I MENTIONED EARLIER.
Here is the simple program that I have created that I am not able to activate
==========================================
REPORT ZTEST_STRING1.
tables: ztest.
ztest-zid = 2.
ztest-zstring1 = 'ABC'.
insert ztest.
===========================================
ztest has two fields
zid which is NUMC type
and zstring1 which is STRING type.
When I try to activate I get an error message as follows:
'ztest' must be a flat structure. You cannot use internal tables,
strings, references, or structures as components.
Edited by: Ram Prasad on Mar 20, 2008 6:08 PM -
My new wireless keyboard is repeating the "\" character endlessly. It also inserts the '\" into strings of characters as I type them in word or safari or firefox. I can't erase the characters fast enough or type fast enough not to get these characters. \Help!
Try changing the batteries on the keyboard or see if the keyboard has some sort of reset available.
-
How can I pull info into a report using just the first two characters of that field?
I am trying to pull a total cost based upon locations in a particular area(s). Can I get the formula to just do this based on the first two characters of that field?
Here is what I have so far:
if {PACKED.LOCATIONS.NEXT OPERATION} = ["xx"] THEN {Job.Total_Price}
Packed locations is a table I'm pulling from and the column I want just the first two digits is the the Next operation. Once this meets the "xx" (whatever location) then give me the total price from the Job table.
This works for one or two orders, but then blows up when I do 10 or so.Hi Steve, assuming that Next Operation is a string field...
Create a new formula and place it in the field where you see the {Job.Total_Price} field (Detail or Group depending on your report) with the formula:
whileprintingrecords;
global numbervar TotalValue;
if len({? Replace me}) <= len({PACKED.LOCATIONS.NEXT OPERATION}) then(
if left(ucase({PACKED.LOCATIONS.NEXT OPERATION}),len({? Replace me})) = ucase({? Replace me}) then
TotalValue := TotalValue + {Job.Total_Price}
TotalValue;
You can go ahead and suppress that field.
Create a new formula to place where you want to view the summary using the formula:
whileprintingrecords;
global numbervar TotalValue;
This method allows for a higher degree of flexibility and you can search for the first x characters of that field instead of only the first 2 characters -
Converting String Characters into Regular Expression Automatically?
Hi guys.... is there any program or sample coding which is available to convert string characters into regular expression automatically when the program is run?
Example:
String Character Input: fnffffffffffnnnnnnnnnffffffnnfnnnnnnnnnfnnfnfnfffnfnfnfnfnfnnnnd
When the program runs, it automatically convert into this :
Regular Expression Output: f*dhey guys.... i am sorry for not providing all the information that you guys need as i was rushing off to urgent meeting... for my string characters i only have a to n.. all these characters are collected from sensors and stored inside database... from many demos i have done... i found out that every demo has different strings of characters collected and these string of characters will not match with the regular expressions that i had created due to several unwanted inputs and stuff... i have a lot of different types of plan activities and therefore a lot of regular expressions.... if i put [a-z|0-9]*... it will capture all characters but in the same time it will be showing 1 plan only.... therefore, i am finding ways to get the strings i collected and let it form into regular expression by themselves in the program so that it will appear as different plans as output with comparing with the regular expression that i had created.... is there any way to do so?
please post again if there is any questions u are still not familiar with... thank you... -
Can you parse an array of string characters into separate arrays?
Hello,
I didn't see anything directly related to my question, so I'll go ahead and post it. I'm looking to parse an array of hex characters into three separate arrays for parallel Color to RGB conversion in LabView. Ideally, after importing an image, I would have liked to use the Color to RGB conversion for the 24-bit pixmap (in hex digit format), but apparently, you can only do this for single number conversions...not arrays. Another way is what I have mentioned above, which would be to parse each element's red, green, and blue # into three separate arrays as shown below:
Original Array: aa11ff 225599
cc4488 bbcc11
Array 1: aa 22
cc bb
Array 2: 11 55
44 cc
Array 3: ff 99
88 11
I could then do a parallel conversion of these arrays from hex to numeric and get the desired result. However, I'm having trouble finding a function that will do this. So I would like to ask if a function like this does exist and if so, what is it? I should note that I'm trying to avoid using two while loops because of time constraints (using the program for in-situ measurements), and we do not own, nor are we looking to purchase the $$$ vision/video package that NI makes.Nevermind. I found an adequate way.
-
Hi , we have a scenario where we have to move entire source structure into one of the fields of the target structure.
Example:
Source:
item1
description
store
storedescription
price
batch
Target:
item1
store
xmlstring
we would like to do following mappings:
1. item1 in source to item1 in target
2. store in source to store in target
3. entire source structure in XML format into xmlstring in target
we reffered following blog , but couldnt map to our requirement.
/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
XML to single element: Attn: Henrique
Thanks,
RajeshHI
I think you need to write UDF for this. there is library from apache called XML Serializer. Below is the sample file how you achieve that using that. Use that code in your UDF.
http://www.informit.com/articles/article.asp?p=31349&seqNum=3&rl=1
Even just concatenate into one field in the target during mapping and the send the data . this could also achive your requirments. no need to go for Java mapping
thanks
Swarup
Edited by: Swarup Sawant on Feb 15, 2008 11:42 AM
Edited by: Swarup Sawant on Feb 15, 2008 11:42 AM -
XML document convert into String and Insert into Database
Hello all,
In the FIle to File Scenario I want to send the data to the Reciever System in xml Document and convert into String and insert into Database.
Please can you tell me exact way how to send it.
Thanks & Regards,
RajHI,
As per my understanding your scenario is File to file where you will get output fiel in XML format.
Now that XMl payload need to be passed as single string in the database via XI.
You cauld do this but you need to imply some manipulations such as
With the help of standard API you need to concatenate the XML tags and create the structre along with the data.
For e.g. in your outpuf file the XML structre contain data as
<field1>ABCD</field1>
Then in mapping
The source field will be mappeda s concat(<field1>) + value of Source field "ABCD" + concat(</field1>) to the target field.
This is the way that you could achive the requirments else there is no direct way avaialble for it.
thanks
Swarup -
Output strings from loop into one string
im trying my best to explain my problem so ber in mind:)
hey having a bit of trouble with outputing strings from loop
example
i typed ab into the textbox
the output should be 12
but since it is in a loop it would only output the last string and in this case is 2
im trying to get both strings from the loop and output strings from loop into one string.
here is some of my code to understand my problem
// characters a to f
char[] charword = {'a','b','c','d','e','f'};
String charchange ;
// get text from password textbox
stringpassword = passwordTextbox.getText();
try {
// loop to show password length
for ( int i = 0; i < stringpassword.length(); i++ ){
// loop to go through alfabet
for (int it = 0; it < charword.length; it++){
// if char equals stringwords
if (stringpassword.charAt(i) == charword[it]){
System.out.print("it worked");
// change characters start with a
if (charword[it] == 'a'){
charchange = "1";
// change to 2
if (charword[it] == 'b'){
charchange = "2";
}Not sure how you are displaying the result but you could display each value as soon as you find it.
if (charword[it] == 'a'){
System.out.print("1");
}If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
if (charword[it] == 'a'){
charchange += "1";
} -
Joining Two Fields Into One Field for a View
I am trying to create a view based off of multiple tables.
I have all of the joins and everything done nicely and working properly.
However, when I get to this one step, that's when I start running into problems.
I just want to join (or concatenate) two fields together with a period character in between them.
For example, if I take FirstName and LastName, then I want them to become one field called Name, appearing as "JOHN.DOE"
When I try to join them together, the problem comes up with the period character.
A sample code of what I have done is here:
BEGIN
EXECUTE IMMEDIATE 'create view VIEW_LALALA
as SELECT t1.FirstName + '.' + t2.LastName as Name, t1.something as Something, t2.ooo as OOO
FROM (tableFirstNames t1 inner join tableLastNames t2 on t1.nameID = t2.nameID)
END;832667 wrote:
I am trying to create a view based off of multiple tables.
I have all of the joins and everything done nicely and working properly.
However, when I get to this one step, that's when I start running into problems.
I just want to join (or concatenate) two fields together with a period character in between them.
For example, if I take FirstName and LastName, then I want them to become one field called Name, appearing as "JOHN.DOE"
When I try to join them together, the problem comes up with the period character.
A sample code of what I have done is here:
BEGIN
EXECUTE IMMEDIATE 'create view VIEW_LALALA
as SELECT t1.FirstName + '.' + t2.LastName as Name, t1.something as Something, t2.ooo as OOO
FROM (tableFirstNames t1 inner join tableLastNames t2 on t1.nameID = t2.nameID)
END;to concatenate two string together do not use "+", but "||"
SELECT FIRST_NAME||'.'||LAST_NAME FROM EMP;
Maybe you are looking for
-
Master-details tables with popup edit form : popup doesn't zynchronized
In first, we don't use "Task Flow". We have 1 table master and 1 table details. Each of these tables shows an Edit button to open a popup formular. This formular is based on the same view object than the table below. The trouble is that : 1. The user
-
The iphone 4g white was thicker than the black one, is this the same for iphone 4s?
the iphone 4g white was thicker than the black one, is this the same for iphone 4s?
-
Best way to load a bunch of drum sounds?
Hey, all - In the course of getting rid of some older equipment, I've preserved a bunch of drum sounds that I want to continue using; I've recorded them and edited them into separate audio files (about 250). I'll be triggering them from a percussion
-
Shortcut for brush rotation & better 3D model rotation/movement
I'm pretty amazed that this still hasn't been added in. Just a nice simple shortcut to rotate the brush(and have the cursor reflect its current rotation) would really help instead of constantly having to go into the brush settings and play guess the
-
I bought my copy from ebay and when i got it I installed it, but every time i click on final cut pro 7 it asks for a serial number and when i put the on that came with it, it tells me it an invalid serail number. It is kinda making me want ti throw m