Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reading WebDAV Content from ABAP

Former Member
0 Kudos

Hello,

I like to read WebDAV Content from SAP NetWeaver Portal KM with ABAP.

For writing Content with WebDAV I found this post:

With Method GET_CONTENT from CL_SWDCL_NAMESPACE_CLIENT I can read single files, but what I need is a list with files and folders for a given path.

I also tried to use the Interface IF_SWDCL_BASIC_SEARCH_CLIENT, but I only get HTML-Errorcodes 400 or 422 since I don't know which parameters I need.

Maybe there is someone here who can help me to solve this problem.

Thank you.

3 REPLIES 3

Former Member
0 Kudos

Hello,

I face the same problem, did you already find a solution you can share?

Thanks in advance

Stefan

0 Kudos

Hi Stefan,

sorry, I couldn't find a solution for this

Regards

Marcel

former_member232353
Discoverer
0 Kudos

Hi, after some time of search I found 2 possibilities to list the files of a directory with webDAV.

1. Possibility (based on the small working example you've linked):

DATA: mt_tab TYPE sdavc_tt_resource_data,
           ms_tab TYPE sdavc_ts_resource_data.


prop = lo_client->get_property_client( ).

        prop->get_properties(

          EXPORTING

            i_url                 = '/some_directory'    " URL

            i_depth               = '1'    " Tiefe

          RECEIVING

            rt_resources          = mt_tab    " Daten von WebDAV-Resourcen

        ).

"ms_tab-url is the path of the file/dir, ms_tab-content_type is e.g. httpd/unix-directory

LOOP AT mt_tab INTO ms_tab.

ENDLOOP.


2. Possibility (also based on the example)


          DATA factory TYPE REF To if_SWDCL_RESOURCE_FACTORY.
         DATA resource TYPE REF TO if_SWDCL_RESOURCE.

         factory = cl_SWDCL_RESOURCE_FACTORY=>get_instance( ).

         " read directory
         factory->get_resource(
           EXPORTING
             i_url                 = '/some_directory'
             ip_connection         = lo_connection    " DAV-Connection-Objekt
           RECEIVING
             rp_resource           resource   " WebDAV-Resource
         ).

         DATA: children TYPE SDAVC_TT_RESOURCES,
               ms_directory TYPE SDAVC_TS_RESOURCE,
               mt_files TYPE SDAVC_TT_RESOURCES.
       
        children = resource->get_children( ).

     
        LOOP AT children INTO ms_directory.

          " ms_directory-resource is the child resource

          " ms_directory-url is the name of the resource: e.g. test.xml
          mt_files = ms_directory-resource->get_children( ).

          " if not initial then ms_directory is a directory with another files
         IF NOT mt_files IS INITIAL.
           LOOP AT mt_files.

           ENDLOOP.
         ENDIF.

        ENDLOOP.



This should help.