Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Field Symbols.

Hi,

My requirement is to tranfer 5 internal table contents to 5 different files in application server. To achieve this in one go I used feild symbols & I was successful in it. But now a change has come in where the filepath needs to be flexible depending upon the environment & client where I am running this program. Hence I want help on converting the hardcoding of file path to the one which will be given in the selection screen.

Following is the code that I am using :-

  • Uploading the details of first internal table

WA_FILE-TABLENAME = 'IT_GLAC_BUKRS'.

WA_FILE-WA = 'WA_GLAC_BUKRS'.

WA_FILE-FILEPATH = '/usr/sap/Gl_Account_Text.txt'.

APPEND WA_FILE TO IT_FILE.

  • Uploading the details of second internal table

WA_FILE-TABLENAME = 'IT_PRCTR'.

WA_FILE-WA = 'WA_PRCTR'.

WA_FILE-FILEPATH = '/usr/sap/Profit_Center_Text.txt'.

APPEND WA_FILE TO IT_FILE.

  • Perform to transfer the files to application server

LOOP AT IT_FILE INTO WA_FILE.

PERFORM TRANSFER_DATA USING WA_FILE-TABLENAME

WA_FILE-WA

WA_FILE-FILEPATH.

ENDLOOP.

*&----


*& Form TRANSFER_DATA

*&----


  • Perform to transfer the files to application server

*----


  • -->P_WA_FILE_TABLENAME text

  • -->P_WA_FILE_WA text

  • -->P_WA_FILE_FILEPATH text

*----


FORM TRANSFER_DATA USING DATA_TAB

WA

FILE.

ASSIGN (DATA_TAB) TO <FS_DATATAB>.

ASSIGN (WA) TO <FS_WA>.

OPEN DATASET FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

IF SY-SUBRC = 0.

LOOP AT <FS_DATATAB> INTO <FS_WA>.

TRANSFER <FS_WA> TO FILE.

ENDLOOP.

ENDIF.

CLOSE DATASET FILE.

Thank You,

SB.

Tags:
Former Member
replied

Is this what you are looking for?

parameters: p_file1 LIKE rlgrap-filename DEFAULT '/usr/sap/Gl_Account_Text.txt',
            p_file2  LIKE rlgrap-filename DEFAULT '/usr/sap/Profit_Center_Text.txt',
            p_file3  LIKE rlgrap-filename DEFAULT ....
            p_file4 ....
            p_file5....

You can then simply use the same existing code where you are appending IT_FILE,

but instead of WA_FILE-FILEPATH = '/usr/sap/Gl_Account_Text.txt', you can now say WA_FILE-FILEPATH = p_file1.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question