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

Accept a string if its first 2 bytes contains capital letter


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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: 419
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Sun Feb 26, 2006 11:03 pm
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
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
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: 419
Location: Inside the SPEW (Southwest Ohio, USA)

PostPosted: Mon Feb 27, 2006 6:30 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top