Application Development 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: 

write out file to PC-problem

Former Member
0 Kudos
233

hi people,

When I am writing my data to the presentation server, the fields are not getting transferred as they should. The fields that are coming from the tables directly are the ones that are not getting copied with the manipulation that I have done on them. Can somebody suggest something? For example,

it I want lips-werks to write only three chars. say SDN it is still writing out all the characters in the flat file on the PC but is giving out the right data on the SAP screen.

Can somebody suggest something or give some solution to this problem?

Thanks,

AM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
145

Hi AM,

When you are writing your file to the PC, the internal table with the data has to be EXACTLY as you want it be sent to the PC. If you want to truncate lips-werks to three characters, I would recommend moving it to a three character field in the internal table. If you leave it as LIPS-WERKS then at best it will have 4 characters with one of them blank, and at worst the whole field will be written to the table.

Second point is, how are you "manipulating" the data? If you just use a write statement for formatting on the SAP screen then the data wont be affected in the table. If you are changing the contents of the internal table, make sure to use a MODIFY statement to ensure that the contents of the internal table are updated.

If you implement these suggestions, then your problem should be fixed.

If not, come back with some more information.

Cheers,

Brad

20 REPLIES 20

Former Member
0 Kudos
146

Hi AM,

When you are writing your file to the PC, the internal table with the data has to be EXACTLY as you want it be sent to the PC. If you want to truncate lips-werks to three characters, I would recommend moving it to a three character field in the internal table. If you leave it as LIPS-WERKS then at best it will have 4 characters with one of them blank, and at worst the whole field will be written to the table.

Second point is, how are you "manipulating" the data? If you just use a write statement for formatting on the SAP screen then the data wont be affected in the table. If you are changing the contents of the internal table, make sure to use a MODIFY statement to ensure that the contents of the internal table are updated.

If you implement these suggestions, then your problem should be fixed.

If not, come back with some more information.

Cheers,

Brad

0 Kudos
145

Hi,

Thanks for your reply. Another question....what if I have to suppress leading and trailing zeros from fields?

Regards,

Minal

0 Kudos
145

You can suppress the leading zeros with the ALPHA conversion FMs:

CONVERSION_EXIT_ALPHA_INPUT

CONVERSION_EXIT_ALPHA_OUTPUT

Test them to see how they work.

Regards,

Peter

nishanthbhandar
Contributor
0 Kudos
145

Hi Minal,

Please make use of the SHIFT command to delete leading or trailing zeroes.

SHIFT <c> LEFT DELETING LEADING <str>.

SHIFT <c> RIGHT DELETING TRAILING <str>.

Cheers

Nishanth

0 Kudos
145

Hi Minal,

You have a number of good reponses here.

Please remember to reward those reponses that helped you. Just click on the stars next to each post.

Cheers,

Brad

0 Kudos
145

Hey everybody,

Thanks for all the help. One more help.....In the text file if I have to write data starting from a new line like:

120 USALP01 THREE

FOUR FIVE 3244

How Do I do that? Right now, I am getting the data that I want to start from the next line on one line.

And yes I will reward all the answers that have been helpful, brad.

Regards,

AM

0 Kudos
145

Thanks AM,

To put a carriage return, you need to use the hex character 13.

This can be like:

constants: c_cr(1) type x value '13'.

You can then introduce this into your internal table before downloading to the PC.

Otherwise, you can manage the split by moving the second line into another line in your internal table.

Cheers,

Brad

0 Kudos
145

Hi Minal,

If you are not getting a line feed for each line of your internal table, then set the WRITE_LF parameter to 'X'.

Cheers,

Brad

0 Kudos
145

Hey Brad,

Can you give me an example of how I should do either of the ways that you suggested?

Thanks,

AM

0 Kudos
145

When you write to the presentation server, you can use the function module GUI_DOWNLOAD.

All you need to do is two things:

1. Make sure that the lines in the internal table you pass to the parameter DATA_TAB, correspond exactly to the lines as you would like to see them on the file of the presentation server.

2. You need to pass the value 'X' to the parameter WRITE_LF.

Hope that helps.

Brad

0 Kudos
145

I have arranged the values in the internal table as I want them in my file but the thing is if say I have 5 values to be written out to my file, I want 3 to go on one line and 2 to start immediately from the next line. This has to be done for each line in the internal table.

So if I do a Write: / 11,2,3,

/ 45,78.

Its not working. It goes like this...11 2 3 45 78

