• 查看指定 SAP CRM One Order 的 note 数据


    源代码:

    REPORT znote_browse_tool.
    
    PARAMETERS: id   TYPE crmd_orderadm_h-object_id OBLIGATORY DEFAULT '25949',
                type TYPE crmd_orderadm_h-process_type OBLIGATORY DEFAULT 'CX01'.
    
    TYPES: text_line(cl_crm_odata_oppt_constant=>gc_oppt_notes_textlength)  TYPE c.
    TYPES: BEGIN OF ty_text_detail,
             tdid    TYPE stxh-tdid,
             "tdobject type stxh-tdobject, "CRM_ORDERH
             tdname TYPE stxh-tdname,
             tdspras TYPE stxh-tdspras,
             tdfuser TYPE stxh-tdfuser,
             tdfdate TYPE stxh-tdfdate,
             tdftime TYPE stxh-tdftime,
             tdluser TYPE stxh-tdluser,
             tdldate TYPE stxh-tdldate,
             tdltime TYPE stxh-tdltime,
             tdtext  TYPE ttxit-tdtext,
             content TYPE string,
           END OF ty_text_detail.
    DATA: lv_char32   TYPE char32, " CRMD_ORDERADM_H-guid,
          lv_textname TYPE string,
          lv_id       LIKE id,
          lv_guid     TYPE crmd_orderadm_h-guid,
          lt_stxh     TYPE STANDARD TABLE OF stxh,
          ls_stxh     LIKE LINE OF lt_stxh,
          ls_notes    TYPE crmt_odata_oppt_notes.
    DATA: ls_thead                TYPE thead.
    DATA: lt_text_table           TYPE TABLE OF text_line.
    
    DATA: ls_bupa_addr            TYPE bapiaddr3.
    DATA: ls_return               TYPE STANDARD TABLE OF bapiret2.
    DATA: lt_lines                TYPE STANDARD TABLE OF tline.
    DATA: et_notes TYPE crmt_odata_oppt_notest.
    DATA: ls_text_detail TYPE ty_text_detail,
          lt_text_detail TYPE STANDARD TABLE OF ty_text_detail.
    DATA: lt_text_object TYPE STANDARD TABLE OF ttxit,
          ls_text_object LIKE LINE OF lt_text_object,
          lv_xml         TYPE string.
    
    lv_id = id.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = lv_id
      IMPORTING
        output = lv_id.
    
    SELECT SINGLE guid FROM crmd_orderadm_h INTO lv_guid WHERE object_id = id AND process_type = type.
    IF sy-subrc <> 0.
      WRITE: / 'No opportunity found' COLOR COL_GROUP.
      RETURN.
    ENDIF.
    
    lv_char32 = lv_guid.
    
    CONCATENATE lv_char32 '%' INTO lv_textname.
    
    SELECT * FROM stxh INTO TABLE lt_stxh
                       WHERE  tdobject  EQ   'CRM_ORDERH'
                         AND  tdname    LIKE lv_textname.
    
    SELECT tdid tdtext FROM ttxit INTO CORRESPONDING FIELDS OF TABLE lt_text_object
       WHERE tdspras = sy-langu
         AND tdobject  = cl_crm_odata_oppt_constant=>gc_oppt_notes_tdobject.
    
    LOOP AT lt_stxh INTO ls_stxh.
      ls_notes-header_guid = lv_char32.
      MOVE-CORRESPONDING ls_stxh TO ls_text_detail.
      READ TABLE lt_text_object INTO ls_text_object WITH KEY tdid = ls_stxh-tdid.
      IF sy-subrc = 0.
        ls_text_detail-tdtext = ls_text_object-tdtext.
      ENDIF.
    
      CALL FUNCTION 'BAPI_USER_GET_DETAIL'
        EXPORTING
          username = ls_stxh-tdfuser
        IMPORTING
          address  = ls_bupa_addr
        TABLES
          return   = ls_return.
    
      ls_notes-creator = ls_bupa_addr-fullname.
    
      CONVERT DATE ls_stxh-tdfdate TIME ls_stxh-tdftime INTO TIME STAMP ls_notes-created_at TIME ZONE 'UTC'.
    
      CLEAR lt_lines.
      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          id       = ls_stxh-tdid
          language = ls_stxh-tdspras
          name     = ls_stxh-tdname
          object   = ls_stxh-tdobject
        IMPORTING
          header   = ls_thead
        TABLES
          lines    = lt_lines
        EXCEPTIONS
          OTHERS   = 1.
      CHECK sy-subrc EQ 0.
      CALL FUNCTION 'CONVERT_ITF_TO_STREAM_TEXT'
        TABLES
          itf_text    = lt_lines
          text_stream = lt_text_table.
      CONCATENATE LINES OF lt_text_table INTO ls_notes-content RESPECTING BLANKS.
      ls_text_detail-content = ls_notes-content.
      APPEND ls_text_detail TO lt_text_detail.
    
      CLEAR: ls_notes, ls_stxh, lt_lines, lt_text_table, ls_thead, ls_bupa_addr, ls_text_detail.
    ENDLOOP.
    
    CALL TRANSFORMATION id SOURCE data = lt_text_detail RESULT XML lv_xml.
    CALL METHOD cl_demo_output=>display_xml( lv_xml ).
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112

    使用方法:

    指定任务 id 和任务类型:
    在这里插入图片描述
    输出结果:
    在这里插入图片描述

  • 相关阅读:
    头插法 销毁 清空链表的操作
    Redis Sentinel原理
    leetcode 57. 插入区间
    【FPGA教程案例76】通信案例2——基于FPGA的滑动窗口累加器实现
    wordpress获取登录权限后获取shell的方法
    【数据结构初阶】图文详解10道力扣链表OJ题
    沉睡者IT创业项目 - 学习如何玩直播卖零食
    11.NiO多线程优化
    Vue中的生命周期
    云课五分钟-04一段代码学习-大模型分析C++
  • 原文地址:https://blog.csdn.net/i042416/article/details/126917052