Wednesday, October 10, 2007

SAP R/3 : GUI_UPLOAD with # as SPACE...

There are many times when we need to upload a text file into an internal table we are not aware that the SPACE among the line of strings in the text file is represented as '#'. When we unknowingly get a row of items and started to split it, using SPLIT syntax with the normal '#' symbol, into the columns of your internal table then we get garbage or unreadable contents in the internal table.


That is because the space is not recognized during upload by GUI_UPLOAD function module. The SPACE among the strings of line items will be replace by '#'. However, this hash or '#' is not your average character '#' but it is an ASCII character of value 09. Thus it showed as '#' in your strings of line items.

Therefore, you will need to do something in your coding so you can SPLIT your string of items properly with the '#'. So, you have to declare a variable with X and value of 09 at the begining of your code. Then only you can use it in your SPLIT syntax. For example, the code below.

Data : tp_hash TYPE x VALUE '09'.
Data : tp_result1(15) TYPE c.
Data : tp_result2(15) TYPE c.

Assuming variable tp_file-item contains 'WILLIAM#WILSTROTH' and obtained via GUI_UPLOAD.

SPLIT tp_file-item AT tp_hash INTO tp_result1 tp_result2.

Write : / tp_result1, tp_result2.

Thus, it now shows:

William Wilstroth


is sky the limit... split with ASCII 09... not #...

No comments: