Application Development 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: 

ALV PRoblem

former_member196601
Active Participant
0 Kudos

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....

1 ACCEPTED SOLUTION

gopi_narendra
Active Contributor
0 Kudos

Just change I_SALES into capital letters

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = repid
i_internal_tabname = 'I_SALES' " I_SALES in capital letters
* I_STRUCTURE_NAME = i_sales
i_inclname = repid
I_BYPASSING_BUFFER = 'X'
CHANGING
ct_fieldcat = fieldcat[].

Regards

Gopi

6 REPLIES 6

gopi_narendra
Active Contributor
0 Kudos

Just change I_SALES into capital letters

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = repid
i_internal_tabname = 'I_SALES' " I_SALES in capital letters
* I_STRUCTURE_NAME = i_sales
i_inclname = repid
I_BYPASSING_BUFFER = 'X'
CHANGING
ct_fieldcat = fieldcat[].

Regards

Gopi

0 Kudos

I TRIED CHANGING IT TO CAPS BUT STILL IAM GETTING THE SAME ERROR.....

0 Kudos

Hi,

the problem was u crossed the limit of characters that can be written in a single line.divide that select statements into many smaller lines.ur select statement is little too big to be written straight.breake into smaller lines as i have done. and i have made the code bold where i have changed

REPORT ZALVEXAMPLE.

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 100,

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 a~erdat

abstdk anetwr a~waerk

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 )

<b>WHERE akunnr IN sold_to AND avbeln IN sales_d AND b~matnr </b> "changed

IN material AND avkorg IN sales_o AND avtweg 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

<b>i_internal_tabname = 'I_SALES'</b> "change

  • I_STRUCTURE_NAME = i_sales

i_inclname = repid

I_BYPASSING_BUFFER = 'X'

CHANGING

ct_fieldcat = fieldcat[]

.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

<b> I_CALLBACK_PROGRAM = REPID</b> "change

it_fieldcat = fieldcat[]

TABLES

t_outtab = i_sales.

ENDFORM. " 150_alv_display

<b>reward if helpful</b>

Regards,

sanjeev

0 Kudos

STILL IAM FACING THE SAME ERROR....

0 Kudos

HI,

if u have any code line in ur program(including comment lines)

more than 72 char length it will give that error.to get rid of this u just truncate the larger lines in the code into different lines.

rgds,

bharat.

0 Kudos

REWARDED WITH THANKS.....