Hi All,

I have created this document to show you how to get the no of rows count from file without loading it into table.

I have used BODS EXEC command to get the rows count in file.

My BODS is installed on Linux server.


Suppose I have file with name contract_master.csv .

In this file there are 10 columns and 100 rows.

Now if I want to get the count of rows in file then I have to write the following code in script:

$row_count = exec(‘/bin/sh’,’-c “wc -l /C:/Incoming_Files/contract_master.csv’,0);


where row_count is the global variable of type varchar.

C:/Incoming_Files is path where file is kept.

Now when you run the job you will get the following output.

100 /C:/Incoming_Files/contract_master.csv

here first 100 represent total number of rows in file.

Now to remove the file path & file name use following code

$actual_count =  rtrim_blanks( ltrim_blanks( replace_substr(‘/C:/Incoming_Files/contract_master.csv’,”)));

I hope this will help you.

You can do testing vary easily using this functionality,let’s say you have 100 file in your project and you have to load all the files & post loading to varify the count whether all data loaded properly you can apply logic mentioned above.

Feel free to ask any doubt.



To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Arun U

    Hi Dirk,

    Any method of reading count from SAP ECC as source? while assigning values to variable using SQL or word for RDBMS and Flat file works need to know if there is something available for SAP Application as data store.

  2. srinivas panala

    Hi swapnil bhootwala,

    The above script

    $row_count = exec(‘/bin/sh’,’-c “wc -l /C:/Incoming_Files/contract_master.csv’,0);

    is not working for me its throwing some issue.
    my script is below:

    #$row_count =  exec(‘/bin/sh’,’-c “wc -l /C:Test_Folder/201612.csv’,0);

    Please look over the script and help me out.



Leave a Reply