XML解析服务

文章目录

      • [1 Introduction](#1 Introduction)
      • [2 Code](#2 Code)

1 Introduction

In the sap there is xml code . We will use the code for it .

2 Code

sql 复制代码
        CALL METHOD LR_PALLET_INFO->LZLJ_1299_SAP_Requirements_PLA
          EXPORTING
            INPUT  = LS_INPUT
          IMPORTING
            OUTPUT = LS_OUTPUT.


        "4.记录返回结果
        LV_SIGN = LS_OUTPUT-SIGN.
        CONDENSE LV_SIGN NO-GAPS.
        LV_MESSAGE = LS_OUTPUT-MESSAGE.
        IF LV_SIGN = 'TRUE'.
          "4.1 ESB返回成功
          "4.1.1解析返回的MESSAGE节点信息
          CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
            EXPORTING
              TEXT   = LV_MESSAGE
            IMPORTING
              BUFFER = LV_XMLDATA
            EXCEPTIONS
              FAILED = 1
              OTHERS = 2.
          IF SY-SUBRC NE 0.
            LV_ERROR = 'X'.
            LV_MSG = '返回MESSAGE节点XML数据格式错误!'.
          ENDIF.

          CHECK LV_ERROR IS INITIAL.
          CALL FUNCTION 'SMUM_XML_PARSE'
            EXPORTING
              XML_INPUT = LV_XMLDATA
            TABLES
              XML_TABLE = LT_XML_INFO
              RETURN    = LT_RET2
            EXCEPTIONS
              OTHERS    = 0.
          LOOP AT LT_RET2 INTO LS_RET2.
            CASE LS_RET2-TYPE.
              WHEN 'E' OR 'A'.
                LV_ERROR = 'X'.
                LV_MSG = '解析返回MESSAGE节点XML数据!'.
                EXIT.
              WHEN OTHERS.
            ENDCASE. .
          ENDLOOP.
          "4.1.2获取MESSAGE节点中解析出来的ITEM节点信息,该节点是SRM返回信息的JSON字符传
          CHECK LV_ERROR IS INITIAL.
          LOOP AT LT_XML_INFO INTO DATA(LS_XML_INFO) WHERE CNAME = 'ITEM'.
            LV_JSON_RES = LV_JSON_RES && LS_XML_INFO-CVALUE.
          ENDLOOP.
          CONDENSE LV_JSON_RES NO-GAPS.
          IF LV_JSON_RES IS INITIAL.
            LV_ERROR = 'X'.
            LV_MSG = '未获取到SRM返回数据!'.
          ENDIF.
          CHECK LV_ERROR IS INITIAL.
          /UI2/CL_JSON=>DESERIALIZE(
                        EXPORTING
                          JSON  = LV_JSON_RES
                          PRETTY_NAME   = /UI2/CL_JSON=>PRETTY_MODE-CAMEL_CASE
                        CHANGING
                          DATA  = LS_OUTPUT  ).

          IF  LS_OUTPUT-SIGN = 'FAILURE'.

             EV_STATUS  =  'E' .
            EV_MESSAGE = '传送数据失败'.

*            MESSAGE '传送数据成功' TYPE 'S' DISPLAY LIKE 'S'.
            ELSE.

             EV_STATUS  =  'S' .
            EV_MESSAGE = '传送数据成功'.
*             MESSAGE '传送数据失败' TYPE 'E' DISPLAY LIKE 'E'.
          ENDIF.
  ENDIF.
  ENDTRY.
相关推荐
山茶花开时。7 天前
[SAP ABAP] 序列化与反序列化
开发语言·sap·abap
左甜甜9 天前
SAP MMPV报错MMPV_DATE_CHECK
sap
SAP女战士11 天前
【ABAP SAP】开发-BUG修补记录_采购申请打印时品名规格品牌为空
运维·数据库·bug·sap·abap开发
Cindy的SAP加油站13 天前
SAP Ariba_Order Fulfillment Status
sap·sap ariba
SAP学习成长之路14 天前
ADBC 查询语法介绍:EXECUTE_QUERY
java·服务器·开发语言·数据库·sap·abap·零售
需己以听的以听16 天前
4.模块化技术之子程序
sap·gui·abap·模块化·改行学it·子程序
syounger16 天前
近四分之一SAP ECC用户对未来规划尚不明朗
sap
SAP学习成长之路21 天前
SAP HANA 上进行 ABAP 开发:简介
开发语言·数据结构·数据库·sap·abap·代码规范
阿达_优阅达24 天前
利用 Xtract Universal,将 SAP 数据高效迁移至 Amazon S3 或 Redshift
数据库·sap·企业数字化转型·theobald sap·redshift
左甜甜25 天前
ABAP OOALV模板
sap·abap·alv