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 GRID

Former Member
0 Kudos

Hi,

Requirment is am using function module REUSE_ALV_FIELDCATALOG_MERGE to populate the data from the internal table . I have some fields in the internal table which shouldn't be displayed in the alv grid , How do i supress the fields using the same function module .

2) I have a de-allocate button on the ALV grid , on click

of this alv its pops up a message TYPE (I) (goods movement) when i click on 'x' on the pop message it not comming back to the alv indeed its going ahaed with the deallocation process.

Any suggestions and sample code on this will be helpfull..

Thanks in Advance

vind.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

1. If you have some fields in the internal table, then I assume those fields are also in the field catalog. In that, set the NO_OUT to 'X', those fields will not be displayed on the output.

2. It depends on your logic. Looks like your logic with IF condition, and its continuing with the process. Please post the code here

Regards,

Ravi

Note : Please mark the helpful answers

7 REPLIES 7

Former Member
0 Kudos

Hi,

1. If you have some fields in the internal table, then I assume those fields are also in the field catalog. In that, set the NO_OUT to 'X', those fields will not be displayed on the output.

2. It depends on your logic. Looks like your logic with IF condition, and its continuing with the process. Please post the code here

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

1) I have a de-allocate button on the ALV grid , on click

of this alv its pops up a message TYPE (I) (goods movement) when the user dont want to go ahead he click on 'x' on the pop message , it not comming back to the alv indeed its going ahaed with the deallocation process.

my code is like this :

FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&DEALL'.

  • Message for reselection of lines

IF itab_display-kalab LE 0.

MESSAGE i101(/..../pp).

EXIT.

ELSE.

*message for goods movement

IF itab_display-kalab GT 0.

MESSAGE i237(/....../pp).

ENDIF.

ENDIF.

  • Check for the allocation quantity

  • Clear itab_display.

Loop at itab_display where select = 'X'.

read table itab_display index sy-tabix.

Any suggestions and sample code on this will be helpfull..

0 Kudos

Well, the logic looks good to me. Did you try debugging and saw why its going beyond the EXIT statement.

You probably can try STOP statement.

Regards,

Ravi

Note : Please mark the helpful answers and close the thread if the issue is resolved.

Former Member
0 Kudos

Hi Vind,

When you are creating the field catalog for that particular field set no_out = 'X'.The field will not be shown in the ALV display

former_member181962
Active Contributor
0 Kudos

Have another internal table with with only the fields to be displayed and pass that to the function module.

or

Manually build your field catalog instead of using the FM.

Regards,

Ravi

Former Member
0 Kudos

Hai Vinay

Go through the following Code

&----


*& Report ZALV_GRID *

*& *

&----


*& *

*& *

&----


REPORT ZALV_GRID NO STANDARD PAGE HEADING

LINE-SIZE 150

LINE-COUNT 60(4)

MESSAGE-ID Z00.

*..Type Definitions for ALV Report

TYPE-POOLS SLIS.

*..Includes

*for ICONs

*INCLUDE <ICON>.

----


  • Table/Structure declarations. *

----


TABLES: MARA,

MARC,

T134.

----


  • Internal Tables declaration *

----


*..To store Basic Report fields

DATA:BEGIN OF IT_MARA OCCURS 0,

MATNR LIKE MARA-MATNR,

MTART LIKE MARA-MTART,

MATKL LIKE MARA-MATKL,

MEINS LIKE MARA-MEINS,

NTGEW LIKE MARA-NTGEW,

END OF IT_MARA.

*DATA:BEGIN OF IT_MATKL OCCURS 0,

  • MATKL LIKE T023-MATKL,

  • WGBEZ LIKE T023-WGBEZ,

  • END OF IT_MATKL.

DATA:BEGIN OF IT_MARC OCCURS 0,

WERKS LIKE MARC-WERKS,

LADGR LIKE MARC-LADGR,

MTVFP LIKE MARC-MTVFP,

DISPR LIKE MARC-DISPR,

DISMM LIKE MARC-DISMM,

DISPO LIKE MARC-DISPO,

END OF IT_MARC.

