extract values from a code



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

extract values from a code

Postby thirdeye » Fri Sep 21, 2007 7:18 am

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!
thirdeye
 
Posts: 1
Joined: Fri Sep 21, 2007 7:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: extract values from a code

 

Re: extract values from a code

Postby CICS Guy » Fri Sep 21, 2007 2:28 pm

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....
CICS Guy
 
Posts: 255
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: extract values from a code

Postby dick scherrer » Sat Sep 22, 2007 4:56 am

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.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: extract values from a code

Postby cravi_pdy » Tue Nov 13, 2007 5:24 pm

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
cravi_pdy
 
Posts: 5
Joined: Tue Nov 13, 2007 5:06 pm
Has thanked: 0 time
Been thanked: 0 time

Re: extract values from a code

Postby CICS Guy » Tue Nov 13, 2007 8:01 pm

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
CICS Guy
 
Posts: 255
Joined: Wed Jun 20, 2007 4:08 am
Has thanked: 0 time
Been thanked: 0 time

Re: extract values from a code

Postby Lina » Sun Nov 25, 2007 2:54 pm

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
Lina
 
Posts: 9
Joined: Sun Nov 25, 2007 2:12 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post