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

alv report

Former Member
0 Likes
2,522

Hi folks,

i am developing an ALV report in ABAP in which i want to use field MATNR CHARG MAKTX .BWART,

Now my query is iam using the FIELDS MATNR CHARG MAKTX where BWART = '951' .

Now i want to fetch again the same fields where BWART = '952'.

How di i use it as if i declare the same fields in the it_mat Structure it will show an error that field already exists.

Pl. help

1 ACCEPTED SOLUTION
Read only

former_member185116
Active Participant
0 Likes
2,495

Hi pal,

write your code like below..

data : begin of wa_itab,

         matnr type mara-matnr,

         charg type charg,

         maktx type maktx,

         bwart type bwart          " iam not sure of the table here...

         end of wa_itab.

data : it_itab like table of wa_itab.

select matnr charg maktx bwart from table(write u r table name here)

                                               into table it_itab

                                               where bwart in ('951' , '952').

       

regards,

vinay..

Hi folks,

i am developing an ALV report in ABAP in which i want to use field MATNR CHARG MAKTX .BWART,

Now my query is iam using the FIELDS MATNR CHARG MAKTX where BWART = '951' .

Now i want to fetch again the same fields where BWART = '952'.

How di i use it as if i declare the same fields in the it_mat Structure it will show an error that field already exists.

Pl. help

13 REPLIES 13
Read only

former_member196331
Active Contributor
0 Likes
2,495

hello

If you want to maintain different column.

create one more field Structure and fetch the same way like BWART = '951'

In main table create one more field as BWART1 form 952.

Update the main table using Read Statement.

Hope you understood.

If you want to combine 951 and 952 No problem same query you can use but in operator you have to use select * from table where bwart in required types.

Hope you understood.

Read only

0 Likes
2,495

How do i update the table using 'Read' statement ? do i write in inside the loop ?

Read only

0 Likes
2,495

Yes. Loop at main table in the loop using Read statement  you need read the child table,

means for 952 you already fetched some data  and put it in some table. From that table.

you have to maintain one same key field from the Two tables. they only update the main table.

Just check read statement and  update(modify) in forum so many examples are there. You can check it.

Read only

0 Likes
2,495

I declared another structure IT_BLEND  in which i took the same fields as MATNR1 CHARG1 MAKTX1 & BWART1 .

I fetched these fields using select statement where bwart = 952 same as i fetched for bwart = 951.

below is the code.

SELECT a~MATNR a~CHARG a~MBLNR a~BUDAT_MKPF b~MAKTX BWART FROM MSEG AS a INNER JOIN MAKT AS b ON a~MATNR = b~MATNR INTO CORRESPONDING FIELDS OF TABLE it_blend
WHERE BWART = '952' AND BUDAT_MKPF in p_date AND charg in p_batch.


now inside the loop .

how do i write for the read statement .

it_blend is my new structure(for 952) n& it_mat is my old structure(951).

Read only

0 Likes
2,495

First Sort the both tables.

Actually i can not write the total logic.

Because i dont know the tables are with header or without header. but

Sequence of steps i will tell you.

In First table you have to maintain two fields bwart for 951 and bwart1 for 952

Ok

First you already fetched for 951 So, bwart field is filled. no problem

Now

you need fined key field for both the tables. one field should be match between two tables,

whether it is matnr or docnot " Field should not be repeated, it should be unique.

Loop at first table into workarea1

read table from  second table into workarea2 with key matnr = workarea1-matnr.

"in the above by using workarea1-matnr  you are checking the same in table2.

if sy-surbc eq 0.

workarea1-bwart1 =  'workarea2-bwtar


"In above statement Second table bwart value you are assigning to the first table

work area.

modify firstable from workarea1.

"Modifying the first table from the first table workarea.

endif.

endloop.

Hope you understood.

Read only

0 Likes
2,495

ok will do that

thanks .

Read only

former_member185116
Active Participant
0 Likes
2,496

Hi pal,

write your code like below..

data : begin of wa_itab,

         matnr type mara-matnr,

         charg type charg,

         maktx type maktx,

         bwart type bwart          " iam not sure of the table here...

         end of wa_itab.

data : it_itab like table of wa_itab.

select matnr charg maktx bwart from table(write u r table name here)

                                               into table it_itab

                                               where bwart in ('951' , '952').

       

regards,

vinay..

Read only

0 Likes
2,495

THANKS for the help Vinay.

got my o/p

Read only

0 Likes
2,495

i got the o/p correct but the o/p is coming in the next line .

what i want is the values for 951 in  the cloumn n for 952 , the values should come corresponding to the 951 values.

Read only

0 Likes
2,495

Could you plz tell me

Format1

col1     Col2

951

951

952

952

Format2

col1     col2

951      952

951      952

May i know which format you need.

Read only

0 Likes
2,495

format2

Read only

0 Likes
2,495

In that case

How the below query will be helpful.

select matnr charg maktx bwart from table(write u r table name here)

                                               into table it_itab

                                               where bwart in ('951' , '952').

If you use like above. different lines will come like

951

952

951

952

Because of that reason i said you have to maintain superstate table for 952 then update the main table.

I already given some solution. based on that you need  to write the logic.

I hope you already got the answer. You were closed the post too.

Hope you understood.

Read only

0 Likes
2,494

yes if i use bwart in ('951','952') then it gives me the o/p but in different lines.

i will try the other suggested way. thanks