Seperate string and setrange
klum
Member Posts: 102
Hi All,
I would like to seperate string and setrange to record for find record and sum up amount and change status.
1. I put the no. in text box "Card No."(code20) - 0001,0002,0003,0004
2. I want to seperate each No. by (,) for setrange with VoucherReg Table
At Textbox "Card No."-Onvalidate
](*,)
I don't know how to cut each No. to setrange with "VoucherReg.SETRANGE("Voucher No.","Card No.")"
If somebody know please guide me with the code ....(I search about SelectStr already but I tell you guys the truth I don't understand much)
Thank in advance
Wanvisa
I would like to seperate string and setrange to record for find record and sum up amount and change status.
1. I put the no. in text box "Card No."(code20) - 0001,0002,0003,0004
2. I want to seperate each No. by (,) for setrange with VoucherReg Table
At Textbox "Card No."-Onvalidate
//Sum up amount for each voucher
IF SaleHeaderRec2."Payment Method Code" <> '' THEN BEGIN
VoucherReg.RESET;
VoucherReg.SETRANGE(Type,VoucherReg.Type::Voucher);
[b]VoucherReg.SETRANGE("Voucher No.","Card No.");[/b]
IF VoucherReg.FIND('-') THEN BEGIN
IF VoucherReg.Status = VoucherReg.Status::Sold THEN BEGIN
REPEAT
VoucherAmt += VoucherReg."Amount LCY";
UNTIL VoucherReg.NEXT = 0;
ReceiveTmp := VoucherAmt;
END ELSE
ERROR('This voucher has status:%1',VoucherReg.Status,FALSE);
END ELSE
ERROR('This voucher could not be found',FALSE);
END;
](*,)
I don't know how to cut each No. to setrange with "VoucherReg.SETRANGE("Voucher No.","Card No.")"
If somebody know please guide me with the code ....(I search about SelectStr already but I tell you guys the truth I don't understand much)
Thank in advance
Wanvisa
0
Answers
-
Hi Klum
You could use"Card No." := CONVERTSTR("Card No.",',','|'); CoucherReg.SETFILTER("Voucher No.",'%1',"Card No.");
Hope this helps0 -
Well, you should use the SELECTSTR-statement for this, imho.
E.g.
commastring := '012,345,567,889,345';
SELECT(4,commastring)
This will give you '889', being the 4th part in your string.
To know how many times you have to loop through your string, you can count the comma's (+1).
strCommas := DELCHR(String,"=",DELCHR(String,'=',','));
intNumberOfLoops := STRLEN(strCommas ) + 1;
Then you can fill a temp table.0 -
Hi,
Thank for your help Albertvh but It's not work for me
so I have to try that difficult for me from Waldo....And one question now ...How to fill a temp table please guide me with some code. :oops:
Thank a lot for your help guys O:)
Wanvisa0 -
Working with temporary table is the same as with "normal" table. The only difference is that you must set the the Temporary property in record variable definition.0
-
Well not entirely. You can only transfer the temp table by using var, and it has a bigger scope than normal tables.0
-
Thanks for every reply and Happy Chinese New Year

