*&---------------------------------------------------------------------*
*& Include ZVERSN_LEVEL
*&---------------------------------------------------------------------*
************************************************************************
* Restriction: No restriction
************************************************************************
"The order of execution
* Do the enqueue
* PERFORM ENQUEUE.
* Load the structure from DB
* PERFORM LOAD_VERSN USING VERSN.
* Create the node table for the function module displaying the tree
* PERFORM CREATE_NODE_TAB TABLES NODE_TAB.
*Result is in NODE_TAB
*Reference FM: 1 、FI_IMPORT_BALANCE_SHEET_TEXT
* 2、 FI_IMPORT_BALANCE_SHEET_POS
************************************************************************
"全局程序字段 RFGSBSTR 的结构
TABLES RFGBST.
*Type define
TYPES:
T_BS_TYPE TYPE I,
BEGIN OF T_BS_INFO,
* info about BS given out to clients
KTOPL LIKE T011-KTOPL,
XAUTO LIKE T011-XAUTO,
TYPE TYPE T_BS_TYPE,
END OF T_BS_INFO,
FIBS_BS_NODE_TYPE TYPE C,
FIBS_POS_ID TYPE I,
FIBS_ACCT_ID TYPE I,
BEGIN OF FIBS_GLAC_ID,
KTOPL LIKE SKA1-KTOPL,
SAKNR LIKE SKA1-SAKNR,
END OF FIBS_GLAC_ID,
FIBS_FAINT_ID TYPE I,
FIBS_FAREA_ID LIKE TFKB-FKBER,
BEGIN OF FIBS_BS_NODE_ID,
TYPE TYPE FIBS_BS_NODE_TYPE,
POS_ID TYPE FIBS_POS_ID,
ACCT_ID TYPE FIBS_ACCT_ID,
GLAC_ID TYPE FIBS_GLAC_ID,
FAINT_ID TYPE FIBS_FAINT_ID,
FAREA_ID TYPE FIBS_FAREA_ID,
END OF FIBS_BS_NODE_ID,
T_NODE LIKE SNODETEXT,
T_BS_NODE_ID TYPE FIBS_BS_NODE_ID,
T_NODE_TAB TYPE T_NODE OCCURS 900,
T_BS_NODE_TAB TYPE T_BS_NODE_ID OCCURS 50,
*Char 1 character
T_FLAG TYPE C.
DATA :
*Financial statements version
VERSN TYPE RFGBST-VERSN .
DATA:
BS_INFO TYPE T_BS_INFO.
DATA:
*Level main table
NODE_TAB TYPE T_NODE_TAB WITH HEADER LINE.
DATA :
GV_LINE TYPE I.
*Constants define
CONSTANTS:
TRUE TYPE T_FLAG VALUE 'X',
FALSE TYPE T_FLAG VALUE ' '.
*&---------------------------------------------------------------------*
*& Form LOAD_VERSN
*&---------------------------------------------------------------------*
* FI - 会计报表版本
*----------------------------------------------------------------------*
* -->VALUE(VERSN) text
*----------------------------------------------------------------------*
FORM LOAD_VERSN
USING VALUE(VERSN) TYPE VERSN_011.
* Load the version
CALL FUNCTION 'FAGL_FI_BS_LOAD'
EXPORTING
VERSION = VERSN
IMPORTING
BS_INFO = BS_INFO.
IF BS_INFO-XAUTO = TRUE.
RFGBST-KEY_ON = FALSE.
ELSE.
RFGBST-KEY_ON = TRUE.
ENDIF.
* Load the texts : 要是没加的话之前的节点Text就不会找到!
PERFORM LOAD_VERSN_TEXT.
ENDFORM. "LOAD_VERSN
*&---------------------------------------------------------------------*
*& Form LOAD_VERSN_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM LOAD_VERSN_TEXT.
DATA:
FLG_LANGU_MAINT TYPE T_FLAG VALUE FALSE,
FLG_SYLANGU_NOT_FOUND TYPE T_FLAG,
MAINT_LANGU LIKE SY-LANGU.
CALL FUNCTION 'FAGL_FI_BS_LOAD_LANGU'
EXPORTING
FLG_LANGU_MAINT = FLG_LANGU_MAINT
IMPORTING
FLG_SYLANGU_NOT_FOUND = FLG_SYLANGU_NOT_FOUND
MAINT_LANGU = MAINT_LANGU
EXCEPTIONS
OTHERS = 1.
ENDFORM. " LOAD_VERSN_TEXT
*&---------------------------------------------------------------------*
*& Form CREATE_NODE_TAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->NODE_TAB text
*----------------------------------------------------------------------*
FORM CREATE_NODE_TAB
TABLES NODE_TAB TYPE T_NODE_TAB.
REFRESH NODE_TAB.
DATA:
ROOT_ID TYPE T_BS_NODE_ID.
* Get the root
CALL FUNCTION 'FI_BS_GET_ROOT'
IMPORTING
ROOT_ID = ROOT_ID
EXCEPTIONS
NOT_FOUND = 01.
* Recursively add nodes
PERFORM ADD_NODE_WITH_SUBTREE
TABLES NODE_TAB
USING 1
ROOT_ID.
ENDFORM. " CREATE_NODE_TAB
*&---------------------------------------------------------------------*
*& Form ADD_NODE_WITH_SUBTREE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->NODE_TAB text
* -->VALUE(LEVEL) text
* -->VALUE(NODE_ID) text
*----------------------------------------------------------------------*
FORM ADD_NODE_WITH_SUBTREE
TABLES NODE_TAB TYPE T_NODE_TAB
USING VALUE(LEVEL) TYPE I
VALUE(NODE_ID) TYPE T_BS_NODE_ID.
DATA:
CHILDREN_NODE_TAB TYPE T_BS_NODE_TAB WITH HEADER LINE.
RFGBST-GLAC_ON = 'X'.
* Get the display info
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(NODE_ID) TYPE FIBS_BS_NODE_ID
*" VALUE(WITH_GL_ACCOUNTS) TYPE FIBS_FLAG DEFAULT FALSE
*" EXPORTING
*" VALUE(ATTR) LIKE SNODETEXT STRUCTURE SNODETEXT
*" EXCEPTIONS
*" NODE_NOT_FOUND
CALL FUNCTION 'FI_BS_NODE_GET_SNODETEXT'
EXPORTING
NODE_ID = NODE_ID
WITH_GL_ACCOUNTS = RFGBST-GLAC_ON
IMPORTING
ATTR = NODE_TAB
EXCEPTIONS
NODE_NOT_FOUND = 01.
NODE_TAB-TLEVEL = LEVEL.
APPEND NODE_TAB.
* And do the same for its children
LEVEL = LEVEL + 1.
CALL FUNCTION 'FI_BS_NODE_GET_CHILDREN'
EXPORTING
NODE = NODE_ID
WITH_GL_ACCOUNTS = RFGBST-GLAC_ON
TABLES
CHILDREN_NODE_TAB = CHILDREN_NODE_TAB
EXCEPTIONS
NODE_NOT_FOUND = 01.
LOOP AT CHILDREN_NODE_TAB.
PERFORM ADD_NODE_WITH_SUBTREE
TABLES NODE_TAB
USING LEVEL
CHILDREN_NODE_TAB.
ENDLOOP.
ENDFORM. " ADD_NODE_WITH_SUBTREE
*&---------------------------------------------------------------------*
*& Form ENQUEUE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM ENQUEUE.
* Perform ENQUEUE if necessary
CALL FUNCTION 'FI_BS_ENQUEUE'
EXPORTING
VERSN = VERSN
EXCEPTIONS
FOREIGN_LOCK = 01
SYSTEM_FAILURE = 02.
ENDFORM. " ENQUEUE