how to write itab fields in one line seperated by space

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

vasu_user

how to write itab fields in one line seperated by space

Post by vasu_user » Tue Aug 09, 2005 3:01 pm

Hi Guys

I have a question may be simple but my stupid brain is not wroking.

I have an internal table with data and I want to write this internal table onto application server seperated by space.

Here you go.

types : begin of costcenter,
kokrs type csks-kokrs,
kostl type csks-kostl,
end of costcenter.

data : t_costcenter type standard table of costcenter initial size 0,
wa_costcenter type costcenter.


loop at t_costcenter into wa_costcenter.

transfer wa_itab to 'xxxxxxxfile'.

endloop.

This code writes wa_costcenter onto file but I want to write with space seperation between fields. Here in this example I have 2 fields but in reality I have like 20-30 fields.

I can concatenate these fields into string or another variable seperated by space but I am looking for any simple solution.

Thanks a lot in advance
Vasu

Big Joe
Posts: 171
Joined: Wed Oct 20, 2004 2:43 pm
Location: Zürich - Switzerland

Post by Big Joe » Tue Aug 09, 2005 6:28 pm

hi there...

something like:

loop at itab_XX into wa_XX.

concatenate wa_xx-field1
wa_xx-field2 into itab_XY-field_AAA separated by space.

endloop.


is this wha you need ?

CIAOOO

Guest

Post by Guest » Tue Aug 09, 2005 6:35 pm

Thanks Joe,

I know this solution as I told you earlier i have like 20-30 fields in internal table , still I can concatenate but just wondering if there is any other solution.


Thank you
Vasu

Sark E. Get

Search

Post by Sark E. Get » Wed Aug 10, 2005 5:27 am

Anonymous wrote:I know this solution as I told you earlier i have like 20-30 fields in internal table , still I can concatenate but just wondering if there is any other solution.
Use the search function, this has been asked so many times before. Maybe Rich has a macro for it :wink:

Guest

Post by Guest » Wed Aug 10, 2005 6:54 am

types : begin of costcenter_space,
kokrs type csks-kokrs,
filler,
kostl type csks-kostl,
filler2,...
end of costcenter.

wa_costcenter_space type costcenter_space.

clear wa_costcenter_space.
loop at t_costcenter into wa_costcenter.
move-corresponding wa_costcenter to wa_costcenter_space.
transfer wa_costcenter_space.
endloop.


regards.

Guest

Post by Guest » Wed Aug 10, 2005 6:57 am

I've forgotten:
do not use concatenate... it ignores trailing spaces.

regards.

hognoxious
Posts: 1398
Joined: Thu Dec 04, 2003 8:16 am
Location: Stuck in a pagoda with Tricia Toyoda

I see the cop-paste fairy has worked her magic here...

Post by hognoxious » Wed Aug 10, 2005 9:08 am

Anonymous wrote:types : begin of costcenter_space,
kokrs type csks-kokrs,
filler,
kostl type csks-kostl,
filler2,...
end of costcenter.
Terrible. You'd have to change the code if a field was added or removed. And what about any non-charachter fields? I really hope you don't code like that for real.
First he pinches my sig, Now he's cribbing my posts too!

Guest

Re: I see the cop-paste fairy has worked her magic here...

Post by Guest » Thu Aug 11, 2005 2:11 am

Hi Hognoxious :)
hognoxious wrote:
Terrible. You'd have to change the code if a field was added or removed.
If a field has to be added or removed in an internal table you likely have to change the code...
hognoxious wrote:
And what about any non-charachter fields?
What's the problem with non-character fields?

Could you please show your solution?

Thanks for your patience :)

Regards

Guest

Post by Guest » Thu Aug 11, 2005 2:57 am

Rich,
you're absolutely right.

But the original poster didn't mention any problem with numeric fields, so I assumed that the internal table already contained only 'transferable' fields.

He even said that he could have used the CONCATENATE command..

Regards.

ocvantol
Posts: 929
Joined: Tue Oct 22, 2002 3:19 am
Location: The Hague

Re: I see the cop-paste fairy has worked her magic here...

Post by ocvantol » Thu Aug 11, 2005 4:25 am

Anonymous wrote:Hi Hognoxious :)
hognoxious wrote:
Terrible. You'd have to change the code if a field was added or removed.
If a field has to be added or removed in an internal table you likely have to change the code...
Not if you use field symbols
Oscar.

Search user man

Re: I see the cop-paste fairy has worked her magic here...

Post by Search user man » Thu Aug 11, 2005 6:53 am

Anonymous wrote: Could you please show your solution?
Could we please have your salary? After all, we seem to be doing your job.

It's been asked before: use the f^&%%* search already!

RosieBrent
Posts: 6197
Joined: Mon Oct 21, 2002 3:04 am
Location: Darlington
Contact:

Post by RosieBrent » Thu Aug 11, 2005 7:09 am

This topic will be locked if the abuse level gets any worse than above. Please note that masked profanity is no better than open profanity and will be treated as such.
Kind Regards

Rosie Brent

Please remember to search the forum and check the FAQ before posting questions, thank you.

Tuly Idiot most of the time, part-time Guru Image

Guest

Re: I see the cop-paste fairy has worked her magic here...

Post by Guest » Thu Aug 11, 2005 8:03 am

Search user man wrote:
Anonymous wrote: Could you please show your solution?
Could we please have your salary?
I'd do if I could :D, but I'm afraid it's nuts for an high-level such you.
Search user man wrote: After all, we seem to be doing your job.
Really? It seems to me you're wasting time...

You haven't read the entire post or you haven't understand it. It's up to you. :D

Best regards.

vasu_user

Post by vasu_user » Thu Aug 11, 2005 8:19 am

Hi Guys

Thank you for all your responses ! In my internal table I may have numberic data type also . I do not know that I will have problem in concatenating numeric fields .

Anyway I will follow RICH solution and let you know guys.

Once again thank you for all your time and efforts.

Vasu

Guest

Post by Guest » Thu Aug 11, 2005 1:08 pm

Hello Guys

Filler after every field is working fine in my case.

hognoxious wrote:

And what about any non-charachter fields?



What's the problem with non-character fields?

Thanks for every one and special thanks to Guest who suggested filler and Rich

Vasu

Post Reply