查找包含指定关键字的BDOC
生活随笔
收集整理的這篇文章主要介紹了
查找包含指定关键字的BDOC
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Created by Jerry Wang, last modified on Apr 27, 2015假設需要查找指定時間段內(nèi),包含指定關(guān)鍵字的BDOC列表。 report下方顯示進度條: report source code: REPORT zscan_bdoc_via_keyword.PARAMETERS: start TYPE smw3_bdoc-snd_date OBLIGATORY DEFAULT sy-datlo,end TYPE smw3_bdoc-snd_date OBLIGATORY DEFAULT sy-datlo,keyword TYPE string LOWER CASE OBLIGATORY DEFAULT 'CRMA'.DATA: lv_bdoc_id TYPE smw3_bdoc1-bdoc_id VALUE 'FA163E8EAB031EE496D7B1616132B3D2',lt_header TYPE STANDARD TABLE OF smw3_bdoc,lv_xml TYPE xstring,lv_count TYPE i,lv_string TYPE string.START-OF-SELECTION.PERFORM main.FORM main.SELECT * INTO TABLE lt_header FROM smw3_bdoc WHERE snd_date >= start AND snd_date <= end.IF sy-subrc <> 0.WRITE: / 'No BDOC exists for given time period.'.RETURN.ENDIF.lv_count = lines( lt_header ).LOOP AT lt_header ASSIGNING FIELD-SYMBOL(<header>).PERFORM display_progress USING sy-tabix.PERFORM get_bdoc_ext_via_id USING <header>-bdoc_id CHANGING lv_xml.CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'EXPORTINGim_xstring = lv_xmlIMPORTINGex_string = lv_string.FIND keyword IN lv_string.IF sy-subrc = 0.WRITE: / 'found search keyword in BDOC: ' , <header>-bdoc_id.ENDIF.CLEAR: lv_xml, lv_string.ENDLOOP.ENDFORM.FORM get_bdoc_ext_via_id USING iv_id TYPE smw3_bdoc1-bdoc_id CHANGING cv_xml TYPE any.DATA: wa_smw3_bdoc TYPE smw3_fhd,l_dtyp TYPE smw3_ddic1,bdoc_ext TYPE REF TO data.FIELD-SYMBOLS: <b_ext> TYPE any.CALL METHOD cl_smw_bdocstore=>get_bdocEXPORTINGbdoc_id = iv_idget_bdoc_header = 'X'IMPORTINGbdoc_header = wa_smw3_bdocEXCEPTIONSOTHERS = 4.ASSERT sy-subrc = 0.IF wa_smw3_bdoc-ddic2 IS INITIAL."MESSAGE s006(smw3)." No BDoc extension available (no messaging BDoc).WRITE: / 'Not BDOC extension avaible for BDOC id: ' , lv_bdoc_id.EXIT.ENDIF.* create data refsl_dtyp = wa_smw3_bdoc-ddic2 .CREATE DATA bdoc_ext TYPE (l_dtyp).ASSIGN: bdoc_ext->* TO <b_ext>.CLEAR: <b_ext>.CALL METHOD cl_smw_bdocstore=>get_bdocEXPORTINGbdoc_id = iv_idget_bdoc_header = ' 'get_body_ext = 'X'IMPORTINGbdoc_body_ext = <b_ext>EXCEPTIONSinvalid_bdoc_id = 1inconsistent_body = 2failed = 3OTHERS = 4.CHECK sy-subrc = 0.PERFORM get_xml_source USING <b_ext> CHANGING cv_xml.CLEAR: <b_ext>, bdoc_ext.ENDFORM.FORM display_progress USING iv_percent.DATA: lv_percent type i,lv_text TYPE string.lv_percent = iv_percent * 100 / lv_count.lv_text = 'In process... ' && lv_percent && '%'.CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'EXPORTINGPERCENTAGE = lv_percenttext = lv_text.eNDFORM.FORM get_xml_source USING is_ext TYPE any CHANGING cv_xml TYPE xstring.DATA:* x_xml_tab TYPE swr_t_html,lv_rc TYPE sy-subrc,lref_document TYPE REF TO if_ixml_document,lref_data_as_dom TYPE REF TO if_ixml_element.* Maps a ABAP variable into a DOM structureCALL FUNCTION 'SDIXML_DATA_TO_DOM'EXPORTINGname = 'MESSAGE'dataobject = is_ext* CONTROL =IMPORTINGdata_as_dom = lref_data_as_domCHANGINGdocument = lref_document* TYPE_HANDLE =EXCEPTIONSillegal_name = 1OTHERS = 2.ASSERT sy-subrc = 0.CALL METHOD lref_document->append_childEXPORTINGnew_child = lref_data_as_domRECEIVINGrval = lv_rc.ASSERT sy-subrc = 0.* SDIXML_DOM_TO_XMLCALL FUNCTION 'SDIXML_DOM_TO_XML'EXPORTINGdocument = lref_documentIMPORTINGxml_as_string = cv_xmlEXCEPTIONSOTHERS = 1.ASSERT sy-subrc = 0.ENDFORM. |
總結(jié)
以上是生活随笔為你收集整理的查找包含指定关键字的BDOC的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【STM32H7教程】第39章 S
- 下一篇: 1.零基础如何学习Web安全渗透测试?[