Page 1 of 1

COBOL string handling

PostPosted: Mon Nov 14, 2011 10:36 pm
by shirazi2589
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.

Re: COBOL string handling

PostPosted: Mon Nov 14, 2011 10:55 pm
by BillyBoyo
Several methods are possible. INSPECT REPLACING, reference modification, occurs depending on and others. How are you "getting rid of" your "*"?

Re: COBOL string handling

PostPosted: Mon Nov 14, 2011 11:22 pm
by shirazi2589
would this work
STRING NAME DELIMITED BY '*' INTO WS-NAME2.
INSPECT WS-NAME2 REPLACING ALL ' ' BY '_' AFTER INITIAL '*'.

Re: COBOL string handling

PostPosted: Mon Nov 14, 2011 11:27 pm
by dick scherrer
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.

Re: COBOL string handling

PostPosted: Mon Nov 14, 2011 11:50 pm
by shirazi2589
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.

Re: COBOL string handling

PostPosted: Tue Nov 15, 2011 12:00 am
by dick scherrer
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".

Re: COBOL string handling

PostPosted: Tue Nov 15, 2011 1:17 am
by BillyBoyo
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?