‎2010 Feb 25 3:33 PM
Hello
I am tring to create a General Motors GM 1724-A format barcode label in Smartform.
The GM specifications state that the PDF4-417 must contain certain unprintable characters like ASCII 04, ASCII 29 and ASCII 30.
I want to create a sring of data in my Smartform Print Program and pass the entire string to the Smartform through an internal structure.
I have create 3 constants defned as hex (type x) '04', '1D' and '1E', but when I try to CONCACTONATE them into the structure field, the program comple erors out... You cannot CONCACTONATE a hex field.
When I moved those hex fields into a 1 char fields, they contain '0', '1' and '1'.
I cannot find a Function Module which will convert these hex into characters correctly.
Any suggestions would be appreciated.
Thanks
Peter
‎2010 Feb 26 8:11 AM
On unicode systems, you can not mix types x with c/string.
Have a look at this:
types:
char01 type c length 1.
data:
s type string,
hex type x length 4,
char type char01.
FIELD-SYMBOLS:
<pc>.
hex = '0D'.
assign hex to <pc> casting type char01.
char = <pc>.
‎2010 Feb 25 3:45 PM
I do something similar in putting a carriage return character into a file I am outputting.
This gives me no error when I concatenate the hex onto a character varaible.
So I would have thought the way you are trying would work.
data: c_cr type x value '0D'.
data: wa_field(1000).
concatenate wa_field c_cr into wa_field.
‎2010 Feb 25 4:42 PM
Hey, Thanks
I took your code and put it in a program, and when I attempted to activate it, I got the following error mesage:
"C_CR" must must be a character-type data object(data type C, N, D, T or STING).
Any idea?
Peter
‎2010 Feb 26 7:30 AM
Are you on Unicode, we are not, I wonder if this is why you get the error ?
‎2010 Feb 26 8:50 AM
Certainly is an Unicode issue.
I switched on the Unicode checks on the abap attributes, and I get the same error message.
So, Rainer's solution seems to work, or if you are not a Unicode site, you could just switch off the Unicode checks in the program attributes.
‎2010 Feb 26 10:27 AM
Switching off the unicode flag is not a good idea cause you're just postponing the problem. SAP clearly states that maintenance of non-unicode systems will come to an end.
‎2010 Feb 26 8:11 AM
On unicode systems, you can not mix types x with c/string.
Have a look at this:
types:
char01 type c length 1.
data:
s type string,
hex type x length 4,
char type char01.
FIELD-SYMBOLS:
<pc>.
hex = '0D'.
assign hex to <pc> casting type char01.
char = <pc>.
‎2010 Feb 26 8:20 AM
Well you directly have a replacement available in the class CL_ABAP_CHAR_UTILITIES for carriage return (0D). So you could try something like this
class: cl_abap_char_utilities definition load.
data: c_cr(1) type c .
data: wa_field(1000).
c_cr = cl_abap_char_utilities=>cr_lf+0(1).
concatenate wa_field c_cr into wa_field.
Vikranth
‎2010 Feb 26 8:42 AM
The requirement was
The GM specifications state that the PDF4-417 must contain certain unprintable characters like ASCII 04, ASCII 29 and ASCII 30.
How does cl_abap_char_utilities helps in these cases?
‎2010 Feb 26 10:37 AM
Clearly you need to check the unicode flag and allow the system to handle the hex values.
im able to check the conversion from hex to char using this FM
HR_RU_CONVERT_HEX_TO_STRING
allows u to convert hex values to char ..
probably you can concatenat the char in the string .. i hope i have understood ur requirement clearly..
Just check if this solves ur purpose.
Br,
Vijay.
‎2010 Mar 01 4:10 PM
Rainer, Thank You!
The sample code you sent me worked, with one small change....
in your example, I changed :
hex = '0D'.
to
hex = '000D'.
and it worked like a charm.
Thanks, again.
Peter Graham
Cooper Standard Automotive
‎2010 Mar 03 3:46 PM
Hi Peter and Rainer,
I was looking at that thread and wondered why Peter had to add a leading 00. It must be because of his SAP system endianness (Peter has a big endian system, while Rainer has a little endian system).
So probably the best solution would be to use the following code which takes care of the endianness:
DATA char TYPE c LENGTH 1.
char = cl_abap_conv_in_ce=>uccp( '000D' ).
Sandra