Hello all,
Due to a program change that was made in a non-Unicode environment to make a program Unicode compliant, I now have a file that is read by other programs that has an amount field that has two different formats.
Format 1:
field_1(150)
field_2(8) type p
Format 2:
field_1(150)
field_2(15) type n
I am trying to create a one-time utility program to convert all of the old records that have a packed data field into the new format where the amount field is type n. All of my efforts so far have either resulted in compile errors, or programs that will compile, but abend when they're run.
The code below will show you what I'm attempting to do. Any thoughts on how I can resolve my problem will be greatly appreciated
In file format 1 the packed field's hex value is '123456789012345C', occupying eight bytes .
In file format 2 the number field should be 123456789012345, occupying 15 bytes.
Thanks
Bruce
*>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<
data: begin of detlrec.
data: Char_150(150),
respti(8) type p,
data: end of detlrec .
*
data: begin of detlrec_uc.
data: Char_150(150),
respti_uc(15) type n,
data: end of detlrec_uc .
*
data: w_input(80) value '/home/ftp400/zruntimes2007'.
data: w_output(80) value '/home/ftp400/zruntimes2007_fixed'.
*
data: w_string(195).
*
open dataset w_input for input in text mode encoding default.
open dataset w_output for output in text mode encoding default.
*
do.
read dataset w_input into w_string .
if sy-subrc <> 0.
exit.
endif.
*
if w_string+175(10) = space.
Old Format, convert
w_amount_p = w_string+150(8).
detlrec_uc-respti_uc = w_amount_p.
translate detlrec_uc-respti_uc using ', '.
condense detlrec_uc-respti_uc no-gaps.
shift detlrec_uc-respti_uc right deleting trailing space.
translate detlrec_uc-respti_uc using ' 0'.
*
transfer detlrec_uc to w_output.
*
else.
New format, output as is
detlrec_uc = w_string.
transfer detlrec_uc to w_output.
*
endif.
*
enddo.
Message was edited by:
Bruce Tjosvold