‎2009 Mar 20 8:40 AM
Hi all,
I have an internal table it_ekpo with the following data :
EBELN EBELP MATNR MENGE
5000000023 0001 test 5
I have another internal table it_ekbe with the following data :
EBELN EBELP BELNR BUZEI DMBTR
5000000023 00001 4900002212 0001 804.04
5000000023 00001 4900002213 0001 804.04
My requirement is to club these 2 internal tables and get a single ALV Internal table as output to generate ALV report.
I tried to modify the it_ekpo by transporting BELNR and DMBTR to it_ekpo. Since there is no differentiator to separate the two records, I am getting a single record output, instead of two records as follows :
EBELN EBELP MATNR MENGE BELNR
5000000023 0001 test 5 4900002213
BUZEI BUDAT MENGE_GI DMBTR
0001 20090317 1.000 804.04
I tried to use sy-tabix also and could not succeed.
I need your guidance in solving this problem.
Thanks in advance.
Rgds
Murali
‎2009 Mar 20 8:44 AM
HI,
Instead of modifying the it_ekpo modify the it_ekbe whcih has multiple items.
For example
EBELN EBELP MATNR MENGE
5000000023 0001 test 5
LOOP AT IT_EKBE.
READ IT_EKPO.
IF SY-SUBRC EQ 0.
MODIFY IT_EKBE with index
ENDIF.
ENDLOOP.
Modify it_ekbe with MATNR and MENGE and pass this table to ALV
EBELN EBELP MATNR MENGE BELNR BUZEI DMBTR
5000000023 00001 test 5 4900002212 0001 804.04
5000000023 00001 test 5 4900002213 0001 804.04
Or instead of getting data into two different internal table using INNER JOIN on ekpo and ekbe get the required data in one table and pass this to alv
Edited by: Avinash Kodarapu on Mar 20, 2009 2:17 PM
‎2009 Mar 20 8:44 AM
HI,
Instead of modifying the it_ekpo modify the it_ekbe whcih has multiple items.
For example
EBELN EBELP MATNR MENGE
5000000023 0001 test 5
LOOP AT IT_EKBE.
READ IT_EKPO.
IF SY-SUBRC EQ 0.
MODIFY IT_EKBE with index
ENDIF.
ENDLOOP.
Modify it_ekbe with MATNR and MENGE and pass this table to ALV
EBELN EBELP MATNR MENGE BELNR BUZEI DMBTR
5000000023 00001 test 5 4900002212 0001 804.04
5000000023 00001 test 5 4900002213 0001 804.04
Or instead of getting data into two different internal table using INNER JOIN on ekpo and ekbe get the required data in one table and pass this to alv
Edited by: Avinash Kodarapu on Mar 20, 2009 2:17 PM
‎2009 Mar 20 8:58 AM
Hi,
Use the following:
types:
begin of ty_output,
ebeln type ebeln,
ebelp type ebelp,
matnr type matnr,
menge type menge,
belnr type belnr,
buzei type buzei,
dmbtr type dmbtr,
end of ty_output.
data: wa_output type ty_output,
it_output type table of ty_output.
--
--
sort it_ekpo by ebeln ebelp.
delete adjacent duplicates from it_ekpo comparing ebeln ebelp.
sort it_ekbe by ebeln ebelp.
loop at it_ekpo into wa_ekpo.
clear wa_output.
clear wa_ekbe.
wa_output-ebeln = wa_ekpo-ebeln.
wa_output-ebelp = wa_ekpo-ebelp.
wa_output-matnr = wa_ekpo-matnr.
wa_output-menge = wa_ekpo-menge.
loop at it_ekbe into wa_ekbe where ebeln = wa_ekpo-ebeln and ebelp = wa_ekpo-ebelp.
wa_output-belnr = wa_ekbe-belnr.
wa_output-buzei = wa_ekbe-buzei.
wa_output-dmbtr = wa_ekbe-dmbtr.
append wa_output to it_output.
clear wa_ekbe.
endloop.
clear wa_ekpo.
endloop.
---
---
Then write the logic to displaying ALV output using IT_OUTPUT internal table.
Best Regards,
Suresh
‎2009 Mar 20 8:50 AM
Hi there,
you need to declare another internal table with all the fields you want in alv output.
loop at onetable.
read table <table2> with key ebeln = onetable-ebeln.
if sy-subrc = 0.
final table -field = assign corresponding field
endif.
endloop.
‎2009 Mar 20 8:50 AM
LOOP at it_ekbe .
itab- EBELN = it_ekbe-ebeln.
itab-EBELP = it_ekbe-ebelp
itab- BELNR = it_ekbe-belnr
itab- BUZEI= it_ekbe-buzei
itab- DMBTR= it_ekbe-dmbtr.
read tabvle it_ekpp with key ebelnebelp.
itab-BELNR = it_ekpo-belnr
itab-BUZEI= it_ekpo-buzei
itab- DMBTR= it_ekpo-dmbtr.
append itab.
clear itab.
endloop.
reg
Ramya
‎2009 Mar 20 8:50 AM
Hi murali,
loop at it_ekbe.
read table it_ekpo with key ebeln = it_ekbe-ebeln
ebelp = it_ekbe-ebelp.
if sy-subrc eq 0.
it_final-EBELN = it_ekpo-EBELN.
it_final-EBELP = it_ekpo-EBELP.
it_final-MATNR = it_ekpo-MATNR.
it_final-MENGE = it_ekpo-MENGE.
it_final-BELNR = it_ekbe-BELNR.
it_final-BUZEI = it_ekbe-BUZEI.
it_final-DMBTR = it_ekbe-DMBTR.
" (similarally other fields).
append it_final.
clear: it_final.
endif.
endloop.
Reg,
Sachin
‎2009 Mar 20 8:50 AM
Hi,
Try to modify it_ekbe because it has two records and u will get two records..
Regards,
Nagaraj
‎2009 Mar 20 8:58 AM
Hi,
You already have two internal tables it_ekpo and it_ekbe.
Create an internal table with all the fields to be displayed in ALV Grid (say it_final).
Use:
sort it_ekpo by ebeln ebelp.
sort it_ekpe by ebeln ebelp.
loop at it_ekbe.
it_final-ebeln = it_ekbe-ebeln.
it_final-ebelp = it_ekbe-ebelp.
it_final-belnr = it_ekbe-belnr.
it_final-buzei = it_ekbe-buzei.
it_final-dmbtr = it_ekbe-dmbtr.
read table it_ekpo with key ebeln = it_ekbe-ebeln
ebelp = it_ekbe-ebelp.
if sy-subrc = 0.
it-final-matnr = it-ekpo-matnr.
it-final-menge = it-ekpo-menge.
endif.
append it_final.
clear it_final.
clear it_ekpo.
clear it_ekbe.
endloop.
But for this you need to make sure that internal table it_ekpo doesnt contains duplicates for combination of ebeln and ebelp
Or you can use JOIN on these database table to fetch the records into a single internal table.
Hope this helps you.
Regards,
Tarun
‎2009 Mar 20 9:40 AM
Hi,
Crete another final interrnal table with the fields
required from two table and then assing the corresponding fields from two itab to final itab.
see the code.
loop at it_ekbe.
read table it_ekpo with key ebeln = it_ekbe-ebeln
ebelp = it_ekbe-ebelp.
if sy-subrc eq 0.
it_fintab-EBELN = it_ekpo-EBELN.
it_fintab-EBELP = it_ekpo-EBELP.
it_fintab-MATNR = it_ekpo-MATNR.
it_fintab-MENGE = it_ekpo-MENGE.
it_fintab-BELNR = it_ekbe-BELNR.
it_fintab-BUZEI = it_ekbe-BUZEI.
it_fintab-DMBTR = it_ekbe-DMBTR.
append it_fintab.
endif.
endloop.
Regards
Rajendra