Hi Gurus
My requirement is to print the sales output using alv. I have used inner join of 3 tables n i have used the FM 'reuse_alv_fieldcatalog_merge', iam not very much familiar with this function module, i jsu heard that its used when we need to join 2 or more tables n display in alv.
My code looks as follows..
&----
*& Report ZIND_CUSTOMER_SALES_ALV
*&
&----
*&
*&
&----
REPORT zind_customer_sales_alv.
TYPE-POOLS : slis.
DATA: fieldcat TYPE slis_t_fieldcat_alv with header line.
DATA: repid TYPE sy-repid.
repid = sy-repid.
TABLES : vbak, vbap, kna1.
DATA : BEGIN OF i_sales OCCURS 0,
kunnr LIKE vbak-kunnr, "Sold-to party
vbeln LIKE vbak-vbeln, "Sales Document
vkorg LIKE vbak-vkorg, "Sales Organization
vtweg LIKE vbak-vtweg, "Distribution Channel
erdat LIKE vbak-erdat, "Date on Which Record Was Created
bstdk LIKE vbak-bstdk, "Customer purchase order date
netwr LIKE vbak-netwr, "Net Value of the Sales Order in Document Currency
waerk LIKE vbak-waerk, "SD Document Currency
matnr LIKE vbap-matnr, "Material Number
spart LIKE vbap-spart, "Division
aufnr LIKE vbap-aufnr, "Order Number
posnr LIKE vbap-posnr, "Sales Document Item
lfrel LIKE vbap-lfrel, "Item is relevant for delivery
zmeng LIKE vbap-zmeng, "Target quantity in sales units
meins LIKE vbap-meins, "Target quantity UoM
name1 LIKE kna1-name1, "Customer Name
maktx LIKE makt-maktx, "Material Description
END OF i_sales.
SELECT-OPTIONS : sold_to FOR vbak-kunnr,
sales_d FOR vbak-vbeln,
material FOR vbap-matnr,
sales_o FOR vbak-vkorg,
dist_ch FOR vbak-vtweg,
division FOR vbap-spart,
date FOR vbak-erdat.
PERFORM 100_internal_table_fetch.
PERFORM 150_alv_display.
&----
*& Form 100_INTERNAL_TABLE_FETCH
----
FORM 100_internal_table_fetch .
SELECT DISTINCT akunnr avbeln avkorg avtweg aerdat abstdk anetwr awaerk
bmatnr bspart baufnr bposnr blfrel bzmeng b~meins
cname1 dmaktx INTO CORRESPONDING FIELDS OF TABLE i_sales FROM ( vbak AS a
INNER JOIN vbap AS b ON avbeln = bvbeln
INNER JOIN kna1 AS c ON akunnr = ckunnr
INNER JOIN makt AS d ON bmatnr = dmatnr )
WHERE akunnr IN sold_to AND avbeln IN sales_d AND bmatnr IN material AND avkorg IN sales_o AND a~vtweg IN dist_ch
AND bspart IN division AND aerdat IN date.
SORT i_sales BY name1.
ENDFORM. " 100_INTERNAL_TABLE_FETCH
&----
*& Form 150_alv_display
----
FORM 150_alv_display .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = repid
i_internal_tabname = 'i_sales'
I_STRUCTURE_NAME = i_sales
i_inclname = repid
I_BYPASSING_BUFFER = 'X'
CHANGING
ct_fieldcat = fieldcat[]
.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcat[]
TABLES
t_outtab = i_sales.
ENDFORM. " 150_alv_display
Iam getting a runtime error that abap prog lines are wider than the internal table...
can anyone help me in this....