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

Replacement for ws_query

Former Member
0 Likes
1,525

Hi,

We are using WS_QUERY FM to get the length of file name.

CALL FUNCTION 'WS_QUERY'

EXPORTING

filename = l_filename

query = 'FL'

IMPORTING

return = return

This FM is obslete in ECC 6.0. So is there any FM or method which provides the same functionality.

Thanks & Regards,

Sri ramya g.

1 ACCEPTED SOLUTION
Read only

former_member206377
Active Contributor
0 Likes
1,479

Hi Ramya,

Query 'FL' is for getting the file size and below is the replacement for ws_query in case of query 'FL'.


data: l_filename1 type string,
      rc type i.
move l_filename to l_filename1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_GET_SIZE
  EXPORTING
    FILE_NAME            = l_filename1
  IMPORTING
    FILE_SIZE            = rc
  EXCEPTIONS
    FILE_GET_SIZE_FAILED = 1
    CNTL_ERROR           = 2
    ERROR_NO_GUI         = 3
    NOT_SUPPORTED_BY_GUI = 4
    others               = 5
        .
CALL METHOD CL_GUI_CFW=>FLUSH.

IF SY-SUBRC = 0.
  move rc to return.
ENDIF.

14 REPLIES 14
Read only

former_member585060
Active Contributor
0 Likes
1,479

Hi,

Try GUI_GET_FILE_INFO

Regards

Bala Krishna

Read only

Former Member
0 Likes
1,479

Hi Ramya,

Use methods of class CL_GUI_FRONTEND_SERVICES like FILE_GET_ATTRIBUTES

Regards

Abhii

Edited by: Abhii on Jan 27, 2010 11:07 AM

Read only

former_member206377
Active Contributor
0 Likes
1,480

Hi Ramya,

Query 'FL' is for getting the file size and below is the replacement for ws_query in case of query 'FL'.


data: l_filename1 type string,
      rc type i.
move l_filename to l_filename1.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_GET_SIZE
  EXPORTING
    FILE_NAME            = l_filename1
  IMPORTING
    FILE_SIZE            = rc
  EXCEPTIONS
    FILE_GET_SIZE_FAILED = 1
    CNTL_ERROR           = 2
    ERROR_NO_GUI         = 3
    NOT_SUPPORTED_BY_GUI = 4
    others               = 5
        .
CALL METHOD CL_GUI_CFW=>FLUSH.

IF SY-SUBRC = 0.
  move rc to return.
ENDIF.

Read only

0 Likes
1,479

Hi,

Thanks for your reply.But the method is not giving size of file.It is returning 0 in RC of the method.

Read only

0 Likes
1,479

1) Check sy-subrc value after the method is executed to check if the method is returning any error

2) Check if the filename provided is correct

3) Have you called CALL METHOD CL_GUI_CFW=>FLUSH after the call to the method FILE_GET_SIZE ?

Edited by: Vasuki S Patki on Jan 27, 2010 5:33 PM

Read only

0 Likes
1,479

I called the method CL_GUI_CFW=>FLUSH after File_get_size and sy-subrc = 0 also.

Read only

0 Likes
1,479

Hi Ramya,

Try using GUI_GET_FILE_INFO.

 data file_path  like rlgrap-filename."später verlängern
data filesize   type i

    call function 'GUI_GET_FILE_INFO'
         exporting
              fname          = file_path
         importing
              file_size      = filesize
         exceptions
              fileinfo_error = 1.
    move filesize            to object_hd_display-objlen.
    move reference_type_file to object_hd_display-extct.
    perform mom_object_insert.
    if f_cancelled is initial.
*     Object was created successfully
      move: crea                     to objects-okcode,
            object_hd_display-objnam to objects-objnam,
            object_hd_display-objdes to objects-objdes.
      modify_objects_index current_line.
    endif.
  endif.

Regards

Abhii

Read only

0 Likes
1,479

Can you pls post your code here.

Read only

0 Likes
1,479

But GUI_GET_FILE_INFO is also a obsolete FM

Read only

0 Likes
1,479

data:V_FILENAME LIKE RLGRAP-FILENAME value 'C:\Documents and Settings\narayanp\Desktop\pass.txt',

V_RETURN TYPE I.

DATA:L_FILE TYPE STRING,

RC TYPE I.

CALL FUNCTION 'WS_QUERY'

EXPORTING

FILENAME = V_FILENAME

QUERY = 'FL'

IMPORTING

RETURN = V_RETURN

EXCEPTIONS

OTHERS = 1.

*MOVE V_FILENAME TO L_FILE.

*CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_GET_SIZE

  • EXPORTING

  • FILE_NAME = L_FILE

  • IMPORTING

  • FILE_SIZE = RC

  • EXCEPTIONS

  • FILE_GET_SIZE_FAILED = 1

  • CNTL_ERROR = 2

  • ERROR_NO_GUI = 3

  • NOT_SUPPORTED_BY_GUI = 4

  • others = 5

  • .

*IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

*

*CALL METHOD CL_GUI_CFW=>FLUSH

    • EXCEPTIONS

    • CNTL_SYSTEM_ERROR = 1

    • CNTL_ERROR = 2

    • others = 3

  • .

*IF SY-SUBRC <> 0.

*MOVE RC TO V_RETURN .

*ENDIF.

WRITE V_RETURN .

Read only

0 Likes
1,479

Hi Ramya,

Pls check the path that you have provided, as I get the right file size with the code that you have provided.

I uncommented the replacement part ( CL_GUI_FRONTEND_SERVICES=>FILE_GET_SIZE) that you have commented in your post, and able to get teh file size, can you please check again,.

Vasuki

Read only

0 Likes
1,479

Give the file path through selection screen and check if its working!!

if u like to hardcode the string for which u want to return length then give a simpe word with out slashes or other character's and

check........

I guess this should work for u

Regards,

Shravanthi

Read only

Former Member
0 Likes
1,479

Hello,

I hope Vasuki S Patki is correct

Thanks,

santhosh

Edited by: santhosh kumar on Jan 27, 2010 12:04 PM

Read only

Former Member
0 Likes
1,479

Hi ,

Use class cl_gui_frontend_services and method

CALL METHOD cl_gui_frontend_services=>FILE_GET_SIZE

Regards

SVJ

Edited by: Siddivinesh jogu on Jan 27, 2010 12:42 PM