1

I am using a function module to communicate from ABAP to a device connected on the serial port. It is based on the MSCOMM ActiveX Control and uses the MSCOMM properties to read/write values. Unfortunately, I need to send hex strings to the device because of the communication protocol. I am unable to do that. When I try to send a string of hex values, it is sending the ASCII values of the hex values on the serial port.

For example, I want to send the following hex values on the serial port: 01 24 56. I created an XSTRING in ABAP and has the value 012456, which is ok, but the serial port receives the following hex values: 30 31 32 34 35 36, which are the converted ASCII values for the components of the string sent from ABAP.

I saw that in VisualBasic, for example, to the string can be applied a cast to hex before sending it.

Can anybody tell me if it is possible to send hex strings through the serial port from this function module based on MSCOMM in ABAP without using a third-party software?

Thanks in advance, S.

Eric Brown
  • 13,774
  • 7
  • 30
  • 71
Stefan F.
  • 11
  • 1
  • That's what a "hex string" actually is, ASCII codes that *represent* a binary value. Do distinguish between hex and binary, you need to write the byte values instead of converting to a string. – Hans Passant Jul 04 '14 at 12:46
  • Please add the code you use to fill the XSTRING. – vwegert Jul 04 '14 at 13:17
  • @HansPassant you are right, but still I don't know how I can do that directly from ABAP – Stefan F. Jul 07 '14 at 06:11
  • @vwegert I am simply declaring a variable of XSTRING type and fill it with a value. Example: DATA: lv_var TYPE XSTRING. lv_var = '01243E4D3F'. Then, this value gets sent by using the output property of the MSCOMM control. – Stefan F. Jul 07 '14 at 06:15
  • And how do you send the XSTRING? What is the signature of the method involved? – vwegert Jul 07 '14 at 11:43
  • I send it by using the following line: SET PROPERTY OF o_obj 'Output' = lv_var, where o_obj is the MSCOMM object. This is basically the same thing as this line in VB: MSComm1.Output = Buffer – Stefan F. Jul 07 '14 at 13:02
  • It worked by converting the XSTRING TO STRING using the CL_ABAP_CONV_IN_CE and then sending the string, but apparently only on ECC 6.0 systems. – Stefan F. Jul 10 '14 at 06:35

1 Answers1

0

If I understood you well, you may use STRING = XSTRING assignment and then transfer this value to your device:

DATA : X_VAR TYPE XSTRING
     , S_VAR TYPE STRING.

XSTRING = ...  " For example 'Z0!'
S_VAR = X_VAR. " S_VAR is now '5A3021'
Nikolai Kim
  • 685
  • 8
  • 22