IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Searching into a variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Mon Nov 24, 2008 4:14 pm
Reply with quote

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
View user's profile Send private message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Mon Nov 24, 2008 5:33 pm
Reply with quote

can anyone ..help me on the above ?
Is there any other information is required ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Nov 24, 2008 5:41 pm
Reply with quote

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
View user's profile Send private message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Mon Nov 24, 2008 6:08 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Nov 24, 2008 9:03 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Mon Nov 24, 2008 11:27 pm
Reply with quote

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
View user's profile Send private message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Tue Nov 25, 2008 1:32 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Nov 25, 2008 2:31 am
Reply with quote

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
View user's profile Send private message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Tue Nov 25, 2008 10:31 am
Reply with quote

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
View user's profile Send private message
beruoist

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Tue Nov 25, 2008 10:36 am
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Nov 25, 2008 11:37 am
Reply with quote

Hi, Here are couple of threads which will help you.

ibmmainframes.com/viewtopic.php?t=34435&highlight=search
ibmmainframes.com/viewtopic.php?t=35454&highlight=search
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Searching for a member but don't know... TSO/ISPF 6
Search our Forums:

Back to Top