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
 

 

Accept a string if its first 2 bytes contains capital letter

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Sat Feb 25, 2006 3:22 pm    Post subject: Accept a string if its first 2 bytes contains capital letter
Reply with quote

Hi,i want 2 accept a string if its first 2 bytes contains capital letters help me pls.E.G HB222
Back to top
View user's profile Send private message

mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Feb 25, 2006 9:14 pm    Post subject:
Reply with quote

Hi Jackal,

You don't show us how the string is defined in the COBOL pgm. If it's:

05 fld-a pic x(005).

You can use:
Code:

if fld-a(1:2) = 'HB'
   perform 200-accept-string
end-if
Back to top
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Sun Feb 26, 2006 2:11 pm    Post subject: Re: One condition in cobol
Reply with quote

Hi mmwife,i got your answer but the problm is to accept only tht string whch is having 1st 2 char capital not only HB.
E.G 01 A pic X(5).
Accept strngs like AC222
DM562
thanx in advance
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 241
Location: Cincinnati OH USA

PostPosted: Sun Feb 26, 2006 11:03 pm    Post subject:
Reply with quote

here's some psuedo code

[code]

if field(1:1) => 'A' and field(1:1) <='Z' and field(2:1) =>'A' and field(2:1) <= 'Z'
then accept
else ...
endif

[/code
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Feb 27, 2006 5:30 am    Post subject:
Reply with quote

Hi Jackl,

Sorry, I misunderstood.

You can try something like this:

CONFIGURATION SECTION.
SPECIAL NAMES. CLASS UP-ALPHA IS A THRU I J THRU R S THRU Z.

In PD.

if fld-a(1:2) is up-alpha
perform 200-accept-string
end-if

What Dave suggests can be dangerous since A - Z are not contiguous in the coallting sequence. But since you 're dealing w/printable chars you may get away with it.

Some of the printable chars other than A thru Z that exist in that range are "}" "\". There are 2 or 3 others but there not usually seen in print.

So if that doesn't seem a threat to you, Dave's solution is fine.

The solution I offered is similar to the IF NUMERIC/IF ALPHABETIC clauses you've seen on occasion. This one (UP-ALPHA) is custom made.
Back to top
View user's profile Send private message
jackal
Currently Banned

New User


Joined: 21 Jan 2006
Posts: 48
Location: india

PostPosted: Mon Feb 27, 2006 1:38 pm    Post subject: Re: One condition in cobol
Reply with quote

Thanx alot mmwife and dneuforth 4 ur assistance.
Jackal
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 241
Location: Cincinnati OH USA

PostPosted: Mon Feb 27, 2006 6:30 pm    Post subject:
Reply with quote

mmwife,

good point on the extra characters in the A to Z range

I forgot about that.
Back to top
View user's profile Send private message
M.Bhavani Prasad

New User


Joined: 10 Mar 2006
Posts: 6
Location: Hyderabad

PostPosted: Fri Mar 10, 2006 1:19 pm    Post subject: need the diffference between the return codes and abend code
Reply with quote

icon_confused.gif
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


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