Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

binary mode

Former Member
0 Likes
639

Hi,

can somebody give an example how to use:

- FIND in byte mode

- REPLACE in byte mode

- variable+0(length) in byte mode

- save xstring table with open dataset in byte mode for output.

thanks,

martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
505

Hi ,

For Variable+0(length ) check out the following example .

----


  • MOVE: structure <-> structure (Offset)

----


report ZCH_UNIEXP_3.

  • Before Unicode enabling:

  • data: begin of STRUC1,

  • F0 type x,

  • F1(10) type c,

  • F2(20) type c,

  • F3 type i,

  • F4 type p,

  • end of STRUC1,

  • begin of STRUC2,

  • C0 type i,

  • C1(10) type c,

  • C2(20) type c,

  • C3 type x,

  • C4 type f,

  • end of STRUC2.

  • STRUC11(30) = STRUC24(30). <---- Unicode error !!

  • After Unicode enabling:

types: begin of PART1,

F1(10) type c,

F2(20) type c,

end of PART1,

begin of PART 2,

C1(10) type c,

C2(20) type c,

end of PART 2.

data: begin of STRUC1,

F0 type x.

include type PART1 as PART.

data: f3 type i,

f4 type p,

end of STRUC1,

begin of STRUC2,

C0 type i.

include type PART2 as PART.

data: C3 type x,

C4 type f,

end of STRUC2.

STRUC1-PART = STRUC2-PART.

For open dataset use this following example.

----


  • OPEN DATASET

----


report ZCH_UNIEXP_11.

data: begin of STRUC,

F1 type c,

F2 type p,

end of STRUC,

DSN(30) type c value 'TEMPFILE'.

STRUC-F1 = 'X'.

STRUC-F2 = 42.

  • Before Unicode enabling:

  • Write to file

  • open dataset DSN in text mode. <---- Unicode error

  • transfer STRUC to DSN.

  • close dataset DSN.

  • Read from file

  • clear STRUC.

  • open dataset DSN in text mode. <---- Unicode error

  • read dataset DSN into STRUC.

  • close dataset DSN.

  • write: / STRUC-F1, STRUC-F2.

  • After Unicode enabling

  • a) You don't need to read old non Unicode files

  • and may change the layout

data: begin of STRUC2,

F1 type c,

F2(20) type c,

end of STRUC2.

move-corresponding STRUC to STRUC2.

  • write to file

open dataset DSN in text mode for output encoding utf-8.

transfer STRUC2 to DSN.

close dataset DSN.

  • read from file

clear STRUC.

open dataset DSN in text mode for input encoding utf-8.

read dataset DSN into STRUC2.

close dataset DSN.

move-corresponding STRUC2 to STRUC.

write: / STRUC-F1, STRUC-F2.

  • b) Now you need to read old non Unicode files

  • but must not change the layout

  • write to file

open dataset DSN in legacy text mode for output.

transfer STRUC to DSN.

close dataset DSN.

  • read from file

clear STRUC.

open dataset DSN in legacy text mode for input.

read dataset DSN into STRUC.

close dataset DSN.

write: / STRUC-F1, STRUC-F2.

For Find and search use the following example.

FIND ... IN BYTE MODE

REPLACE ... IN BYTE MODE

REPLACE f WITH g INTO h IN BYTE MODE

PLease reward if useful.

1 REPLY 1
Read only

Former Member
0 Likes
506

Hi ,

For Variable+0(length ) check out the following example .

----


  • MOVE: structure <-> structure (Offset)

----


report ZCH_UNIEXP_3.

  • Before Unicode enabling:

  • data: begin of STRUC1,

  • F0 type x,

  • F1(10) type c,

  • F2(20) type c,

  • F3 type i,

  • F4 type p,

  • end of STRUC1,

  • begin of STRUC2,

  • C0 type i,

  • C1(10) type c,

  • C2(20) type c,

  • C3 type x,

  • C4 type f,

  • end of STRUC2.

  • STRUC11(30) = STRUC24(30). <---- Unicode error !!

  • After Unicode enabling:

types: begin of PART1,

F1(10) type c,

F2(20) type c,

end of PART1,

begin of PART 2,

C1(10) type c,

C2(20) type c,

end of PART 2.

data: begin of STRUC1,

F0 type x.

include type PART1 as PART.

data: f3 type i,

f4 type p,

end of STRUC1,

begin of STRUC2,

C0 type i.

include type PART2 as PART.

data: C3 type x,

C4 type f,

end of STRUC2.

STRUC1-PART = STRUC2-PART.

For open dataset use this following example.

----


  • OPEN DATASET

----


report ZCH_UNIEXP_11.

data: begin of STRUC,

F1 type c,

F2 type p,

end of STRUC,

DSN(30) type c value 'TEMPFILE'.

STRUC-F1 = 'X'.

STRUC-F2 = 42.

  • Before Unicode enabling:

  • Write to file

  • open dataset DSN in text mode. <---- Unicode error

  • transfer STRUC to DSN.

  • close dataset DSN.

  • Read from file

  • clear STRUC.

  • open dataset DSN in text mode. <---- Unicode error

  • read dataset DSN into STRUC.

  • close dataset DSN.

  • write: / STRUC-F1, STRUC-F2.

  • After Unicode enabling

  • a) You don't need to read old non Unicode files

  • and may change the layout

data: begin of STRUC2,

F1 type c,

F2(20) type c,

end of STRUC2.

move-corresponding STRUC to STRUC2.

  • write to file

open dataset DSN in text mode for output encoding utf-8.

transfer STRUC2 to DSN.

close dataset DSN.

  • read from file

clear STRUC.

open dataset DSN in text mode for input encoding utf-8.

read dataset DSN into STRUC2.

close dataset DSN.

move-corresponding STRUC2 to STRUC.

write: / STRUC-F1, STRUC-F2.

  • b) Now you need to read old non Unicode files

  • but must not change the layout

  • write to file

open dataset DSN in legacy text mode for output.

transfer STRUC to DSN.

close dataset DSN.

  • read from file

clear STRUC.

open dataset DSN in legacy text mode for input.

read dataset DSN into STRUC.

close dataset DSN.

write: / STRUC-F1, STRUC-F2.

For Find and search use the following example.

FIND ... IN BYTE MODE

REPLACE ... IN BYTE MODE

REPLACE f WITH g INTO h IN BYTE MODE

PLease reward if useful.