‎2006 Jun 09 1:19 AM
Hi all,
I am using as follows
data : num1(60) type c value 'what'.
data: num2(10) type c value 'who'.
in the o/p i will be getting num2 after 61 column..correct...how to get num2 after num1 just seperated by tab..how to remove empty columns..i want o/p as:::
what who (seperated by tab space)
‎2006 Jun 09 1:29 AM
hi use the below code..
data : num1(60) type c value 'what'.
num2(10) type c value 'who',
res(70) type c.
concatenate num1 num2 into res separated by space.
Cheers,
Abdul Hakim
‎2006 Jun 09 1:29 AM
If you are outputting this to a file, you can do something like this. On the output list here, the # represents the TAB. But in a .txt file it would be a tab.
report zrich_0006.
data : num1(60) type c value 'what'.
data: num2(10) type c value 'who'.
data: output_string type string.
concatenate num1 num2 into output_string
separated by cl_abap_char_utilities=>horizontal_tab.
write:/ output_string.
If you just want to put a space in between in your list display, then you can the same, but separated by space.
report zrich_0006.
data : num1(60) type c value 'what'.
data: num2(10) type c value 'who'.
data: output_string type string.
concatenate num1 num2 into output_string
separated by space.
write:/ output_string.REgards,
Rich Heilman
‎2006 Jun 09 1:33 AM
‎2006 Jun 09 1:35 AM
hi you can use but specify the length
for eg,
data output_string(80) type c.
Cheers,
Abdul Hakim
‎2006 Jun 09 1:36 AM
data: output_string type c will only have a default legth of 1 char unless you explcitly specify the legth.
With a data type STRING you need not specify the length, it is dynamically assigned at runtime by the system.
Regards,
Suresh datti
‎2006 Jun 09 1:44 AM
‎2006 Jun 09 1:45 AM
hi no u cannot if you want to use tab then refer the code given by Rich..
Cheers,
Abdul Hakim
‎2006 Jun 09 1:46 AM
hi,,
it is giving error for
separated by cl_abap_char_utilities=>horizontal_tab
Thanks
‎2006 Jun 09 1:47 AM
If you are writing this to a list display, tab does you no good. If you are writing this out to a .txt file, then tab would definitly work. You must use the class=>attribute that I have provided above. If you are on earlier version of SAP, this class will not exists, so you must use the hex value instead.
report zrich_0006.
data : num1(60) type c value 'what'.
data: num2(10) type c value 'who'.
data: output_string type string.
<b>CONSTANTS: c_tab TYPE x VALUE '09'.
</b>
concatenate num1 num2 into output_string
separated by <b>c_tab</b>.
write:/ output_string.Regards,
Rich Heilman
‎2006 Jun 09 1:48 AM
‎2006 Jun 09 1:50 AM
‎2006 Jun 09 1:52 AM
hi i m in 4.7 so i think it doesnt exits in 4.6c so ref the code given by Rich...
Cheers,
Abdul Hakim
‎2006 Jun 09 1:53 AM
‎2006 Jun 09 2:01 AM
Hi,
see i am having 10 fields to be displayed in seperate format o/p as::
12 10
12 23 45 45
12
56 78 34
and some fileds are having length of 50 60...
I want the o/p to be displayed just like above but for adjacent fields seperated by tab???????
each field in each row seperated by tab space/////
‎2006 Jun 09 2:05 AM
‎2006 Jun 09 2:09 AM
first row consists of constant values
second row is also constant
<b>third row is field values...it may goto 10 rows</b>
and 4th and 5th rows are constants..similar to 1st and 2nd......
‎2006 Jun 09 2:11 AM
Ok, check out this sample. Here all of the data resides in an internal table. We are writing out all of the fields that actually have some data in it and separating with a tab.
report zrich_0006.
data: begin of itab occurs 0,
fld1(10) type c,
fld2(20) type c,
fld3(30) type c,
fld4(40) type c,
fld5(50) type c,
end of itab.
data: output_string type string.
field-symbols: <fs>.
constants: c_tab type x value '09'.
itab-fld1 = '01'.
itab-fld2 = '02'.
itab-fld3 = '03'.
append itab.
itab-fld1 = '21'.
itab-fld2 = '22'.
itab-fld3 = '23'.
itab-fld4 = '24'.
append itab.
itab-fld1 = '31'.
itab-fld2 = '32'.
itab-fld3 = '33'.
itab-fld4 = '34'.
itab-fld5 = '35'.
append itab.
loop at itab.
clear output_string.
do.
assign component sy-index of structure itab to <fs>.
if sy-subrc <> 0 .
exit.
endif.
check not <fs> is initial.
if sy-index = 1.
output_string = <fs>.
else.
concatenate output_string <fs>
into output_string separated by c_tab.
endif.
enddo.
write:/ output_string.
endloop.
Regards,
Rich Heilman
‎2006 Jun 09 2:12 AM
my exact o/p should be.
10 20(constant)
30 40 (constant)
50 AP EC 30...
TD MN..
.......(variables..)
60 80(constant)
90 100(constant)
‎2006 Jun 09 2:15 AM
hi
are your data reside in an internal table?
if so use the code sample given by Rich.
Cheers,
Abdul Hakim
‎2006 Jun 09 2:21 AM
thats what i want to ask...
first 2 rows are constants..can i keep them in internal table...
3rd row i have to keep in internal table because the values may vary ...it may go upto 10 rows..or more
and last 2 rows are constants...
please help me....
‎2006 Jun 09 2:24 AM
‎2006 Jun 09 2:24 AM
hi
you can keep.
jus define an internal table with the maximum number of columns you are expecting to store the values and then play with it..
Cheers,
Abdul Hakim
‎2006 Jun 09 2:44 AM
Hi,
but some fields are integer type...it is displaying error if i am using concatenate statment...
‎2006 Jun 09 2:48 AM
‎2006 Jun 09 2:55 AM
thanks...
but values i will be getting from the standard table fields...how to convert integer values to C.
and moreover in my o/p every field is seperated by #????
why so?????
Thanks in advance
‎2006 Jun 09 3:13 AM
Please help me out......
why fields are separeted by # i want to be separetd by tab space and if any field is having null value it should separetd by tab space...i.e, if num2 has null value then num1 and num3 should be separetd by 3 tab spaces...correct????
‎2006 Jun 09 3:15 AM
When you are retreiving the values from the table, you can put them into internal table which is TYPEd like the standard table. Then loop at that table when building the ITAB which will have all fields as character moving the TYPE I fields to the TYPE C fields.
Loop at istab.
clear itab.
itab-fld1 = istab-ifield. " Move from TYPE I to TYPE C
append itab.
Endloop.Regards,
Rich Heilman
‎2006 Jun 09 3:19 AM
Ok, the # represents the TAB. I was assuming that the fields in the string will all be filled except the last ones in the string. If not, we have some more work to do.
You will want to remove the line of code that says.
CHECK not <fs> is initial.
When you do this, it will allow to put a tab when a field is blank. But now you will have TABs at the end of the string. This may be ok for you. If not you will need to remove them. There are a couple ways of doing so. If you are writing this output string to a .txt file there is really no need to remove them.
Regards,
Rich Heilman
‎2006 Jun 09 3:24 AM
i didnt got the code u wrote
Loop at istab.
clear itab.
itab-fld1 = istab-ifield. " Move from TYPE I to TYPE C
append itab.
Endloop.
??????????
I AM MOVING THE O/P AUTOMATICALLY(BACKGROUND) TO APPLICATION SERVER (AL11 TCODE)...
so what all changes do i need to do....just brief it
Thanks in advance....
‎2006 Jun 09 3:29 AM
This code....
select * into table istab
from some_table
where.....
Loop at istab.
clear itab.
itab-fld1 = istab-ifield. " Move from TYPE I to TYPE C
append itab.
Endloop.
Is just showing you how you can take the data from the database, and move it to your output internal table, you can move the TYPE I field from your your internal tabe which the data came from DB to your output internal table. Then all of the fields will by TYPE C and you can use the concatenate statement.
Since you are writing this to app server, you may not need to remove the trailing tabs.
If you do, this may work.
shift output_string right deleting trailing c_tab.
shift output_string left deleting leading space.You can write to the app server using OPEN DATASET, READ DATASET, and CLOSE DATASET.
Regards,
Rich Heilman
‎2006 Jun 09 1:03 PM
‎2006 Jun 09 6:53 PM
Hi rich,
i have used concatenate statements for all the rows...
but for the row 3 the lines may vary..it may go to n lines...
just think that o/p file first 2 rows and last 2 rows are constant and middle rows will contain data based on he PO number...
can i use the same concatenate statment for 3 row??
so i have to keep in loop or other...
concatenate r_id
sp_n
c_date
c_time
f_format
f_version
into output_string1
separated by tab.
concatenate r_id1
o_id
o_name
into output_string2
separated by tab.
***********************3rd row
concatenate r_id2
o_id1
num12
num23
into output_string3
separated by tab.
***********************
concatenate r_id3
o_id2
o_name1
d_r_count
into output_string4
separated by tab.
concatenate r_id4
e_r_count
file_record_count
write 😕 output_string1.
write 😕 output_string2.
write 😕 output_string3.
write 😕 output_string4.
write 😕 output_string5.
it is interface program..so it runs in background..and file will be created in AL11.when i execute report the o/p gives as seperated by #..will it be tab space in AL11?
‎2006 Jun 09 6:56 PM
hi
you can use concatenate no issues.
indicates tab.
Cheers,
Abdul Hakim
Mark all useful answers..
‎2006 Jun 09 7:03 PM
‎2006 Jun 09 7:05 PM
‎2006 Jun 09 7:07 PM
hi,
but in the code the 3rd will be displayed only once..
i want the data to be displayed based on some conditions..
e.g: lfa1-name1 = 'tom'
so to display all the PO based on tom..it will 10(suppose)..
but i am getting only one record...
how to keep loop based on what conditions...
Thanks in advance
‎2006 Jun 09 7:12 PM
Hi,
the o/p will be for 3 rd row..
1000004567 45 v1 b1...
1000000569 98 j1 b1..
1000000023 67 m1 n1....
any how first 2 and last 2 rows are constants...so we can put direct concatenate statment..but how to concatenate 3 rd row and how to keep loop?do i need to take internal table..
please explain by giving code or insert in above code..
Thanks in advance
‎2006 Jun 09 7:19 PM
Let us say you write out the first two rows. You have the POs related to TOM in an internal table. You loop at this internal table and write all of them out. After the loop, you write the last two rows. So essetially your logic will be as follows.
row1
row2
loop at itab.
write itab information.
endloop.
row-last-but-one.
row-last.
‎2006 Jun 09 7:19 PM