Document Builder: how is LCL_ELEMENT_COUNTER initialized

148 阅读1分钟

Created by Jerry Wang, last modified on Oct 17, 2014

report ZJERRY_GET_DOC_CONTENT in BTD/003:
PARAMETERS: content  TYPE /ipro/tdocmnt-content DEFAULT 'ZCR_KT' OBLIGATORY,
                      document TYPE /ipro/tdocmnt-docmnt_id OBLIGATORY.
DATA:   lt_contents      TYPE /ipro/tt_contents,
        lo_content       TYPE REF TO /ipro/if_content,
        lo_doc_factory   TYPE REF TO /ipro/if_docb_factory,
        lo_document      TYPE REF TO /ipro/if_document,
        lv_content       TYPE string,
        lo_exception     TYPE REF TO cx_root,
        lv_error_text    TYPE string.
lv_content = content.
CALL FUNCTION '/IPRO/CONTENT_FACTORY'
  EXPORTING
    piv_name     = lv_content
  IMPORTING
    pet_contents = lt_contents.
READ TABLE lt_contents INTO lo_content INDEX 1.
CHECK lo_content IS BOUND.
lo_doc_factory = lo_content->get_docb_factory( ).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
   EXPORTING
      input = document
   IMPORTING
      output = document.
TRY.
    lo_document ?= lo_doc_factory->open( piv_docmnt_id = document ).
  CATCH cx_root INTO lo_exception.
    lv_error_text = lo_exception->get_text( ).
    WRITE: /,lv_error_text.
    RETURN.
ENDTRY.
DATA: lo_data TYPE REF TO /ipro/if_docb_attribute.
lo_data = lo_document->get_document_data( ).

输入content ID和Document ID:

clipboard1

 

mo_element_counter is filled:

clipboard2

 

with all 8 entries:

clipboard3

 

clipboard4

 

clipboard5

 

clipboard6

 

clipboard7

 

 

Document header information包含下列这些属性:

  

document guid

 

content name

 

creation user name

 

document id

 

document language

 

document description

 

document style

 

...

clipboard8

 

The second step is to read other document information like variable assignment detail from DB table /IPRO/TDOCDATA:

clipboard9

 

please note the structure of /IPRO/TDOCDATA, the document detail information is stored in that table as a xml stream:

clipboard10

 

 

for example, in this part of xml it defines that the variable ZCR_PERSON contains five sub variables:

clipboard11

 

which reflects the hierarchy relationship defined in customizing:

clipboard12

 

besides the variable information there is also another part of xml which contains the element information:

clipboard13

 

The xml is serialized here:

clipboard14

 

clipboard15

 

the internal table is filled here:

clipboard16