COBOL string handling



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COBOL string handling

Postby shirazi2589 » Mon Nov 14, 2011 10:36 pm

I have an application which demands me to include wild card search from db2 database
hance the query is somewhat :
EXEC SQL
SELECT EMPID INTO :EMPID WHERE NAME LIKE :NAME
END-EXEC.

I would accept name from CICS map if user enters SH* then all names starting should be listed...
how should i accomplish this task( I am using a CURSOR the query was just for display purpose)

one solution i thought of is to have variable with entry 'SH______" assuming my variable to be of 8 bytes but what if its SHI*
how can i dynamically allot to a variable
if i use
01 name
05 name1 pic x(05)
05 sym pic x(03) value all '_'

then if i move SHI* after removing * then i would have SHIbb___ in my name field..... which doesn't work

how should i go abt it.
shirazi2589
 
Posts: 15
Joined: Mon Nov 14, 2011 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL string handling

Postby BillyBoyo » Mon Nov 14, 2011 10:55 pm

Several methods are possible. INSPECT REPLACING, reference modification, occurs depending on and others. How are you "getting rid of" your "*"?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: COBOL string handling

Postby shirazi2589 » Mon Nov 14, 2011 11:22 pm

would this work
STRING NAME DELIMITED BY '*' INTO WS-NAME2.
INSPECT WS-NAME2 REPLACING ALL ' ' BY '_' AFTER INITIAL '*'.
shirazi2589
 
Posts: 15
Joined: Mon Nov 14, 2011 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL string handling

Postby dick scherrer » Mon Nov 14, 2011 11:27 pm

Hello and welcome to the forum,

We are big believers in "learning by doing". . .

What happens when you try this?

Any questions/problems, post what happened and someone should be able to clarify.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: COBOL string handling

Postby shirazi2589 » Mon Nov 14, 2011 11:50 pm

actually i havent done this i would go to my lab tomorrow and execute this piece of work.....

one small doubt if u can clarify now it would be helpful for me.

can i call a cobol-db2 program (batch prgram) via 'call' command from CICS-DB2 program.

i want to upload records from a file into the database if the user presses one of the AID keys.

eg say if user presses F2 then the COBOL - DB2 program needs to be called which would read records from a PS(non VSAM file)
and add the records into the data base..


can i accomplish this task via STATIC CALL command i.e CALL PGM USING NAME1.
shirazi2589
 
Posts: 15
Joined: Mon Nov 14, 2011 9:08 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COBOL string handling

Postby dick scherrer » Tue Nov 15, 2011 12:00 am

Hello,

Most organizations do not permit online programs to allocate/use external sequential files.

Online programs also do not "call" batch programs.

If a user pressed an "aid" key, how does the system know which file to read to get the database updates?

Suggest this process be re-designed. Possibly the online process could "submit" a customized batch job to do the updates. There would be no "call".
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: COBOL string handling

Postby BillyBoyo » Tue Nov 15, 2011 1:17 am

CALL 'PGM' could be a static call, if compiled with option NODYNAM. CALL PGM (which is not a literal) will be a dynamic call, whatever the compiler option.

If you want to access DB2 from CICS, you need to do that how CICS wants you to do it. You can't just use a batch program that happens to do what you want. Maybe you could make a "module" that is usable in batch and CICS, so you have the same code, but do some research and testing before you decide to go that route.

Back to your other question, if you remove the "*" you can't use it as a starting-point for your INSPECT?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post