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

Former Member
0 Kudos
171

Hi Experts,

See the below code.

Here iam able to display the check box.But i am not able to select it.It is in disable mode.And also the text for checkbox 'CHEC' which i declared in structure ZSTR is not displaying in the o/p. Can any body tell me what may be the problem?

REPORT ZRALV1 .

TYPE-POOLS: SLIS.

TABLES: EKKO,EKPO.

PARAMETERS: P_EBELN LIKE EKKO-EBELN.

DATA: BEGIN OF IT_PURCHASE OCCURS 0,

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

AEDAT LIKE EKKO-AEDAT,

CHEC(1),

END OF IT_PURCHASE.

DATA: BEGIN OF IT_ITEM OCCURS 0,

MATNR LIKE EKPO-MATNR,

TXZ01 LIKE EKPO-TXZ01,

MATKL LIKE EKPO-MATKL,

MEINS LIKE EKPO-MEINS,

WERKS LIKE EKPO-WERKS,

END OF IT_ITEM.

DATA:V_CALLBACK_UCOMM TYPE SLIS_FORMNAME.

DATA: V_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

GT_LAYOUT TYPE SLIS_LAYOUT_ALV.

  • gt_sort type slis_sortinfo_alv,

  • fieldcat like line of gt_fieldcat.

DATA: V1_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

GT1_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA: PGM TYPE SY-REPID.

PGM = SY-REPID.

START-OF-SELECTION.

PERFORM GET_EKKO_DATA.

PERFORM ITEM_DATA.

PERFORM FILL_FIELDCATALOG.

PERFORM DISPLAY_DATA.

*

*&----


*

*& Form get_ekko_data

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM GET_EKKO_DATA .

SELECT EBELN BUKRS BSART AEDAT FROM EKKO INTO TABLE

IT_PURCHASE WHERE EBELN = P_EBELN.

ENDFORM. " get_ekko_data

*&----


*

*& Form item_data

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

FORM ITEM_DATA .

IF NOT IT_PURCHASE[] IS INITIAL.

SELECT MATNR TXZ01 MATKL MEINS WERKS INTO TABLE IT_ITEM FROM EKPO

FOR ALL ENTRIES IN IT_PURCHASE WHERE EBELN = IT_PURCHASE-EBELN AND

BUKRS = IT_PURCHASE-BUKRS .

ENDIF.

ENDFORM. " item_data

&----


*& Form fill_fieldcatalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM FILL_FIELDCATALOG .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = PGM

I_INTERNAL_TABNAME = 'IT_ITEM'

I_STRUCTURE_NAME = 'ZSTR'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = GT_FIELDCAT

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 gt_fieldcat into wa_fieldcat where fieldname = 'CHEC'.

wa_fieldcat-checkbox = 'X'.

modify gt_fieldcat from wa_fieldcat .

clear wa_fieldcat.

endloop.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = PGM

I_INTERNAL_TABNAME = 'IT_ITEM'

I_STRUCTURE_NAME = 'ZSTR11'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = GT1_FIELDCAT

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.

ENDFORM. " fill_fieldcatalog

&----


*& Form display_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY_DATA .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = PGM

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = GT_FIELDCAT

TABLES

T_OUTTAB = IT_PURCHASE

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_data

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

CASE R_UCOMM.

WHEN '&IC1'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = PGM

IT_FIELDCAT = GT1_FIELDCAT

TABLES

T_OUTTAB = IT_ITEM

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

ENDCASE.

ENDFORM. "user_command

1 ACCEPTED SOLUTION

former_member181962
Active Contributor
0 Kudos
111

First thing is that you have to include a 1 charcter variable as the first field of the internal table being displayed.

YOu have to fill the layout structure also.

layout-BOX_FIELDNAME = <Name of the Check box field>.

REgards,

Ravi

7 REPLIES 7

former_member181962
Active Contributor
0 Kudos
112

First thing is that you have to include a 1 charcter variable as the first field of the internal table being displayed.

YOu have to fill the layout structure also.

layout-BOX_FIELDNAME = <Name of the Check box field>.

REgards,

Ravi

0 Kudos
111

Hi

Thanks .Can you tell me where and how to include that?

Regards

Ravi.

0 Kudos
111

Hi,

IS_layout is a parameter in FM reuse_alv_grid_display.

data w_layout type SLIS_LAYOUT_ALV.

w_layout-box_fieldname = 'CHECKBOX'.

while calling the fm,pass is_layout = w_layout

former_member181962
Active Contributor
0 Kudos
111

DATA: BEGIN OF IT_PURCHASE OCCURS 0,

<b>CHEC(1),</b>

EBELN LIKE EKKO-EBELN,

BUKRS LIKE EKKO-BUKRS,

BSART LIKE EKKO-BSART,

AEDAT LIKE EKKO-AEDAT,

<b>*CHEC(1),</b>

END OF IT_PURCHASE.

----


FORM DISPLAY_DATA .

<b>data: layout type SLIS_LAYOUT_ALV.

layout-BOX_FIELDNAME = 'CHEC'.</b>

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = PGM

  • I_CALLBACK_PF_STATUS_SET = ' '

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

<b>IS_LAYOUT = layout</b>

IT_FIELDCAT = GT_FIELDCAT

TABLES

T_OUTTAB = IT_PURCHASE

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.

Make the high lighted changes

Regards,

Ravi

0 Kudos
111

HI,

Thanks.

Former Member
0 Kudos
111

Hi,

In your program, dump error is coming in line no 130, the problem is no field catlog available. My suggesation is once check the field cat declaration correctly. And

I am providing the following links to help you very much when generating alv reports:

http://www.sapfans.com/forums/viewtopic.php?t=88376

http://help.sap.com/saphelp_erp2004/helpdata/en/ff/4649a6f17411d2b486006094192fe3/content.htm

Regards,

Bhaskar C

Clemenss
Active Contributor
0 Kudos
111

Hi Ravi,

DATA: BEGIN OF IT_PURCHASE OCCURS 0,

box type flag,

...

and in

FORM DISPLAY_DATA.

Data:

ls_alv_layout TYPE slis_layout_alv.

ls_alv_layout-box_fieldname = 'BOX'

... add function parameter after

EXPORTING

I_PROGRAM_NAME = PGM

is_layout = ls_alv_layout

Regrads,

Clemens