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

Re: Flat file validation

Former Member
0 Likes
1,004

Hi experts,

I am using a FM : F4_filename to obtain file from front end.(presentaion server)

And the i am using fm 's to upload into internal tables.

before that i need to validate the flat file name which i got through F4_filename.

sample code.

at selection-screen on value-request for H_FILE.

CALL FUNCTION 'F4_FILENAME'

  • EXPORTING

  • PROGRAM_NAME = SYST-CPROG

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = H_FILE

.

MOVE P_FILE1 TO C_FILE.

Validating the file

  • IF C_FILE NE 'GLAC.TXT'.

  • MESSAGE E999 WITH 'select the valid file'.

  • ENDIF.

it is giving dump

-


Is ther any fm to obtain file from application server(al11)?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
961

For application server file use FM F4_DXFILENAME_4_DYNP

Regards,

Atish

9 REPLIES 9
Read only

Former Member
0 Likes
962

For application server file use FM F4_DXFILENAME_4_DYNP

Regards,

Atish

Read only

Former Member
0 Likes
961

MOVE P_FILE1 TO C_FILE.

u should write like this : MOVE H_FILE TO C_FILE.

Madhavi

Read only

Former Member
0 Likes
961

Hi

FM: F4_FILENAME results with total path i.e directory path and filename.

Do you need to compare the total path or the file name alone is unclear. If you just need to compare the filename first you have to split the contect of the result from FM to directory and file and then use the file name to compare.

Popup dialog for application server files can be brought by FM: /SAPDMC/LSM_F4_SERVER_FILE

Below is sample code for your reference:


*** Display Directories on the Application Server
     CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
          EXPORTING
            DIRECTORY         = <directory_name>
*   filemask               = ''
         IMPORTING
            SERVERFILE        = P_FILE
         EXCEPTIONS
            CANCELLED_BY_USER = 1
            OTHERS            = 2.
     IF SY-SUBRC  0.
        MESSAGE W016 WITH P_FILE.
     ENDIF.

Kind Regards

Eswar

Read only

0 Likes
961

Hi,

i want to compare file name only , as you said i have to split the entire string into dir and file name.

Thank you

rgds

Umakanth.

Read only

0 Likes
961

Hi

Check below code:


DATA: filepath TYPE ibipparms-path.
DATA: itab TYPE TABLE OF string.
DATA: file TYPE string.
DATA: lin TYPE i.

CALL FUNCTION 'F4_FILENAME'
 EXPORTING
   program_name        = syst-cprog
   dynpro_number       = syst-dynnr
*   FIELD_NAME          = ' '
 IMPORTING
   file_name           = filepath.

SPLIT filepath AT '\' INTO TABLE itab.
DESCRIBE TABLE itab LINES lin.

READ TABLE itab INTO file INDEX lin.

WRITE:/ file.

Regards

Eswar

Read only

0 Likes
961

Hi Eswar,

i want to validate the file, if he unknowingly written any file name instead of using f4 help.

any FM?

Thanks in advance

rgds

Umakanth

Read only

0 Likes
961

Hi Umakanth

Move this part of code to AT SELECTION-SCREEN event.


AT SELECTION-SCREEN.
SPLIT filepath AT '\' INTO TABLE itab.
DESCRIBE TABLE itab LINES lin.
 
READ TABLE itab INTO file INDEX lin.
 
IF file NE <req_file_name>.
*** Error Message
ENDIF.

Here filepath is the parameter, so irrepective of how the filepath is selected the condition applies.

Kind Regards

Eswar

Read only

Former Member
0 Likes
961

Use FM 'KD_GET_FILENAME_ON_F4'. It is very easy.

try this code

PARAMETERS: FILE_NAM LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE_NAM.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

FILE_NAME = FILE_NAM

  • EXCEPTIONS

  • MASK_TOO_LONG = 1

.

Read only

Former Member
0 Likes
961

Hi Umakanth,

Try this one.This will helpful to u ok.

data: gv_infile = p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

  • FIELD_NAME = ' '

IMPORTING

file_name = p_file.

gv_infile = p_file.

we have to cmp with gv_infile ok.

Award points if helpful.

Kiran Kumar.G.A

HAve a Nice Day..