So what should I do?

Thanks,

AM

0 Kudos
145

Hi AM,

Why do you talk about WRITE statements, when you are downloading to a file?

WRITE statements are for writing to a list on the screen, no?

Brad

0 Kudos
145

Yes, actually thats true.

So this is my code to write to a presentation server:

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

FILENAME = FILENAME

TABLES

DATA_TAB = ALL_CUSTOMERS

EXCEPTIONS

FILE_OPEN_ERROR = 1

OTHERS = 2.

CASE SY-SUBRC.

WHEN 1.

WRITE 'Error when file opened'.

EXIT.

WHEN 2.

WRITE 'Error during data transfer'.

EXIT.

ENDCASE.

How do I go about it now?

Thanks,

AM

0 Kudos
145

Have you got the function GUI_DOWNLOAD in your system?

If so, use that for a start (rather than the superceded WS_DOWNLOAD, it has similiar parameters, but more functionality).

Then, make sure that each line in your ALL_CUSTOMERS internal table corresponds to exactly one line on your local file.

Then pass the parameter WRITE_LF the value 'X' (default value, but its best to set it anyway).

That should do it.

Brad

0 Kudos
145

Hey Brad,

The problem with the data that I am writing out is that I have to break one line of the internal table. Its not about writing each line of the table. Every line of the table starts from a new line but that is not what I am trying to do. If you can please suggest a way to break one single line of the internal table from a particular field.

For example if I have

name addr1 addr2 werks spart as one line of the internal table and I want to write:

name addr1 addr2

werks spart

how do I do this?

Thanks,

Minal

0 Kudos
145

Hi Minal,

Dude! I said a number of times in other posts, you must format the internal table EXACTLY as you want it on the PC before you call the function. Therefore, you could do something like:


LOOP AT itab1.
  CLEAR: itab2.
  MOVE: itab1-name  TO itab2-data,
        itab1-addr  TO itab2-data+35,
        itab1-addr2 TO itab2-data+70.
  APPEND itab2.
  CLEAR: itab2.
  MOVE: itab1-werks TO itab2-data,
        itab1-spart TO itab2-data+4.
  APPEND itab2.
ENDLOOP.

This assumes that you only have one line type in your itab1, but you can adapt to suit your needs. But I hope this makes sense, you <b>must do the splitting logic yourself explicitly in the code</b>. By moving your data from one internal table to another you can achieve this.

Cheers,

Brad

0 Kudos
145

Hi,

Im a new member to this forums and also a newbie in ABAP

I was reading through this discussion and my problem seems to be somewhat similar.

I have downloaded the file on application server. This file is totally formatted one the way I need. when I execute my program it creates a file on app server.

Problem here is :-

when I go through transaction al11 I see the directory and

once I open my file I have data in it.. but Im not able to see the complete line. Is it because the total no of fields I have in one row is too large? coz the total no of charecters comes around 1300 in the header level data and around 500 in item level data.

I want to download this file on my PC and check if all is well! How do I go for it??

I would appreciate any help!

Thanks,

Madhu.

0 Kudos
145

Hey Madhu,

I am not sure if you can save the file to the PC when you are in AL11. The way to save a file from SAP to PC without writing the code to write it out to the PC is as follows:

on the top menu, -System-List-Save. Then you can save it to your C: . That is one way of checking if it is getting written completely or not on the App Serv. Other way is to use the code that I have in this string of mails to write the code to the PC where if the size of the file is approx the same on both the PC and the App Serv, then you know that the file has the data on the App Serv as well.

Let me know if this helped. If you need more help, reply back.

Good luck,

AM

0 Kudos
145

Thanks AM,

I can save the file as you said.. thats only if I write it out to the screen and then I will have that option. I tried that and I downloaded it on to my PC..it shows all the fields but not in one line..

And the file on my app server shows in one line but I dont see all the fields..

I was trying to use GUI_download! what do I specify for tables: data_tab? which table it shud be coz Im getting the final data from many diff tables and transferring to a file in a loop while opening the data set!

Thanks,

Madhu.

0 Kudos
145

Hi Madhu,

If you have data coming from many different tables then why don't you make one final_tab table in where you move all the data from all the different tables. This final_tab is the one that you will have to use in the GUI_Download function call for TABLES. If your data_tab is the final table with data from the different tables then you will have to use that.

As for the data coming in one single line, In text format that is not possible if each line of the internal table is very long.

I hope this helps.

Good luck,

AM