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

Function Module for creating file name in Application Server

manoj_goyal2
Participant
0 Likes
1,105

Hi Guys,

Can you suggest me a function module to generate a file name for a flat file to be save on application server using DATASET.

Required filename format : <table name >.<times tamp>.TXT

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

manoj_goyal2
Participant
0 Likes
703

I know OPEN DATASET will create the file, but I need the function module to generate the file name in following format.

<table name>.<time stamp>

Like I should be able to pass the table name, and FM gives me the full file name in above format.

5 REPLIES 5
Read only

suresh_datti
Active Contributor
0 Likes
703

You don't need a function module.. with the OPEN DATASET <filename>... FOR OUTPUT the system opens the file in write mode. If the file already exists, its existing content is deleted. If the file does not exist, the <b>system creates it</b>.

~Suresh

Read only

manoj_goyal2
Participant
0 Likes
704

I know OPEN DATASET will create the file, but I need the function module to generate the file name in following format.

<table name>.<time stamp>

Like I should be able to pass the table name, and FM gives me the full file name in above format.

Read only

0 Likes
703

Hi mg,

You just need to concatenate the SY-UZEIT value to the table name you're providing. This can be done as follows:

CONCATENATE 'MARA' SY-UZEIT INTO FILE_NAME SEPARATED BY '.'.

Regards

Anil Madhavan

Read only

0 Likes
703

data w_filename type FILEEXTERN.

  • put the table in the variable w_table

concatenate w_table sy-datum sy-uzeit into w_filename

separated by '.' .

open dataset w_filename for output in text mode.

~Suresh

Read only

ferry_lianto
Active Contributor
0 Likes
703

Hi,

Please try this ...


DATA: BEGIN OF FILE1,
        CONST1(01) TYPE C VALUE '_',
        FIELD1     LIKE SY-DATUM,
        CONST2(01) TYPE C VALUE '_',
        FIELD2     LIKE SY-UZEIT,
      END OF FILE1.

DATA: FILENAME LIKE EDI_PATH-PTHNAM.

MOVE SY-DATUM  TO FILE1-FIELD1.
MOVE SY-UZEIT  TO FILE1-FIELD2.
CONCATENATE <table name> FILE1 INTO FILENAME.

...

Regards,

Ferry Lianto