Chinaunix首页 | 论坛 | 博客
  • 博客访问: 481851
  • 博文数量: 199
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1902
  • 用 户 组: 普通用户
  • 注册时间: 2020-05-14 13:25
个人简介

代码5S

文章分类

全部博文(199)

文章存档

2021年(5)

2020年(194)

我的朋友

分类: 其他平台

2020-10-23 15:58:47

S4

点击(此处)折叠或打开

  1. *&---------------------------------------------------------------------*
  2. *& Report ZDEMO01
  3. *&---------------------------------------------------------------------*
  4. *&
  5. *&---------------------------------------------------------------------*
  6. REPORT zdemo01.

  7. DATA:gv_int1 TYPE i.

  8. gv_int1 = ipow( base = 12 exp = 3 ).

  9. WRITE gv_int1. "1,728



  10. *&---------------------------------------------------------------------*
  11. *& Report ZDEMO02
  12. *&---------------------------------------------------------------------*
  13. *&
  14. *&---------------------------------------------------------------------*
  15. REPORT zdemo01.

  16. DATA gv_string TYPE string.
  17. DATA gv_position TYPE i.

  18. gv_string = |Hello World|.

  19. gv_position = find( val = gv_string
  20.                     sub = |World|
  21.                     occ = 1
  22.                     case = 'X' ).

  23. WRITE gv_position. "6


  24. *&---------------------------------------------------------------------*
  25. *& Report ZDEMO03
  26. *&---------------------------------------------------------------------*
  27. *&
  28. *&---------------------------------------------------------------------*
  29. REPORT zdemo03.



  30. DATA gv_string TYPE string.

  31. gv_string = |Hello World Hello|.

  32. gv_string = replace( val = gv_string
  33.                      sub = |World|
  34.                      occ = 1
  35.                      with = |S/4HANA| ).

  36. WRITE gv_string. "Hello S/4HANA Hello


  37. *&---------------------------------------------------------------------*
  38. *& Report ZDEMO04
  39. *&---------------------------------------------------------------------*
  40. *&
  41. *&---------------------------------------------------------------------*
  42. REPORT zdemo04.

  43. DATA gs_makt TYPE makt.

  44. gs_makt = VALUE #( matnr = '123' maktx = '456' ).

  45. gs_makt = VALUE #( BASE gs_makt matnr = '0' ).

  46. WRITE gs_makt-matnr."matnr = '0' maktx = '456' 没有BASE GS_MAKT的话会清空maktx


  47. *&---------------------------------------------------------------------*
  48. *& report zdemo05
  49. *&---------------------------------------------------------------------*
  50. *&
  51. *&---------------------------------------------------------------------*
  52. REPORT zdemo05.

  53. DATA: gs_makt TYPE makt,
  54.       gt_makt TYPE TABLE OF makt,
  55.       gs_mara TYPE mara.

  56. SELECT SINGLE * INTO gs_mara
  57.   FROM mara.

  58. gs_makt-maktx = 'maktx'.
  59. gs_makt-matnr = 'matnr'.
  60. MOVE-CORRESPONDING gs_mara TO gs_makt.
  61. gs_makt = CORRESPONDING #( BASE ( gs_makt )
  62.                            gs_mara ).


  63. gt_makt = VALUE #( BASE gt_makt ( gs_makt ) ).
  64. gt_makt = VALUE #( BASE gt_makt ( gs_makt ) ).
  65. gt_makt = VALUE #( ( gs_makt ) ( gs_makt ) ( gs_makt ) ).

  66. WRITE gs_makt-maktx.
  67. ***move-corresponding 与 corresponding #( )的区别在于后者会清空gs_makt
  68. ***没有的字段加上base后,则不会清空gs_makt已有的字段

  69. CLEAR gs_makt.

  70. ****需要注意,没有报 CX_SY_ITAB_LINE_NOT_FOUND异常
  71. gs_makt = gt_makt[ maktx = 'maktx' ].

  72. WRITE gs_makt-maktx.

点击(此处)折叠或打开

  1. *&---------------------------------------------------------------------*
  2. *& report zdemo05
  3. *&---------------------------------------------------------------------*
  4. *&
  5. *&---------------------------------------------------------------------*
  6. REPORT zdemo05.


  7. DATA(time) = COND string(
  8.                 WHEN sy-timlo < '120000' THEN
  9.                   | { sy-timlo TIME = ISO } AM |
  10.                 WHEN sy-timlo > '120000' THEN
  11.                   | { CONV t( sy-timlo - 12 * 3600 ) TIME = ISO } PM |
  12.                 WHEN sy-timlo = '120000' THEN |High Noon| ).

  13. DATA(gv_index) = sy-index.

  14. WRITE 'Hello world'.







阅读(1814) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~