Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Searching into a variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Searching into a variable
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    Post subject: Reply to: Searching into a variable
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: 6968
Location: porcelain throne

PostPosted: Mon Nov 24, 2008 5:41 pm    Post subject:
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    Post subject: Reply to: Searching into a variable
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

Site Director


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

PostPosted: Mon Nov 24, 2008 9:03 pm    Post subject:
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: 1232
Location: Israel

PostPosted: Mon Nov 24, 2008 11:27 pm    Post subject: Re: Reply to: Searching into a variable
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    Post subject: Reply to: Searching into a variable
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

Site Director


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

PostPosted: Tue Nov 25, 2008 2:31 am    Post subject:
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    Post subject: Reply to: Searching into a variable
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    Post subject: Reply to: Searching into a variable
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    Post subject:
Reply with quote

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

http://ibmmainframes.com/viewtopic.php?t=34435&highlight=search
http://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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us