SAP Function SO_FOLDER_HIERARCHY_READ_API1 - SAPoffice: View folder structure using API1

Parameter Reference Type Length Default Optional Text
LAST_ACCESS_DATE SOFOLHIRI1-LAST_ACCES D 8 '00000000' X Filter for last access date
ROOT_FOLDER_ID SOFOLHIRI1-OBJECT_ID C 17 ID of root folder for folder

Parameter Reference Length Optional Text
FOLDER_HIERARCHY_TABLE SOFOLHIRI1 119 Folder hierarchy table

Exception Text
FOLDER_NOT_EXIST Specified root folder does not exist
OPERATION_NO_AUTHORIZATION No authorization to view hierarchy
PARAMETER_ERROR Invalid combination of parameter values
X_ERROR Internal error or database inconsistency

Functionality
This function module allows a folder hierarchy to be created from theroot folder of the folder area of a specified folder.

Import parameters
ROOT_FOLDER_ID
Object ID of the folder for whose folder area the hierarchy is to becreated. The relevant root folder is determined and the hierarchy setup from there. Group folders of the shared folders for which the activeuser does not have an access authorization are not included in thehierarchy.
LAST_ACCESS_DATE
If the hierarchy is to be determined for the shared folders, this valuecan be used to restrict the folders selected. Only those folders areincluded whose renewed date is not under the specified value. If afolder or its contents are changed, the renewed date is passed up viathe hierarchy to the root folder, the branches involved are insertedcompletely in such cases

Table parameters
FOLDER_HIERARCHY_TABLE
This table contains the selected folders of the hierarchy. The firstentry consists of the root folder of the folders, the following entriesare arranged so that the child folders are always located directlyafter their parent folder.

  • OBJECT_ID

  • Object ID of the folder.
    • PARENT_FOL

    • Object ID of the parent folder.
      • OBJ_NAME

      • Name of folder.
        • OBJ_DESCR

        • Title (short description) of folder.
          • NUM_FOLDER

          • Number of child folders.
            • LAST_ACCES

            • Date folder was created/changed. Contains the latest of the two values.This value is not the same as the renewed date, it is not passedthrough the hierarchy.
              • NUM_UNREAD

              • In the case of shared folders, this field contains the number ofdocuments in this folder not yet read by the active user.
                • DEPTH

                • Hierarchy level of the folder. The root folder of the folders has thelevel 0, the direct child folders the level 1 etc.

                  Exceptions
                  FOLDER_NOT_EXIST
                  The specified folder does not exist. An incorrect ID was probablypassed or the relevant folder deleted.
                  OPERATION_NO_AUTHORIZATION
                  The folder hierarchy could not be determined. This may be because anattempt was made to create a hierarchy for the private folders ofanother user.
                  PARAMETER_ERROR
                  An invalid combination of parameter values was passed to the functionmodule. Folder hierarchies can only be determined for the sharedfolders or the private folders of the active user.
                  X_ERROR
                  An internal error or a database inconsistency occurred.

                  Example
                  Determining and outputting the hierarchy of the shared folders. Onlythose folders are listed in which an object was changed within the lastweek. The function module SO_USER_READ_API1 is used to determine the IDof the root folder of the shared folders.
                  DATA: HIERARCHY LIKE SOFOLHIRI1 OCCURS 10 WITH HEADER LINE.
                  DATA: USER_DATA LIKE SOUDATAI1.
                  DATA: NEW_SINCE LIKE SY_DATUM.
                  CALL FUNCTION 'SO_USER_READ_API1'
                  IMPORTING
                  USER_DATA = USER_DATA
                  EXCEPTIONS
                  OTHERS = 1.
                  IF SY-SUBRC <> 0.
                  WRITE: / 'User data could not be read !'.
                  EXIT.
                  ENDIF.
                  NEW_SINCE = SY-DATUM - 7.
                  CALL FUNCTION 'SO_FOLDER_HIERARCHY_READ_API1'
                  EXPORTING
                  ROOT_FOLDER_ID = USER_DATA-SHAREDFOL
                  LAST_ACCESS_DATE = NEW_SINCE
                  TABLES
                  FOLDER_HIERARCHY_TABLE = HIERARCHY
                  EXCEPTIONS
                  OTHERS = 1.
                  IF SY-SUBRC <> 0.
                  WRITE: / 'Error creating the hierarchy !'.
                  EXIT.
                  ENDIF.
                  LOOP AT HIERARCHY.
                  WRITE: / ' '.
                  DO HIERARCHY-DEPTH TIMES.
                  WRITE: ' '.
                  ENDDO.
                  WRITE: HIERARCHY-OBJ_NAME, HIERARCHY-OBJ_DESCR.
                  ENDLOOP.

                  Further information
                  Information on calling the function module SO_USER_READ_API1 can befound in the documentation of this function module.