MUNDOSAP

MUNDOSAP (foro/index.php)
-   Programación ABAP IV (foro/forumdisplay.php?f=4)
-   -   Cómo convertir un INTEGER a CHAR? (foro/showthread.php?t=5822)

lhidalgo 06/06/07 13:37:16

Cómo convertir un INTEGER a CHAR?
 
hola necesitaria convertir un numero entero a su correspondiente caracter ascii.

ej : tengo una variable entera con el 45 y lo quiero convertir a su correspondiente valor Acii que es '-' ( guion del medio )

probe con este codigo pero me tira un error al compilar .

"The length of "X" in bytes must be a multiple of the size of a Unicode "

data : i type i value 45.
data : x type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c.

ana_24 06/06/07 13:49:36

Hola!!

una vez encontre esto por la red y me lo guarde por si alguna vez lo necesitaba. La verdad que no lo he probado,pero por si te sirve de ayuda


FUNCTION Z_CHARACTER_TO_ASCII_CODE.
*"----------------------------------------------------------------------
*"*"Interfase local
*" IMPORTING
*" REFERENCE(FI_CHARACTER) TYPE C
*" EXPORTING
*" REFERENCE(FE_ASCII_CODE_DEC) TYPE I
*" REFERENCE(FE_ASCII_CODE_HEX) TYPE C
*"----------------------------------------------------------------------
field-symbols <FS> type x.
*Have to use CASTING here to purposely force SAP to convert the
*character to an equivalent HEX value (using ASCII chart).
*Note that CASTING feature is not available prior release 4.6
assign fi_character(1) to <FS> casting.
*The type of the destination field will cause SAP to determine which
*type (Decimal/Hexadecimal) of ASCII code should be converted:
* X -> I gives Dec value
* X -> C gives Hex value
fe_ascii_code_dec = <FS>.
fe_ascii_code_hex = <FS>.


ENDFUNCTION.

lhidalgo 07/06/07 18:06:31

Gracias Ana .... modifique esta linea data : x(16) type x. y me funciono


REPORT ztest_alg .

DATA : varbartextin(18) TYPE c,
largo TYPE i.

varbartextin = '34' .

*saca espacios en blanco
*SHIFT varbartextin LEFT DELETING LEADING space .

largo = varbartextin+0(2) .

largo = largo + 33 .

data: c(16) type c.

data : i type i .

i = largo.
data : x(16) type x.
field-symbols : <fc> type c.
move i to x.
assign x to <fc> casting type c.
move <fc> to c.
write c+15(1).

BREAK-POINT.

mcartamil 11/06/07 12:17:59

Para de chamuyar luissssssssssssssssss!!!!

titanium 22/10/09 16:48:53

no funciona
 
eso os funciona verdaderamente??? lo estoy probando y no funciona...

Neo_25 23/10/09 09:30:24

Sí funciona:




Saludos

Ariel-StaFe 06/09/10 19:23:47

Convertir CHAR a ASCII en ECC 60 ?
 
Estimados:
Yo tenía una función Z tal cual comentaron en este "Tema", y funcionaba perfecto en Version 4.7
Migramos a ECC 60 y dejó de funcionar.
Por ejemplo la letra "A" que tiene el valor decimal '65', con esta nueva versión la misma función me devuelve el valor decimal '16.640'
Alguien tiene el mismo problema ?,
Tiene algo que ver "UNICODE" ?..
o "CODEPAGE" ?
ya que tuve otro tipos de problemas tambien similares, cosas que antes funcionaban y ahora no. (con la nueva version)
Ss

Ariel-StaFe 09/09/10 14:00:49

Problema en conv CHAR a ASCII decimal Resuelto
 
Estimados:
Sigo sin entender por que dejó de funcionar, pero por si le sucede a alguien mas, la manera que lo resolví es tomar la conversion en Hexadecimal y luego convertirla de hexa a ascii decimal.
Ss


Husos Horarios son GMT. La hora en este momento es 01:42:11.

www.mundosap.com 2006 - Spain
software crm, crm on demand, software call center, crm act, crm solutions, crm gratis, crm web