Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Creating a File in Application Server

Former Member
0 Likes
612

Hi i have some data in the internal table itab. which contains few fields. Some of the fields are blanks and some contains data. Now i am transfering this internal table to file which is in Application Server. When i trnasfer itab to file, blank fields are concatenated by next field.

Explanation:

itab contains fallwoing data:

field1 field2 field3 field4 field5

uu kk nn ii

when i transer this to file it is coming as fallows

field1 field2 field3 field4 field5

uu kk nn ii

how can i solve this problem

Thanx in Advance

Subhani.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
592

Hi Subhani,

This probelm can be fixed very easily. All you need to do is to use Offsets while writing to the file from internal table. This is done as follows:

DATA: gv_string(217) TYPE c, " Holds text to display

Loop at <itab> into <wa>.

gv_string+0(5) = <wa>-<fieldname>

gv_string+10(5) = <wa>-<fieldname>

  • do this for all the fileds.

Endloop.

Note: In the above code snipet, 0(5) represents 'Starting for the 0th position, reserve 5 characters and print it there. Use this for all the fields of your internal table. Based on the size of the field(s) of the itab, allocate the space accordingly.

<b>PLZ REWARD POINTS IF HELPFUL</b>

Hi i have some data in the internal table itab. which contains few fields. Some of the fields are blanks and some contains data. Now i am transfering this internal table to file which is in Application Server. When i trnasfer itab to file, blank fields are concatenated by next field.

Explanation:

itab contains fallwoing data:

field1 field2 field3 field4 field5

uu kk nn ii

when i transer this to file it is coming as fallows

field1 field2 field3 field4 field5

uu kk nn ii

how can i solve this problem

Thanx in Advance

Subhani.

4 REPLIES 4
Read only

Former Member
0 Likes
592

Problem Explanation Again:

itab contains fallwoing data:

field1 field2 field3 field4 field5

uu-----kk


nn---ii

when i transer this to file it is coming as fallows

field1 field2 field3 field4 field5

uu-----kk-nn-ii--


Ignore the doted line.

Read only

0 Likes
592

try putting a field separator such as a comma between the fields

Read only

Former Member
0 Likes
593

Hi Subhani,

This probelm can be fixed very easily. All you need to do is to use Offsets while writing to the file from internal table. This is done as follows:

DATA: gv_string(217) TYPE c, " Holds text to display

Loop at <itab> into <wa>.

gv_string+0(5) = <wa>-<fieldname>

gv_string+10(5) = <wa>-<fieldname>

  • do this for all the fileds.

Endloop.

Note: In the above code snipet, 0(5) represents 'Starting for the 0th position, reserve 5 characters and print it there. Use this for all the fields of your internal table. Based on the size of the field(s) of the itab, allocate the space accordingly.

<b>PLZ REWARD POINTS IF HELPFUL</b>

Read only

Former Member
0 Likes
592

Hi Subhani,

This can be achieved by writing the keyword "separated by space" or "separated by comma".

You can press F1 on the transfer keyword and you will get the various options.

The other way can be to use the offsets as mentioned above.

The third solution can be to convert the file to ascii and then you can transfer the data easily.The function module for the same is :SAP_CONVERT_TO_TEX_FORMAT.

I hope I have tried to answer your query.

In case you have any further queries,feel free to ask.

Regards,

Puneet Jhari.