Application Development and Automation 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: 
Read only

TMP_GUI_DIRECTORY_LIST_FILES

Former Member
0 Likes
3,348

Hi Gurus,

I am using FM TMP_GUI_DIRECTORY_LIST_FILES to list files in a folder. This FM is working fine in my PC but when we try it in the user's PC it not working nor throwing any exceptions. Please throw light in this issue.

Regards

Anil Malhotra

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,220

Dear All,

Thanks you all for your valuable comments. The problem has been solved by re-installing the SAP GUI.

Regards

Anil Malhotra

Hi Gurus,

I am using FM TMP_GUI_DIRECTORY_LIST_FILES to list files in a folder. This FM is working fine in my PC but when we try it in the user's PC it not working nor throwing any exceptions. Please throw light in this issue.

Regards

Anil Malhotra

9 REPLIES 9
Read only

Former Member
0 Likes
2,220

Hi Anil

it's missing user authorisations from sap or client(microsoft i suppose) perspective

Let me know if you need on how to proceed

a

Read only

0 Likes
2,220

Hi Andrea,

I think so its not authorization issue in SAP because in both the systems I used my login. If it is client issue(Microsoft) then what I need to check. The user is using Win 7.

Regards

Anil Malhotra

Message was edited by: Anil Malhotra

Read only

0 Likes
2,220

Hi Anil

right! so, to make it easy, ask to your support team (in case you can't by yourself) to give admin rights on that computer for microsoft user you are using

Meanwhile it would be useful if you can login to erp op system and try to map the c drive of the client (there could be some network port locked ...)

Let me know if u need me

a

Read only

gouravkumar64
Active Contributor
0 Likes
2,220

Hi,

I am not sure about this issue,but You can check this sap notes

Note 1583869 - Template report for copying the location environment

also You can check this wiki help

http://wiki.sdn.sap.com/wiki/display/Snippets/Working+With+Files

Thanks

Gourav.

Read only

anilkumar_kalkivai
Active Participant
0 Likes
2,220

Hi Anil,

The alternative for above FM is:

CL_GUI_FRONTEND_SERVICES->DIRECTORY_LIST_FILES.

Example for using it.

DATA: wa_pfile TYPE file_table.

DATA: it_pfiles TYPE STANDARD TABLE OF file_table,

      count   TYPE i,

      dir     TYPE string VALUE 'C:\temp\'.

CALL METHOD cl_gui_frontend_services=>directory_list_files

   EXPORTING

     directory                   = dir

     files_only                  = 'X'

   CHANGING

     file_table                  = it_pfiles

     count                       = count

   EXCEPTIONS

     cntl_error                  = 1

     directory_list_files_failed = 2

     wrong_parameter             = 3

     error_no_gui                = 4

     not_supported_by_gui        = 5

     OTHERS                      = 6.

LOOP AT it_pfiles INTO wa_pfile.

   WRITE wa_pfile.

ENDLOOP.

Regards,

Anil.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,220

Hi Anil

Check the Directory Path you are passing?

Is that path exists in the use desktop?  Is it accessible ?

If you are using any shared directlry  then is it accessible ?

Regards,

Venkat

Read only

former_member209120
Active Contributor
0 Likes
2,220

HI Anil,

CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
          EXPORTING
            directory        = 'D
:\ramesh'  " giving path like this is not correct - this path may not be with your user
*          FILTER           = '*.*'
*        IMPORTING
*          FILE_COUNT       =
*          DIR_COUNT        =
          tables
            file_table       = filetable
            dir_table        = dirtable
*        EXCEPTIONS
*          CNTL_ERROR       = 1
*          OTHERS           = 2
                  .
        IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

Try like this


DATA:  ini_path    TYPE string,
        sel_path    TYPE string,
        filetable   like SDOKPATH OCCURS 0 WITH HEADER LINE,
        dirtable   like SDOKPATH OCCURS 0 WITH HEADER LINE.

SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 .

PARAMETER: p_path TYPE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN : END OF BLOCK b1.


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.

CALL METHOD cl_gui_frontend_services=>directory_browse
     EXPORTING
       initial_folder  = ini_path
     CHANGING
       selected_folder = sel_path
     EXCEPTIONS
       cntl_error      = 1
       error_no_gui    = 2
       OTHERS          = 3.
   IF sy-subrc = 0.
     CALL METHOD cl_gui_cfw=>flush( ).
     IF sel_path IS NOT INITIAL.
       p_path = ini_path = sel_path.
     ENDIF.
   ENDIF.

START-OF-SELECTION.

       CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
          EXPORTING
            directory        = p_path
*          FILTER           = '*.*'
*        IMPORTING
*          FILE_COUNT       =
*          DIR_COUNT        =
          tables
            file_table       = filetable
            dir_table        = dirtable
*        EXCEPTIONS
*          CNTL_ERROR       = 1
*          OTHERS           = 2
                  .
        IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

  Loop at filetable.
    write : / filetable-pathname.
  endloop.

  loop at dirtable.
  write: / dirtable-pathname.
  endloop.

Regards,

Ramesh.T

Read only

venkateswaran_k
Active Contributor
0 Likes
2,220

Hi Anil,

Step 1.

Try use function -     CALL    FUNCTION 'EPS_GET_DIRECTORY_LISTING'

Else Step 2

As I already posted, the issue is with the PATH.

As long as you are testing by giving the C:\temp\  from your system.

In order to make it avaialbe,  it is always recommended that you should use the Shared File system..

I have similar requiremetn to read the XML files from the Shared folder whenever user executes a tcode.

So what I did is as follows :

Define the parameter - default it to a value with Shared directory.

PARAMETERS:  p_filnam TYPE localfile    DEFAULT '\\XXXXXXX\FILESERVER\SAP\Default.xml'.

In your case instead of C:\Temp\  -  use teh shared file fodler...

Regards,

Venkat

Read only

Former Member
0 Likes
2,221

Dear All,

Thanks you all for your valuable comments. The problem has been solved by re-installing the SAP GUI.

Regards

Anil Malhotra