‎2006 Jun 29 4:21 PM
We are migrating to a Unicode system. When the unicode flag is switched on I get an error which says that P_1STCHAR must be byte type field.
The SAP unicode help just confirms the error message without giving any suggestions.
IF P_1STCHAR Z HEX_FF is the line with the problem. Z is a relational operator for bit masks. This line is basically saying does P_1STCHAR contain a ZERO at the bit position specified in HEX_FF.
In a non unicode system P_1STCHAR can be a character type field (which it is in this case) but in a unicode system it must be a byte type field.
How can I fix this code?
FORM CHECK_NULL CHANGING P_1STCHAR TYPE C
P_NULLFLAG TYPE C.
* New form...
DATA: HEX_FF(1) TYPE X VALUE 'FF'.
* If every bit position in P_1STCHAR is 0 then we have
* a NULL insert issue. Change the P_1STCHAR to X and
* mark the corresponding P_NULLFLAG with X.
IF P_1STCHAR Z HEX_FF. <<<< THIS IS PROBLEM LINE!!!
WRITE IND-ON TO: P_1STCHAR,
P_NULLFLAG.
ELSE.
CLEAR P_NULLFLAG.
ENDIF.
ENDFORM. " CHECK_NULL
‎2006 Jun 29 4:27 PM
Hi,
Prior to unicode allowed in ABAP.
Have a look at the statement.
Until now, there was a check in these statements to see if field f is character-type, where normally X fields, X strings, and flat structures were also seen as character-type. This is no longer meaningful in a Unicode program because, on the one hand, the types X and XSTRING are no longer regarded as character-type, and, on the other hand, bit-by-bit access to character-type fields or structures is no longer platform-independent. In a Unicode program, field f must therefore be of type X or XSTRING for these operations.
‎2006 Jun 29 4:34 PM
Thanks Manoj, Do you have any suggestions on how I could restructure the code so that it will check for a null entry in P_1STCHAR? So that the code will still have the same functionality as before?
‎2006 Jun 29 4:40 PM
Here is the code calling the null form.
*&---------------------------------------------------------------------*
*& Form APPEND_ZU131
* Routine appends record in HOLDZU131 internal table.
*&---------------------------------------------------------------------*
FORM APPEND_ZU131 USING DATA_1
DATA_2.
* DATA_3
* DATA_4.
* FORM_NAME = 'APPEND_ZU131'.
* INCLUDE ZUINSTRT.
* zu131-rec_number = zu131-rec_number + 1.
* zu131-data_1 = data_1.
* zu131-data_2 = data_2.
ZU131N-REC_NUMBER = ZU131N-REC_NUMBER + 1.
ZU131N-DATA_1 = DATA_1.
ZU131N-DATA_2 = DATA_2.
* ZU131-DATA_3 = DATA_3.
* ZU131-DATA_4 = DATA_4.
* Deal with 1st char.
* If NULL (x'00'), save it and then change it.
PERFORM CHECK_NULL CHANGING:
ZU131N-DATA_1+0(1) ZU131N-FIRSTNULL1,
ZU131N-DATA_2+0(1) ZU131N-FIRSTNULL2.
* HOLDZU131 = ZU131.
* APPEND HOLDZU131.
* append zu131 to holdzu131.
APPEND ZU131N TO HOLDZU131.
* Append does not set SY-SUBRC !
* IF SY-SUBRC NE 0.
* FORM_NAME = 'APPEND_ZU131'.
* INCLUDE ZUINFAIL.
* RAISE INSERT_FAILED.
* ENDIF.
* FORM_NAME = 'APPEND_ZU131'.
* INCLUDE ZUINENDD.
ENDFORM. " APPEND_ZU131
‎2006 Jun 29 5:18 PM
Convert P_1STCHAR to hex and using in If statement might work.
Try this code in Form ..endform.
data: uccp type syhex02,
hex_ff type syhex02 value 'FFFF'.
Get hex of P_1STCHAR
call method cl_abap_conv_out_ce=>uccp
exporting
char = p_1stchar
receiving
uccp = uccp.
if uccp z hex_ff.
write ind-on to: p_1stchar,
p_nullflag.
else.
clear p_nullflag.
endif.
Regards
Sridhar
‎2006 Jun 29 5:51 PM
Thanks, points awarded. Can't actually test it yet though. Thank you.
‎2006 Jun 29 10:04 PM
Small change to my previous post:
Use field symbols to convert char to hex instead of method CL_ABAP_CONV_OUT_CE=>UCCP, because sap may not have a unicode codepoint for every possible bit sequence, use the following code:
data: v_hex(2) type x,
hex_ff type syhex02 value 'FFFF'.
field-symbols: <fs> type any.
assign p_1stchar to <fs> casting type x.
v_hex = <fs>
if v_hex Z hex_ff.
write ind-on to: p_1stchar,
p_nullflag.
else.
clear p_nullflag.
endif.Regards
Sridhar