Author |
Message
|
cadenza |
Posted: Tue Dec 12, 2006 8:55 am Post subject: FIELDTYPE Issue ... Checking for existence of input field |
|
|
Apprentice
Joined: 01 Jun 2004 Posts: 48
|
Hi All,
As per the manual FIELDTYPE function is recommended to test the presence of an input field.
I have a large nested XML message that has a combination of lot of repeating segments. Therefore I have used references to access these elements.
Code:
IF FIELDTYPE(REF_Segment1) IS NOT NULL THEN
Process Data 1
END IF
IF FIELDTYPE(REF_Segment2) IS NOT NULL THEN
Process Data 2
END IF
However it is not working as expected. If there is no Segment2 in the input message it is entering Process Data 2.
I changed FIELDTYPE to FIELDNAME and found in the trace that the name returned for Segment2 is the parent field !!!!
For eg:
For the following abstract of input message
<Library> <Book> <Fiction> <SciFi> ....
if my REF_Segment2 points to Library.Book.Fiction.SciFi and if it is absent then FIELDNAME(REF_Segment2) is returning me "Fiction" !!!
I am not sure if I have understood the FIELDNAME function correctly. I guess it is the same reason why FIELDTYPE is also not returning NULL to me. May be it is returning the field type of Fiction instead of SciFi.
In this scenario ... can any one of you tell me how to test for the presence of input field correctly? I have searched this forum and it seems that if we do not use REFERENCES then it may work ... however that solution wont work for me as I need to use REFERENCES.
I am using MB 5.0 CSD 5
Thanx. |
|
Back to top |
|
 |
elvis_gn |
Posted: Tue Dec 12, 2006 9:22 am Post subject: Re: FIELDTYPE Issue ... Checking for existence of input fiel |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi cadenza,
FIELDNAME is supposed to return the name of the field, if it is returning Fiction, then the reference is pointing at that, how it reached there will only be understood if we see ur code....If Library did not exist and you had DECLAREed your reference directly to it, it would have pointed on Root.
FIELDTYPE is supposed to return the type such as integer, string etc...
If you want to check existance of the field, you could use DECLARE or MOVE(since ur using a reference) and then check for LASTMOVE....
Regards. |
|
Back to top |
|
 |
special_agent_Queue |
Posted: Tue Dec 12, 2006 9:58 am Post subject: |
|
|
 Centurion
Joined: 27 Jul 2006 Posts: 102
|
This indicates to me that you are not referencing correctly.
Check to make sure your path is correct.
Or use the LASTMOVE as elvis_gn suggested. This is the way I would go- sometimes the FIELDTYPE/FIELDNAME functions can be tricky. |
|
Back to top |
|
 |
cadenza |
Posted: Tue Dec 12, 2006 1:10 pm Post subject: |
|
|
Apprentice
Joined: 01 Jun 2004 Posts: 48
|
Hi All,
The references are correct ... I have double checked them. However thanx for your suggestions ... it is working with LASTMOVE.
So for checking the existence of any input field the recommended steps would be ...
Declare Reference to the input field
IF LASTMOVE(Reference) THEN
Field Exists
ELSE
Field Does not exist.
END IF;
But I do wonder what went wrong with FIELDNAME & FIELDTYPE functions.
Any Ideas?
Thanx. |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Dec 12, 2006 1:26 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Is CSD05 the most recent CSD of WBIMB v5? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|