Liquid UI - Documentation - 7.04 closefile()

7.04 closefile()


Purpose

With closefile(), you can save the changes and close an opened file. After performing file operations like open, read, and append, we recommend you close the file to save the changes. Also, closing a file helps you to start reading it from the beginning while performing the read operation.

The closefile() returns a boolean value based on the close status of the file.

  • True: If the file closed successfully
  • False: If the file is not closed


Syntax

Format 1: The file name can be specified directly in the command if the file exists in your scripts directory.

closefile("Filename.ext");
 

Format 2: The file path needs to be specified if the file does not exist in your scripts directory.

// You need to place double backward slashes between the folder names in the file path.
closefile("C:\\LiquidUI\\MMModule\\filename.ext");
 


Properties

  • Filename.ext - Name of the file with extension


Options

The closefile() command does not take any options.


Example

In the following example, we will close the ordertypes.txt file after adding the specified names into it.

//Allows you to open the file internally to add the names into it.

openfile("ordertypes.txt",{"delimiter":",","output":true,"append":true});
name1 = "Standard Order";
name2 = "Promotion Order";
name3 = "Returns";
appendfile("ordertypes.txt",{"name1":true,"name2":true,"name3":true});
closefile("ordertypes.txt");

The file is now closed after completing the read or edit operation.


Tips and Tricks

  • You need to open a file before performing edit or read operations and close the file to save the changes.
  • SAP mode-specific file opening and closing are possible.


Usage Details


Can't find the answers you're looking for?