在 SAP ABAP 中將檔案轉換為位元組陣列
以下是一個程式碼片段,以完成同樣的操作。
data: f_line type xstring. // to get line by line content data: f_file type table of xstring. // to get the final content data: f_filename type string value 'samplefile.txt'. // store the filename of file data: f_len type i. open dataset f_filename for input in binary mode. // read the binary read dataset f_filename into f_line length f_len. // get the number of lines in the file while f_len > 0. // loop through file line by line append f_line to f_file. read dataset f_filename into f_line length f_len. endwhile. close dataset f_filename // close the dataset
上述程式碼片段是多種可能的方法之一。你可以用它來擴充套件或匯出功能。
廣告