2013 Feb 14 11:44 AM
Hi,
I have very limited experience of coding in ABAP
Basically I want to take dataset from a database table, and manipulate it, and output this into a report in SQ01
Is this possible?
Any help would be greatly appreciated
Thanks
2013 Feb 24 1:55 PM
Hi Brian,
I propose to consider a similar example.
Query based on join table KNA1 with KNVK .
There are 3 lines being generated because there are 3 telephone numbers
per customer 13023 in KNVK.
In "Extras" we add an abap code.
We use fields “Telephone 2” and “Telebox” to place the second and third telephone numbers
on the first line and skip other lines with statement "CHECK 0 = 1".
.
Finally we have
Regards
Boris
2013 Feb 14 12:01 PM
Hi Brian,
if you are limited in ABAP (or SQL) try the SQVI transaction. It's more simple.
If you need help maybe give us the requierment.
Regards
Fred
2013 Feb 14 12:07 PM
Basically I want to take a field from a row, add that field to a different row, then delete the entire row... Hope that makes sense?
This is the code im working with...
clear ADR2-TEL_EXTENS.
DATA: countTelephone TYPE int4.
SELECT COUNT( DISTINCT TEL_NUMBER ) FROM ADR2
INTO countTelephone
WHERE ADDRNUMBER = KNA1-ADRNR.
if countTelephone > 1.
DATA TEMP_TABLE LIKE ADR2 OCCURS 10 WITH HEADER LINE.
LOOP AT TEMP_TABLE.
DELETE TEMP_TABLE WHERE CONSNUMBER = '002'.
ADR2-TEL_EXTENS = ADR2-TEL_NUMBER.
ENDLOOP.
endif.
2013 Feb 14 12:20 PM
(i have not check the code)
for me it's better to do like that :
types : begin of ts_adr2 occurs ,
addrnumber type ... ,
tel_number type ... ,
count type i ,
end of ts_adr2 ,
tt_adr2 type table of ts_adr2.
data : it_adr2 type tt_adr2 ,
it_temp type tt_adr2 ,
is_adr2 type ts_adr2.
select addrnumber tel_number
into table it_adr2
from adr2
where ...
sort it_adr2.
loop at it_adr2 into is_adr2.
move 1 to is_adr2-count.
condense is_adr2 to it_temp.
endloop.
you will have into the table IT_TEMP the count set with the number of different addrnumber / tel_numbeR.
(after I'm not sure to understand what you expected to delete)
Fred
2013 Feb 15 7:42 PM
Brian Murphy wrote:
Basically I want to take a field from a row, add that field to a different row, then delete the entire row... Hope that makes sense?
Not really... If you look at the report generated for a query, you'll see that it's basically one giant SELECT... ENDSELECT. There is no internal table to manipulate. Everything is processed one line at a time. So the coding options are limited by this design.
2013 Feb 19 12:02 PM
Thanks for the help.
This is what I currently have...
KNA1 linked with ARD2 on the Address Number field.
I want to have 1 line per customer - but there are 2 lines being generated because there are 2 telephone numbers per customer.
I need to take the second telephone number and add it to a different field on the first line
Can I use a Group By to get rid of the second line?
Thanks
2013 Feb 19 1:08 PM
You can't make that with a simple query, with an abap code it's simple.
we could help you to write this code
Fred
2013 Feb 19 1:58 PM
What would the ABAP code be?
Please bear in mind that this is an SQ01 report
Thanks
2013 Feb 24 1:55 PM
Hi Brian,
I propose to consider a similar example.
Query based on join table KNA1 with KNVK .
There are 3 lines being generated because there are 3 telephone numbers
per customer 13023 in KNVK.
In "Extras" we add an abap code.
We use fields “Telephone 2” and “Telebox” to place the second and third telephone numbers
on the first line and skip other lines with statement "CHECK 0 = 1".
.
Finally we have
Regards
Boris
2013 Feb 28 5:00 PM
Thank you very much for posting, very helpful!
Can I please ask one or two questions with regards to your code?
Would you be able to explain what the following peices of code are:
Thank you
2013 Mar 03 7:54 AM
Hi Brian,
I use " READ TABLE it_knvk .... " to determine the first line for each customer among
all the lines which query supplies for every customer.
" sy-subrc NE 0 " means that we have first line for customer.
In this case the internal table "it_knvk" does not have records containing phone numbers of the customer and I select all phone numbers from database table KNVK into internal table "it_knvk".
After that in " Loop ... " sy-tabix give the number of line in internal table " it_knvk "
making it possible to place all telephone numbers on the first line .
Regards
Boris