View previous topic :: View next topic
|
Author |
Message |
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
Hi Guys
Below is the scenario.
I have a varibale ( Suppose A ) in which values are like below
sDATA-AeDATAB*sDATA-CeDATA-D*sDATA-FeDATA-G*
this vaiable contains lots of the data like this.
now i have another variable VAR-A, i need to do a search in the above variable for VAR-A,note it can only match either DATA-A,DATA-C,DATA-F.Now if it matches to any of them,suppose VAR-A matches to DATA-F,then we need to get the DATA-G for further processing.
Or suppose VAR-A matches to DATA-C than ,we need DATA-D for further processing.
Please advise how we are going to do that ?
Thanks & Regards
BERUOIST |
|
Back to top |
|
|
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
can anyone ..help me on the above ?
Is there any other information is required ? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Code: |
sDATA-AeDATAB*sDATA-CeDATA-D*sDATA-FeDATA-G*
|
now, that is the contents of a field?????
is there some format or regularity to this data.
set up some fields, with data, and show us what you want to do. |
|
Back to top |
|
|
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
The data is like below
S1234567D1111*S2387787D1235*S2367787D1905*S2387000D1235*S2387733D1233 ***********
Now i have a variable in which i have 2387000, now i will have to do a search for 2387000 in above val (S1234567D1111*S2387787D1235*S2367787D1905*S2387000D1235*S2387733D1233 ***********
)
after finding this value i have to take the corresponding D record that is "1235" in my example to another value.
Can we do this by INSPECT or is there any other way out ??
Regards
beruoist |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you redefine the variable as an array of 1-char entries.
Using reference modification, parse that array looking for whatever value(s) and retrieve the needed D record(s). |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
beruoist wrote: |
The data is like below
S1234567D1111*S2387787D1235*S2367787D1905*S2387000D1235*S2387733D1233 ***********
|
Is this pattern constant? if yes, you can redefine the area as:
Code: |
01 data-as-table.
03 single-entry occurs 2000. (<= or whatever)
05 separator1 pic x.
05 key-code pic x(7).
05 separator2 pic x.
05 searched-value pic x(4).
05 separator3 pic x. |
And even if you cannot use a table because the length of "key-code" or "searched-value" is variable, you can use the 'S' and '*' to get to your point (somehow). |
|
Back to top |
|
|
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
Is there any way by we can get starting position where a match occurs,then it will be easier to get the record.
Any idea guys how we can incorporate this ? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Yes, that is what i told you earlier. . . Marso then provided a possible alternative depending on the format or your data.
If you do as i suggested (redefine the data area as an array of 1-byte occurrences and use reference modification), the process will work even if the data is "irregular, but maintains the "D" value behind the search value. |
|
Back to top |
|
|
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
Sorry,I would have told this thing earlier.I am not a COBOL( i have worken in Natural,Adabas) bod.
Dick can you please elaborate a more how i will do this by reference modification ?
i understood the redefining part. |
|
Back to top |
|
|
beruoist
New User
Joined: 14 Nov 2007 Posts: 70 Location: mumbai
|
|
|
|
Also redefining is better way,but if a match occurs how will you move the corresponding D record for the processing.I mean to say how will you know which corresponding record to move until you have the position of the matched record ? |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
Back to top |
|
|
|