Skip to Content
avatar image
Former Member

ABAP code for flat file path

Hello,

My hierarchy is loaded through flat file. This file is present in the application server.

We have hard coded the filename path in our program in the production system as:

DATA:p_fname LIKE rlgrap-filename value '
A0001SAP\PACE_PRD\interface\BI\BO\PYD_PDL.CSV'

Now, our pre production system is refreshed and hence after the refresh, the same path got copied in the pre production system and our process chain got failed as the path name is wrong. Same is the case in the development system.

Please note: The file path is same in all the systems except the name of the system i.e.

For development system, the name is PACE_DEV

for preprodcution system, the name is PACE_PREPRD,

for production system, it is PACE_PRD.

Could anyone let us know, what global logic should be developed so that the process chain runs smoothly in all the systems?

Thanks in advance for the reply.

Regards,

Nitin Chopade.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Dec 20, 2011 at 01:45 PM

    Use logical filenames.

    Go look it up.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 20, 2011 at 01:49 PM

    Use the below code for the file path of your local matchine.

    PARAMETER: file_nm TYPE localfile.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file_nm.

    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

    EXPORTING

    • PROGRAM_NAME = SYST-REPID

    • DYNPRO_NUMBER = SYST-DYNNR

    • FIELD_NAME = ' '

    static = 'X'

    • MASK = ' '

    CHANGING

    file_name = file_nm

    EXCEPTIONS

    mask_too_long = 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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 20, 2011 at 02:33 PM

    Hi,

    +1 for Maen suggestion: Logical file path is the best way to "standardize" file accesses! Have a look to doc & transaction FILE...

    The only FM you will then need is FILE_GET_NAME_USING_PATH...

    Kr,

    Manu.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 20, 2011 at 09:06 PM

    Nitin Chopade,

    Put the path /file name on the selection screen.

    parameters: p_output(120).

    Then use that selection-screen field in place of the hard coded value.

    You can then change the path / file name at will.

    or

    Change the file '
    A0001SAP\PACE_PRD\interface\BI\BO\PYD_PDL.CSV'

    to '
    A0001SAP\PACE_&SYSID&\interface\BI\BO\PYD_.CSV'

    Assign the hard coded value to a variable, w_variable.

    Before you use the file:

    replace '&SYSID&' in w_variable with sy-sysid

    Bruce

    Edited by: Bruce Tjosvold on Dec 20, 2011 4:09 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 21, 2011 at 12:52 AM

    Hi,

    Depending on the setup, you may use radiobuttons to let the user choose between the 3 hardcoded paths. If the program is automated and you know how to determine what system is being used, you may use custom tables to maintain the hardcoded path that will be used by the program.

    Regards,

    Paul

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 21, 2011 at 01:26 AM

    Hi Nitin,

    I'd suggest to use logical filename, which is platform independent.

    Cheers

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 21, 2011 at 01:48 AM

    Hi,

    I suggest you to use Logical File Path

    FM: FILE_GET_NAME_USING_PATH

    Chaminda

    Add comment
    10|10000 characters needed characters exceeded