jueves, 24 de julio de 2008

ABAP. Instruciones de control

IF

La comparación de variables constantes y literales es:


Comparaciones comunes y formas alternativas

Comparison
Alternate
Forms
True When
v1 = v2 EQv1 equals v2
v1 <> v2 NE, ><v1 does not equal v2
v1 > v2 GTv1 is greater than v2
v1 < v2 LTv1 is less than v2
v1 >= v2 GE, =>v1 is greater than or equal to v2
v1 <= v2 LE, =<v1 is less than or equal to v2
v1 between v2 and v3
v1 lies between v2 and v3 (inclusive)
not v1 between v2 and v3
v1 lies outside of the range v2 to v3 (inclusive)



Durante las comparaciones entre variables, puede haber conversiones.
Para eso se usa el ANALISIS DE PROGRAMA.
Conversion de Literales
Description
Data Type
Numbers one to nine digits long
i
Numbers 10 or more digits long
p
All others
c

Conversiones de variables en la comparación.
  • If one field is type f, the other is converted to type f.
  • If one field is type p, the other is converted to type p.
  • If one field is type i, the other is converted to type i.
  • If one field is type d, the other is converted to type d. Types c and n, however, are not converted. They are compared directly.
  • If one field is type t, the other is converted to type t. Types c and n, however, are not converted. They are compared directly.
  • If one field is type n, both are converted to type p (at this point, the other field can only be type c or x).
  • At this point, one field will be type c and the other will be type x. x is converted to type c.

Conversions follow the same rules as those performed by the move statement. Type conversions are fully detailed in the ABAP/4 keyword documentation under the heading "Relational Operators for All Data Types."


COMPARACIÓN DE STRINGS DE CARACTERES
Table 10.3 Special Operators for Character Strings


Operator


Means


True When

Case
Sensitive?
Trailing
Blanks
Ignored?
v1 CO v2 Contains Onlyv1 is composed solely of characters in v2
Yes
No
v1 CN v2 not v1 CO v2 v1 contains characters that are not in v2
Yes
No
v1 CA v2 Contains Anyv1 contains at least one character in v2
Yes
No
v1 NA v2 not v1 CA v2 v1 does not contain any character in v2
Yes
No
v1 CS v2 Contains Stringv1 contains the character string v2
No
Yes
v1 NS v2 not v1 CS v2 v1 does not contain the character string v2
No
Yes
v1 CP v2 Contains Patternv1 contains the pattern in v2
No
Yes
v1 NP v2 not v1 CP v2 v1 does not contain the pattern in v2
No
Yes

These operators can be used in any comparison expression. The CS, NS, CP, and NP operators ignore trailing blanks and are not case sensitive.

Esto es válido para variables, literales y strings.

Contains Pattern: Se pueden usar las siguientes pattern:

Table 10.4 CP and NP Operators
Character
Used to
*
Match any sequence of characters.
+
Match any single character.
#
Interpret the next character literally.


sy-fdpos. Es una variable del sistema que se puede usar para comparaciones.



Sentencia Case.

La sintaxis de la sentencia case es la siguiente:

case v1.
when v2 [ or vn ... ].
---
when v3 [ or vn ... ].
---
[ when others.
--- ]
endcase.






xxxxx

2 comentarios:

Sara Jones21 dijo...

Thanks so much for the resource. am a fresher in sap and this was very helpful SAP ABAP Online Training

yektek training dijo...

nice post thanks for sharing from Swathi