How To Become a Better professional With BODS Windows command

0
160
SAP BODS functions
Windows_Function_ BODS

How To Become a Better professional With BODS Windows command

  1. How to generate UTF8 or any word or value as header in a file by using Echo Function.

To generate a UTF8 or any word or value as a header in a file by using the Echo function, you first need to understand the syntax of the Echo command. Additionally, ensure that your text editor or terminal supports UTF8 encoding. For example, you can use the Echo function followed by the desired text in quotation marks. Furthermore, it is important to redirect the output to the desired file. In conclusion, by following these steps, you can successfully generate headers in a file using the Echo function.

Source:

Target:

  1.  To achieve the above requirement use the below script.

         EXEC ( ‘CMD’,’@ECHO UTF8>  filetest.csv’);

2. How to redirect the output file content to another new file..

  1. By using Type function we can redirect the content of the file and it will create a new file with the copied data.

Print ( exec( ‘CMD’, ‘TYPE \\filepath\ Multiple_output.csv > \\filepath\filetest.csv’));

3. How to merge the data from multiple files to one file even if the structure is not the same.

  1. Use the copy command and /b parameter to merge the files.

Print ( exec ( ‘CMD’, ‘COPY /b \\\filepath\Multiple_output.csv + \\\filepath\filetest.csv >\\\file path\filetest3.csv’));

4. Output can be appended to an existing file.

  1. By using Type function we can append the data to an existing file.

Print (exec (‘CMD’, ‘TYPE Output_file.csv > > Existing file’));

5. How to remove the blank lines (Rows) in a source file. If any blank lines exist in our source file, BODS will throw error as below.

  1. By using findstr function and /v parameter we can achieve this.

Print ( exec( ‘CMD’, ‘findstr /v “^$” “\\\filepath\BLANKCSV.CSV” > file path\Blank2.csv’));

6.How get the record count from the file.

  1. By using find command and /v /c parameters will get the record count.

word_ext( exec( ‘cmd’,’find /v /c “|” [$G_JOB_SERVER_PATH]\[$G_FILENAME] ‘),-1,’:’);

OR print( exec( ‘cmd’ , ‘findstr /R /N “^”  Filename.txt| find /c “file delimiter”‘));

7.How to remove special characters in given string.

To remove special characters in a given string in BODS, first, identify the characters you want to remove. Next, use the appropriate string functions provided by BODS to replace or remove these characters. For example, you can use the REPLACE function to substitute special characters with an empty string. Furthermore, consider using the REG_EXTRACT function for more complex patterns. In conclusion, by utilizing these functions, you can effectively remove special characters from your string in BODS.

  1. print( regex_replace( ‘Ac@,*^&cou+-nti¬ng’,’\\[@,*,^,&,¬,-,+\\]’,”));

For some values we need to use escape characters \-\

8. Using key generation function for flat file.

key_generation(FF_KEY_TARGET.”\\\key_target.txt”,’key’,1)

Here FF_KEY_TARGET means Target file format name key_target.txt is target file.

9. Count the number of files in a folder.

print( exec(‘cmd’,’dir  \filepath\*.txt| find “File(s)”‘));

(or ) print( exec(‘cmd’,’dir filepath\*.txt /b | find /v /c “\”‘));

10 Print all the file names from a single folder.

exec ( ‘cmd’,’dir/b \\\filepath\filename*.txt’ );

11. Pick the latest filename from group of files in a folder.

print( word_ext( exec( ‘cmd’,’dir/b /o-d \\\ filepath\*.xml ‘ ),1,’ ‘));

12. Below is for count of directories in a folder

print( exec(‘cmd’,’dir /b /o:-d /a:d  \\\filepath  | find /c /v “:” ‘));

13. Below is for count of files in a folder

print( exec(‘cmd’,’dir /b /o:-d /a-d  \\\filepath\*.txt  | find /c /v “:” ‘));

      To learn BODS from SAP please click here

      To learn SAP ABAP from SAP please click here

      LEAVE A REPLY

      Please enter your comment!
      Please enter your name here