----


  • ALV Type declaration *

----


DATA:V_NO_DATA TYPE C.

----


  • ALV Type declaration *

----


DATA:V_REPID TYPE SYREPID.

DATA: IT_FIELDCATALOG_MARA TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCATALOG_MARA TYPE SLIS_FIELDCAT_ALV,

IT_FIELDCATALOG_MARC TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCATALOG_MARC TYPE SLIS_FIELDCAT_ALV,

IT_FIELDCATALOG_MATKL TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCATALOG_MATKL TYPE SLIS_FIELDCAT_ALV,

WA_LAYOUT TYPE SLIS_LAYOUT_ALV,

IT_EVENTS TYPE SLIS_T_EVENT,

WA_EVENTS TYPE SLIS_ALV_EVENT,

WA_KEYINFO TYPE SLIS_KEYINFO_ALV.

----


  • Selection Screen. *

----


SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.

SELECT-OPTIONS: S_MATNR FOR MARA-MATNR ,

S_MTART FOR MARA-MTART .

SELECTION-SCREEN END OF BLOCK B1.

----


  • Event:Initialization *

----


INITIALIZATION.

*Report Name

V_REPID = SY-REPID.

----


  • AT Selection Screen. *

----


AT SELECTION-SCREEN.

----


  • Event: Start-of-Selection *

----


START-OF-SELECTION.

PERFORM FETCH_DATA.

----


  • Event: End-of-Selection *

----


END-OF-SELECTION.

IF V_NO_DATA = ''.

MESSAGE I010 WITH 'NO DATA TO DISPLAY ! '.

EXIT.

ELSE.

PERFORM FILL_FIELDCAT_MARA.

  • PERFORM FILL_FIELDCAT_MAKT.

PERFORM FILL_FIELDCAT_MARC.

PERFORM FILL_LAYOUT.

PERFORM CALL_ALV_INIT.

PERFORM ADD_LISTS.

PERFORM DISPLAY_BLOCK_LIST.

ENDIF.

//////////////////////////////////////////////////////////////////////

*

  • FORM DEFINITIONS *

*

*//////////////////////////////////////////////////////////////////////

&----


*& Form FETCH_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FETCH_DATA.

SELECT MATNR

MTART

MATKL

MEINS

NTGEW

INTO CORRESPONDING FIELDS OF TABLE IT_MARA

FROM MARA

WHERE MATNR IN S_MATNR

AND MTART IN S_MTART.

IF SY-SUBRC <> 0.

V_NO_DATA = ''.

ELSE.

V_NO_DATA = 'X'.

SELECT WERKS

LADGR

MTVFP

DISPR

DISMM

DISPO

INTO CORRESPONDING FIELDS OF TABLE IT_MARC

FROM MARC

WHERE MATNR IN S_MATNR.

ENDIF.

ENDFORM. " FETCH_DATA

*

&----


*& Form FILL_FIELDCAT_MARA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_FIELDCAT_MARA.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

  • I_INTERNAL_TABNAME =

I_STRUCTURE_NAME = 'IT_MARA'

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = V_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCATALOG_MARA

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT_FIELDCATALOG_MARA INTO WA_FIELDCATALOG_MARA.

CASE WA_FIELDCATALOG_MARA-FIELDNAME.

WHEN 'MATNR'.

WA_FIELDCATALOG_MARA-COL_POS = '1'.

WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARA-SELTEXT_L = 'Material NO'.

WHEN 'MTART'.

WA_FIELDCATALOG_MARA-COL_POS = '2'.

WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Type'.

WHEN 'MATKL'.

WA_FIELDCATALOG_MARA-COL_POS = '3'.

WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARA-SELTEXT_L = 'Mat Group'.

WHEN 'MEINS'.

WA_FIELDCATALOG_MARA-COL_POS = '4'.

WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARA-SELTEXT_L = 'Measure Unit'.

WHEN 'NTGEW'.

WA_FIELDCATALOG_MARA-COL_POS = '5'.

WA_FIELDCATALOG_MARA-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARA-SELTEXT_L = 'Net Wt'.

