Compare text type variable with code type variable

zpgm
Member Posts: 6
Hi all,
I am having a hard time using STRPOS() to compare a CODE and a TEXT variable.
Here's what I have:
VAR:
myTxt TEXT(80)
myCode CODE(20)
myCode:= '329021277';
myTxt:= '329021277/5504';
using STRPOS(myTxt, myCode) always returs 0!!
I've already used the FORMAT function to cast one type to another but keeps on returning 0.
I will try to parse both variables char by char...but I would like to know the reason why this happens.
Thank you all.
Best regards.
I am having a hard time using STRPOS() to compare a CODE and a TEXT variable.
Here's what I have:
VAR:
myTxt TEXT(80)
myCode CODE(20)
myCode:= '329021277';
myTxt:= '329021277/5504';
using STRPOS(myTxt, myCode) always returs 0!!
I've already used the FORMAT function to cast one type to another but keeps on returning 0.
I will try to parse both variables char by char...but I would like to know the reason why this happens.

Thank you all.
Best regards.
0
Comments
-
Strange as I would expect it to work too, however if it doesn't then you can simply assign the code variable to another text variable and then just use the 2 text vars in STRPOS0
-
As expected, your code (as stated here) is working for me (NAV 2009 R2 / 6.00.30012).
Re-examine what you really coded.0 -
Thanks for your replies.
The code I posted is working fine... I oversimplified my error and mislead you all (even myself).
I have a few customized fields in my "Job Ledger Entry" table and one of them is a Text(80).
I have an automated process that imports data from a CSV file and saves it in a table (let's call it "Imported Lines"). Then all that imported data is validated and if it is ok is posted in the "Job Journal Line". Finally, using the "Job Jnl.-Post" codeunit post that data in the Job Ledger Entry.
All those posted records have only one field that can be edited (in the Job Ledger Entry table) by the user and a few times its content is modified.
In a process I designed I am comparing records in the Job Ledger Entry with records in the "Imported Lines":ImportLines.RESET; IF ImportLines.FIND('-') THEN REPEAT JobLedgEntry.RESET; JobLedgEntry.SETFILTER("Journal Batch Name" , 'GTROUPAS|GTRESIDUOS'); JobLedgEntry.SETRANGE("Job No.", ImportLines."Job No"); JobLedgEntry.SETRANGE("Posting Date", ImportLines."Post Date"); JobLedgEntry.SETRANGE("No.", ImportLines."Resource Code"); IF JobLedgEntry.FIND('-') THEN REPEAT IF STRPOS(JobLedgEntry."Transport Num.", ImportLines."Transport Num.") > 0 THEN BEGIN ... END; UNTIL JobLedgEntry.NEXT = 0; UNTIL ImportLines.NEXT = 0;
The JobLedgEntry."Transport Num." is a Text(80) and the ImportLines."Transport Num." is a Code(20).
I tried debugging with a message box displaying the return value of STRPOS and that message displays 0... The values I posted before (in the myTxt and myCode)are values that exist in both tables.
I tried casting the value of the text variable to a code variable and use that one in the SRTPOS with no luck.
Thanks once again.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions