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: 

*bold* Doubt in alv

Former Member
0 Kudos

Hi friends i am new to sap.

I have a querry in alv.In this report i only get 3 columns in the output [fname,dept and age] whereas location ,eid doesn't comes.i

tried to increase the occurs 5 to 10 ,but it did't worked .

Any suggestion please ??

REPORT zalvreport .

TABLES: zemp.

DATA: BEGIN OF t_report OCCURS 5,

name LIKE zemp-fname,

age LIKE zemp-age,

deprt LIKE zemp-dept,

local LIKE zemp-location,

empid like zemp-eid,

END OF t_report.

TYPE-POOLS: slis.

DATA t_fcat TYPE slis_t_fieldcat_alv.

DATA: d_repid LIKE sy-repid.

SELECT-OPTIONS: s_name FOR zemp-fname .

START-OF-SELECTION.

SELECT * FROM zemp WHERE fname IN s_name.

MOVE: zemp-fname TO t_report-name,

zemp-age TO t_report-age,

zemp-location to t_report-local,

zemp-dept TO t_report-deprt,

zemp-eid TO t_report-empid.

APPEND t_report.

ENDSELECT.

IF sy-subrc NE 0.

WRITE 'No data found'.

EXIT.

ENDIF.

d_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = d_repid

i_internal_tabname = 'T_REPORT'

i_inclname = d_repid

CHANGING

ct_fieldcat = t_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

WRITE: / 'Error:',sy-subrc,

'when Create Field Catalog'.

EXIT.

ENDIF.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = d_repid

it_fieldcat = t_fcat

TABLES

t_outtab = t_report

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE: / 'Error:',sy-subrc,

'when Call ALV List Display'.

EXIT.

ENDIF.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

use the select statment.

see this exapmle

Select * from mseg INTO TABLE I_DOC WHERE MBLNR = I_TAB-MBLNR.

IF SY-SUBRC EQ 0 .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'I_DOC'

I_STRUCTURE_NAME = 'MSEG'

CHANGING

CT_FIELDCAT = I_FIELDCAT1

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

Regards,

priya

5 REPLIES 5

Former Member
0 Kudos

hi,

use the select statment.

see this exapmle

Select * from mseg INTO TABLE I_DOC WHERE MBLNR = I_TAB-MBLNR.

IF SY-SUBRC EQ 0 .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'I_DOC'

I_STRUCTURE_NAME = 'MSEG'

CHANGING

CT_FIELDCAT = I_FIELDCAT1

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

Regards,

priya

Former Member
0 Kudos

Hi,

try this in bold and try to log off and log on again if it doesnt work

1.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = d_repid

i_bypassing_buffer = 'X'

i_internal_tabname = 'T_REPORT'

i_inclname = d_repid

CHANGING

ct_fieldcat = t_fcat

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

2.

if the above doesnt work, then build the fieldcatalog manually

DATA t_fcat TYPE slis_t_fieldcat_alv,

w_fcat type slis_fieldcat_alv.

w_fcat-fieldname = 'NAME'.

w_fcat-tabname = 'T_REPORT'

append w_fcat to i_fcat.

clear w_fact.

w_fcat-fieldname = 'AGE'.

w_fcat-tabname = 'T_REPORT'

append w_fcat to i_fcat.

clear w_fact.

w_fcat-fieldname = 'EMPID'.

w_fcat-tabname = 'T_REPORT'

append w_fcat to i_fcat.

clear w_fact.

w_fcat-fieldname = 'LOCATION'.

w_fcat-tabname = 'T_REPORT'

append w_fcat to i_fcat.

clear w_fact.

w_fcat-fieldname = ''.

w_fcat-tabname = 'T_REPORT'

append w_fcat to i_fcat.

clear w_fact.

0 Kudos

Instead of passing the internal table name and prog. name in FM REUSE_ALV_FIELDCATALOG_MERGE , pass DDIC structure name (parameter I_STRUCTURE_NAME) in your case it is zemp. And after this FM call put a break point and check whether field catalog table t_fcat is populated properly or not.

Also check whether FM REUSE_ALV_LIST_DISPLAY interface parametrs are populated properly or not by passing I_INTERFACE_CHECK = 'X' when calling this FM.

Regards,

Joy.

Former Member
0 Kudos

hi lokesh

here is some information for the FM 'REUSE_ALV_FIELDCATALOG_MERGE'

Create field catalog from dictionary structure or internal table

Supports the creation of the field catalog for the ALV function modules based either on a structure or table defined in the ABAP Data Dictionary, or a program-internal table.

The program-internal table must either be in a TOP Include or its Include must be specified explicitly in the interface.

The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:

Performance is affected since the code of the table definition must always be read and interpreted at runtime.

Dictionary references are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.

If the field catalog contains more than 90 fields, the first 90 fields are output in the list by default whereas the remaining fields are only available in the field selection.

If the field catalog is passed with values, they are merged with the 'automatically' found information.

so it will be better for u if u create Field catalog manually as described above in this u have more hold of catalog creation

Cheers

Snehi Chouhan

Former Member
0 Kudos

thanks for all your replys