Advertisement
Gireada

ABAP v3

Mar 21st, 2019
913
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 3.82 KB | None | 0 0
  1. *&---------------------------------------------------------------------*
  2. *& Report  Y_LAB6_GRIGORE
  3. *&
  4. *&---------------------------------------------------------------------*
  5. *&
  6. *&
  7. *&---------------------------------------------------------------------*
  8.  
  9. REPORT  Y_LAB6_GRIGORE.
  10.  
  11. DATA int TYPE I.
  12. int = 10.
  13.  
  14. DATA float TYPE F.
  15. float = '1.234'.
  16.  
  17. DATA ari TYPE D.
  18. ari = '20190307'.
  19.  
  20. DATA ora TYPE T.
  21. ora = '103719'.
  22.  
  23. DATA nume TYPE C.
  24. nume = 'GRIGORE'.
  25.  
  26. WRITE: int, / float, / ari ,/ ora ,/ nume.
  27.  
  28.  
  29. *& DATA f TYPE I OCCURS 3.
  30. *& INSERT 1 INTO f INDEX 0.
  31. *& INSERT 2 INTO f INDEX 1.
  32. *& INSERT 3 INTO f INDEX 2.
  33.  
  34.  
  35. DATA n1 TYPE F.
  36. DATA n2 TYPE F.
  37. DATA n3 TYPE F.
  38. DATA n4 TYPE F.
  39.  
  40. n1 = '10.10'.
  41. n2 = '10.20'.
  42. n3 = '10.30'.
  43. n4 = '10.40'.
  44.  
  45. DATA: BEGIN OF struct,
  46.         v1 TYPE I,
  47.         v2 TYPE I,
  48.   END OF struct.
  49.  
  50. struct-v1 = 10.
  51. struct-v2 = 20.
  52.  
  53. WRITE:/ 'Struct v1: ', struct-v1, ' Struct v2: ', struct-v2.  
  54.  
  55. WRITE:/ 'Numarul maxim este: '.
  56. IF n1 > n2 AND n1 > n3 AND n1 > n4.
  57.   WRITE: n1.
  58. ENDIF.    
  59. IF n2 > n1 AND n2 > n3 AND n2 > n4.
  60.   WRITE: n2.
  61. ENDIF.      
  62. IF n3 > n2 AND n3 > n1 AND n3 > n4.
  63.   WRITE: n3.  
  64. ENDIF.    
  65. IF n4 > n1 AND n4 > n2 AND n4 > n3.
  66.   WRITE: n4.
  67. ENDIF.  
  68. WRITE: /.  
  69.  
  70. DATA numar_div TYPE I.
  71. DATA NUMAR_DOI TYPE I.
  72. DATA NUMAR_TREI TYPE I.
  73. DATA NUMAR_CINCI TYPE I.
  74. DATA NUMAR_SAPTE TYPE I.
  75.  
  76. numar_div = 25.
  77.  
  78. NUMAR_DOI = numar_div MOD 2.
  79. NUMAR_TREI = numar_div MOD 3.
  80. NUMAR_CINCI = numar_div MOD 5.
  81. NUMAR_SAPTE = numar_div MOD 7.
  82.  
  83. IF NUMAR_DOI = 0.
  84.   WRITE: numar_div , 'este divizibil cu 2'.
  85. ENDIF.  
  86. IF NUMAR_TREI = 0.
  87.   WRITE: numar_div , 'este divizibil cu 3'.
  88. ENDIF.  
  89. IF NUMAR_CINCI = 0.
  90.   WRITE: numar_div , 'este divizibil cu 5'.
  91. ENDIF.  
  92. IF NUMAR_SAPTE = 0.
  93.   WRITE: numar_div , 'este divizibil cu 7'.
  94. ENDIF.  
  95.  
  96.  
  97. DATA a1 TYPE I.
  98. DATA b1 TYPE I.
  99. DATA c1 TYPE I.
  100. DATA d1 TYPE I.
  101. DATA x1 TYPE I.
  102. DATA delta TYPE I.
  103. DATA delta1 TYPE I.
  104. DATA x11 TYPE I.
  105. DATA x12 TYPE I.
  106. DATA sol TYPE I.
  107.  
  108. a1 = 8.
  109. b1 = 7.
  110. c1 = 1.  
  111.  
  112. IF a1 = 0.
  113.   IF b1 = 0.
  114.     IF c1 = 0.
  115.       WRITE: /'Exista o infinitate de solutii !'.
  116.     ELSE.
  117.       WRITE: /'Ecuatie imposibila!'.
  118.     ENDIF.
  119.   ELSE.
  120.       WRITE:  /'Ecuatie de gr 1 cu o solutie '.  
  121.       x1 = ( - c1 ) / b1.
  122.       WRITE: x1.
  123.   ENDIF.
  124. ELSE.
  125.     delta =  b1 * b1.  
  126.     delta1 = 4 * a1 * c1.
  127.     delta = delta - delta1.
  128.     IF delta < 0.
  129.       WRITE: /'Ecuatia nu are solutii reale !'.
  130.     ELSE.
  131.         IF delta = 0.
  132.           sol = ( - b1 ) / ( 2 * a1 ).
  133.           WRITE: /'Ecuatia are solutii egale '.
  134.           WRITE: 'x1=x2= ',  sol.
  135.         ELSE.
  136.           x11 = ( - b1 + sqrt( delta ) ) / 2 * a1.
  137.           x12 = ( - b1 + sqrt( delta ) ) / 2 * a1.
  138.           WRITE: /'Ecuatia are solutii reale! '.
  139.           WRITE: ' x1 = ', x11.
  140.           WRITE: ' x2 = ', x12.
  141.         ENDIF.
  142.      ENDIF.
  143. ENDIF.        
  144.  
  145.  
  146.  
  147.  
  148. DATA numar_text TYPE I.
  149.  
  150. numar_text = 10.
  151.  
  152. CASE numar_text.
  153.   WHEN 0.
  154.     WRITE: / 'Zero'.
  155.   WHEN 1.
  156.     WRITE: / 'Unu'.
  157.   WHEN 2.
  158.     WRITE: / 'Doi'.
  159.   WHEN 3.
  160.     WRITE: / 'Trei'.
  161.   WHEN 4.
  162.     WRITE: / 'Patru'.
  163.   WHEN 5.
  164.     WRITE: / 'Cinci'.
  165.   WHEN 6.
  166.     WRITE: / 'Sase'.
  167.   WHEN 7.
  168.     WRITE: / 'Sapte'.
  169.   WHEN 8.
  170.     WRITE: / 'Opt'.
  171.   WHEN 9.
  172.     WRITE: / 'Noua'.
  173.   WHEN 10.
  174.     WRITE: / 'Zece'.              
  175. ENDCASE.    
  176.  
  177.  
  178. DATA numar_1 TYPE F.
  179. DATA numar_2 TYPE F.
  180. DATA operator TYPE C.
  181.  
  182. operator = '+'.
  183. numar_1 = '10.20'.
  184. numar_2 = '20.30'.
  185.  
  186. DATA rezultat TYPE F.
  187. rezultat = 0.
  188. CASE operator.
  189.   WHEN '+'.
  190.     rezultat = numar_1 + numar_2.
  191.   WHEN '-'.
  192.     rezultat = numar_1 - numar_2.
  193.   WHEN '*'.
  194.     rezultat = numar_1 * numar_2.
  195.   WHEN '/'.
  196.     rezultat = numar_1 / numar_2.
  197.   WHEN '%'.
  198.     rezultat = numar_1 MOD numar_2.            
  199. ENDCASE.    
  200.  
  201. WRITE: / 'Rezultatul este: ', rezultat.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement