Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi ! I have a seqential file tha

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi !

I have a seqential file that has a few fields that contain data in binary format(they were defined in the program as PIC S9(9) COMP).Which means i cannot see them and read them meaningfully when i browse the data.My client wants this file to be converted so that she can read the binary data also meaning fully while browsing the file.So my task now is to convert the binary data into numric format so that she can read it while browsing and could undestand.

Do we have any cobol functions
(a)that convert binary data into ordinary numeric data
(b)that convert packed data into ordinary numeric data

or do we need to resort to REXX or CLIST ?


So that i will rewrite the file with the numeric data in place of binary one.

Referring to previous messages in this FORUM indicates that there exists a solution in REXX.

My question is

Can we embed the REXX code in a VS COBOL II program?
And if i can what else do i need to do to make this program compile and execute?

OR

Can i give my binary file as input to the REXX exec and create an output file with converted decimal data?



I will appreciate any one who has solution for this.

Regards,
Akondeti

[sig][/sig]
 
Akondeti,

2 options you could try...

Option 1...
Call IRXJCL from your COBOL code. The parameter for the call consists of the REXX program name you wish to run, followed by any parameters to be used by the REXX program.

You will need to allocate a SYSEXEC DD prior to the call, which is the PDS where the REXX program can be found.

Option 2...
Use the following REXX to do a straight forward read of one file the write out another file with some field conversion between...

/* Rexx */
idsn = 'hlq.TESTIP'
odsn = 'hlq.TESTOP'
"ALLOC F(DDSEQ01R) DA('"idsn"') SH"
"ALLOC F(DDSEQ01W) DA('"odsn"') SH"

irectot = 0 /* Init i/p record counter. */
orectot = 0 /* Init o/p record counter. */
limit = 30000 /* Scroll thru i/p file this many records at a time. Optimum number depends on record size and region size.*/
start = 1 /* Start at this record number in the i/p file. */

do forever
drop in.
"EXECIO "limit" DIS [sig][/sig]
 
Hi Ringd !

Thank you so much
Let me try these options.

regards,
Akondeti [sig][/sig]
 
If you're writing in VS COBOL II, I believe just a move between a packed decimal to a numeric display will work. No calling of translate or other programs is necessary. Just make sure the receiving field is large enough to hold all the digits. [sig]<p>PhiloVance<br>Other hobbies, interests: Travel, Model RR (HO Gauge), Genealogy.[/sig]
 
Sorry, told you wrong. That should read

just a move between a packed decimal or binary decimal to a numeric display will work.



Example:

77 PACKED-DECIMAL VALUE +230 PIC S9(3) COMP-3.
77 BINARY-DECIMAL VALUE +230 PIC S9(3) COMP.
77 NUMERIC-DISPLAY VALUE 0 PIC 9(10).

either MOVE PACKED-DECIMAL TO NUMERIC-DISPLAY
or
MOVE BINARY-DECIMAL TO NUMERIC-DISPLAY

will produce the same result.

[sig]<p>PhiloVance<br>Other hobbies, interests: Travel, Model RR (HO Gauge), Genealogy.[/sig]
 
Thanks Philo !

It worked as i tried accidentally today.The mistake i was doing was reading the file into a record 397 bytes long and using reference modification to move the binary data into a numeric variable and then asking the numeric variable to display.
In the mean time i was referring to REXX to read the file and write a separte file after modification as suggested by ringd .But i was not knowing how to refer to a specific field in the record and modify it.For example the emp-status field occurs between 34-37 byte positions.Using REXX how to access the emp-status field at 34-37 th position after reading the record, inorder to modify it?

Hi,
Pholo / Ringd
Please let me know the way to do this .

Thanks,
Akondeti
[sig][/sig]
 
Akondeti:

I'm a bit confused. Your original post contains the following:

[q]
Do we have any cobol functions
(a)that convert binary data into ordinary numeric data
(b)that convert packed data into ordinary numeric data

or do we need to resort to REXX or CLIST ?
[/q]

From that, I assumed you were writing a COBOL program and had no need for REXX unless it would perform a specific function you're unable to perform in COBOL. If this is the case, my first and second post should cover the topic. Everything you want to do can be done in COBOL.

If, however, you need to use REXX, then follow Ringd's suggestion.
[sig]<p>PhiloVance<br>Other hobbies, interests: Travel, Model RR (HO Gauge), Genealogy.[/sig]
 
Akondeti,

Looks like the 2nd half of my previous reply was chopped off! Here is the rest, starting at the DO FOREVER...

do forever
drop in.
&quot;EXECIO &quot;limit&quot; DISKR DDSEQ01R &quot;start&quot; (STEM in.&quot;
numofrecs = in.0
irectot = irectot + numofrecs
do a = 1 to numofrecs
call rec_process /* this subroutine processes each record */
end a

out.0 = in.0
orectot = orectot + out.0
&quot;EXECIO * DISKW DDSEQ01W (STEM out.&quot;
drop out.
start = start + numofrecs
if numofrecs < limit then leave
end

&quot;EXECIO 0 DISKW DDSEQ01W (FINIS&quot;
&quot;EXECIO 0 DISKR DDSEQ01R (FINIS&quot;
&quot;FREE F(DDSEQ01W DDSEQ01R)&quot;
say 'Total records processed is 'irectot

exit

REC_PROCESS:
/* Variable 'part1' is the first 33 bytes, 'indec1'
is the packed decimal (col 34 for 4), 'part2' is the rest
of the record. */
parse var in.a part1 34 indec1 38 part2
odec1 = P2D(indec1) /* Convert indec1 from packed decimal */
/* odec1 [sig][/sig]
 
Akondeti,

It happened again! I'll have fix this!! Here is the part that was chopped off my last reply, from the PARSE VAR...
----------------------------------------
parse var in.a part1 34 indec1 38 part2
odec1 = P2D(indec1) /* Convert indec1 from packed decimal */
/* odec1 is the unpacked number. */
out.a = part1||odec1||part2 /* build the output record. */
return

/* Convert a packed field to readable EBCIDIC. */
P2D:
parse arg pdn
erg = C2X(pdn)
sign = RIGHT(erg,1)
number = LEFT(erg,LENGTH(erg)-1)
select
when sign = 'C' then return number
when sign = 'D' then return '-'||number
otherwise return 'ERROR'
end
---------------------------------------------------
Hope this reaches you in one piece! Let me know if it helps.

Cheers,
Dave.
Dave.Ring@barclays.co.uk [sig][/sig]
 
Hi Philo !

Sorry for the confusion i caused.
Actually i have about 10 files each has one or more binary fields.My endeavour is to take each file as input and create a new file as output that contain all the data as that of old file plus the converted binary field to decimal so that the user can read the record meaningfully while browsing.

Thanks,
Akondeti [sig][/sig]
 
Hi Ringd !

I apprciate your patience and perservance in recopying/retyping the missing parts in your posting.

Thanks i will try this.

Akondeti [sig][/sig]
 
You say 'while browsing ... ' . Why not let the browser software do the conversion.

bobh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top