Page 1 of 1

extract values from a code

PostPosted: Fri Sep 21, 2007 7:18 am
by thirdeye
in my program I have a code
01 code pic x(12)
for instance:

AB27272727CD

how can I extract the single parts AB 27272727 CD ?
cobol 2 if I'm not wrong, but I can't remember...
thank you all,

3rd!

Re: extract values from a code

PostPosted: Fri Sep 21, 2007 2:28 pm
by CICS Guy
Generally, if the "single parts" are variable, an inline perform with reference modification could do what you need....
If they are fixed, redefinition would be an alternative....

Re: extract values from a code

PostPosted: Sat Sep 22, 2007 4:56 am
by dick scherrer
Hello,

If you provide more information, we can be better help.

In your 12 byte field, is the "split" always 2/8/2? If yes the following moves will work for you
MOVE code(1:2) TO THE-FIRST-PART
MOVE code(3:8) TO THE-SECOND-PART
MOVE code(11:2) TO THE-THIRD-PART.
Those fields would be pic xx, x(8), and xx respectivedly.

If your requirement has more elaborate rules, post the rules here and we will be able to offer suggestions.

Re: extract values from a code

PostPosted: Tue Nov 13, 2007 5:24 pm
by cravi_pdy
01 code pic x(12)
...........................
01 code-t.
05 code-p1 pic x(02).
05 filler pic x value space.
05 code-p2 pic x(08).
05 filler pic x value space.
05 code-p3 pic xx.
then
move code to code-t
I think this will work.
pl. respond me

Re: extract values from a code

PostPosted: Tue Nov 13, 2007 8:01 pm
by CICS Guy
cravi_pdy wrote:I think this will work.
pl. respond me
Nope, it will not....You will end up with something like
AB27272727CD?? where the ?? is anything from low values to garbage

Re: extract values from a code

PostPosted: Sun Nov 25, 2007 2:54 pm
by Lina
Please let me know if the following piece of code would work as a solution to the above problem

01 code pic x(12)

01 CODE1
05 CodeA PIC x(02)
05 codeB pic x(08)
05 codeC PIC X(02)

01 A Pic X(01) value 'space'

Move Code to Code1.

STring codeA delimited by space ,
A delimited by size ,
codeB delimited by space,
A delimited by size,
codeC delimited by space