Now I understand more about String Function because of try and test.....and I also will try to understand about temporary table.
Best Regards,
Wanvisa0 -
I have question about something I tested from example that someone posted here...
From Example : I've got the error "Type conversion is not possible.....Integer := Text"Hyphon := STRPOS(COPYSTR(CardStr,'-',1,commaSep));
I dont' understand that what does mean about '-' and I try from online help STRPOS and COPYSTR function
My example code : (my code doesn't have '-' because i've got same error)CardStr := "Card No."; //Key : 01,0001 CommaSep := STRPOS(CardStr,','); //Result : 3 NewStr := DELCHR(COPYSTR(CardStr,1,CommaSep),'=',','); //Result : 01
My question is I would like to know about '-' use for what? it should have or should not? (Or if have i will got same error for sure lol)
If I have code like this :NewStr := DELCHR(COPYSTR(CardStr,'-',1,CommaSep),'=',',');
Thanks in advance
Wanvisa
0 -
Don't know if I understand the question exactly, but I can tell you this:
In the first statement, the COPYSTR is wrong.
These are the syntaxes of the two statements:
NewString := COPYSTR(String, Position [, Length])
Position := STRPOS(String, SubString)
So when you try the statement:
Hyphon := STRPOS(COPYSTR(CardStr,'-',1,commaSep));
you put a '-' on the posistion where C/SIDE expects an integer.
That's wy it gives the error "Type conversion is not possible.....Integer := Text"0 -
Hi Waldo
,
Thanks a lot for your clearly suggestion. In the first statement I just try to follow example about string funtion from this :
http://www.mibuso.com/forum/viewtopic.p ... ing+string
Then I struck with this statement : Hyphon := STRPOS(COPYSTR(CardStr,'-',1,commaSep));
But now I understand already ...thanks again.
Best Regards,
Wanvisa
0 -
Hi Waldo
,
Who will dare to do that. lol But now it's my good news I can find solution for myself about my question already. It's not nice code but it's work very well for me
It might usefull for somebody(I hope so)CardStr := "Card No."; CommaSep := STRPOS(CardStr,','); strCommas := DELCHR(CardStr,'=',DELCHR(CardStr,'=',',')); intNumberOfLoops := STRLEN(strCommas ) + 1; FOR i := 1 TO intNumberOfLoops DO BEGIN VoucherNo := DELCHR(COPYSTR(CardStr,1,CommaSep),'=',','); LenStr := STRLEN(VoucherNo)+1; VoucherReg.RESET; VoucherReg.SETRANGE("Voucher No.",VoucherNo); IF VoucherReg.FIND('-') THEN BEGIN VoucherReg."Vouchers Payment" := TRUE; VoucherReg.MODIFY; END; CardStr := DELSTR(CardStr,1,LenStr); END; IF "Card No." <> '' THEN BEGIN VoucherReg.RESET; VoucherReg.SETRANGE(Type,VoucherReg.Type::Voucher); VoucherReg.SETRANGE("Vouchers Payment",TRUE); IF VoucherReg.FIND('-') THEN BEGIN IF VoucherReg.Status = VoucherReg.Status::Sold THEN REPEAT VoucherAmt += VoucherReg."Amount LCY"; UNTIL VoucherReg.NEXT = 0; ReceiveTmp := VoucherAmt; CurrForm.RecieveField.UPDATE; END; END;
:whistle: I can sum it up ..... :sick: Oop!! but i have a difficult task waiting for me about connection to ADO (now back to feel like a donkey again lol but be a donkey in shrek)
Thank a lot for every help .....very usefull for me [-o<
Best Regards,
Wanvisa0 -
klum wrote:Hi Waldo
,
Who will dare to do that. lol But now it's my good news I can find solution for myself about my question already. It's not nice code but it's work very well for me
It might usefull for somebody(I hope so)CardStr := "Card No."; CommaSep := STRPOS(CardStr,','); strCommas := DELCHR(CardStr,'=',DELCHR(CardStr,'=',',')); intNumberOfLoops := STRLEN(strCommas ) + 1; FOR i := 1 TO intNumberOfLoops DO BEGIN VoucherNo := DELCHR(COPYSTR(CardStr,1,CommaSep),'=',','); LenStr := STRLEN(VoucherNo)+1; VoucherReg.RESET; VoucherReg.SETRANGE("Voucher No.",VoucherNo); IF VoucherReg.FIND('-') THEN BEGIN VoucherReg."Vouchers Payment" := TRUE; VoucherReg.MODIFY; END; CardStr := DELSTR(CardStr,1,LenStr); END; IF "Card No." <> '' THEN BEGIN VoucherReg.RESET; VoucherReg.SETRANGE(Type,VoucherReg.Type::Voucher); VoucherReg.SETRANGE("Vouchers Payment",TRUE); IF VoucherReg.FIND('-') THEN BEGIN IF VoucherReg.Status = VoucherReg.Status::Sold THEN REPEAT VoucherAmt += VoucherReg."Amount LCY"; UNTIL VoucherReg.NEXT = 0; ReceiveTmp := VoucherAmt; CurrForm.RecieveField.UPDATE; END; END;
:whistle: I can sum it up ..... :sick: Oop!! but i have a difficult task waiting for me about connection to ADO (now back to feel like a donkey again lol but be a donkey in shrek)
Thank a lot for every help .....very usefull for me [-o<
Best Regards,
Wanvisa
Thank you for sharing your solution.
I think you could have simplified the first part with the SELECSTR-statement ... but if it works for you ...0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