WA_FIELDCATALOG_MARA-DO_SUM = 'X'.

ENDCASE.

MODIFY IT_FIELDCATALOG_MARA FROM WA_FIELDCATALOG_MARA INDEX SY-TABIX.

ENDLOOP.

ENDFORM. " FILL_FIELDCAT_MARA

&----


*& Form FILL_FIELDCAT_MARC

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_FIELDCAT_MARC.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = V_REPID

I_INTERNAL_TABNAME = 'IT_MARC'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = V_REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = IT_FIELDCATALOG_MARC

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

LOOP AT IT_FIELDCATALOG_MARC INTO WA_FIELDCATALOG_MARC.

CASE WA_FIELDCATALOG_MARC-FIELDNAME.

WHEN 'WERKS'.

WA_FIELDCATALOG_MARC-COL_POS = '1'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'PLANT NAME'.

WHEN 'LADGR'.

WA_FIELDCATALOG_MARC-COL_POS = '2'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'Loading Group'.

WHEN 'MTVFP'.

WA_FIELDCATALOG_MARC-COL_POS = '3'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '20'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'Checking group'.

WHEN 'DISPR'.

WA_FIELDCATALOG_MARC-COL_POS = '4'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP PROFILE'.

WHEN 'DISMM'.

WA_FIELDCATALOG_MARC-COL_POS = '5'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP TYPE'.

WHEN 'DISPO'.

WA_FIELDCATALOG_MARC-COL_POS = '6'.

WA_FIELDCATALOG_MARC-OUTPUTLEN = '15'.

WA_FIELDCATALOG_MARC-SELTEXT_L = 'MRP CONTROLLER'.

ENDCASE.

MODIFY IT_FIELDCATALOG_MARC FROM WA_FIELDCATALOG_MARC INDEX SY-TABIX.

ENDLOOP.

ENDFORM. " FILL_FIELDCAT_MARC

&----


*& Form FILL_FIELDCAT_MAKT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_FIELDCAT_MAKT.

ENDFORM. " FILL_FIELDCAT_MAKT

&----


*& Form CALL_ALV_INIT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM CALL_ALV_INIT.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

I_CALLBACK_PROGRAM = V_REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IT_EXCLUDING =

.

ENDFORM. " CALL_ALV_INIT

&----


*& Form ADD_LISTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM ADD_LISTS.

*ADD IT_MARA TABLE TO THE OUTPUT

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = IT_FIELDCATALOG_MARA

I_TABNAME = 'IT_MARA'

IT_EVENTS = IT_EVENTS

  • IT_SORT =

  • I_TEXT = ' '

TABLES

T_OUTTAB = IT_MARA

EXCEPTIONS

PROGRAM_ERROR = 1

MAXIMUM_OF_APPENDS_REACHED = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

**ADD IT_MARC TABLE TO THE OUTPUT

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = IT_FIELDCATALOG_MARC

I_TABNAME = 'IT_MARC'

IT_EVENTS = IT_EVENTS

  • IT_SORT =

  • I_TEXT = ' '

TABLES

T_OUTTAB = IT_MARC

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • MAXIMUM_OF_APPENDS_REACHED = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ADD_LISTS

&----


*& Form FILL_LAYOUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_LAYOUT.

WA_LAYOUT-ZEBRA = 'X'.

WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.

ENDFORM. " FILL_LAYOUT

&----


*& Form DISPLAY_BLOCK_LIST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_BLOCK_LIST.

  • WA_KEYINFO-HEADER01 = 'MATNR'.

  • WA_KEYINFO-ITEM01 = 'MATNR'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • IS_PRINT =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY_BLOCK_LIST .

Thanks & regards

Sreenivasulu P

former_member188685
Active Contributor
0 Kudos

Hi,

after you get the it_fieldcat from the FM, you need to modify the fieldcat.

loop at it_fieldcat into x_fieldcat.
if x_fieldcat-fieldname = 'ABCD'.
 x_fieldcat-no_out = 'X'.
endif.
modify it_fieldcat from x_fieldcat index sy-tabix.
endloop.

Regards

vijay