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: filling cell with F4

former_member712491
Active Participant
0 Kudos

Hi all,

I am using below code to have F4 option for editable ALV grid cell

L_FIELDCAT-FIELDNAME = 'PSD'.

L_FIELDCAT-OUTPUTLEN = 10.

L_FIELDCAT-SELTEXT_L = 'Proposed Start Date'.

L_FIELDCAT-REF_TABNAME = 'EGERH'.

L_FIELDCAT-REF_FIELDNAME = 'AB'.

L_FIELDCAT-EDIT = 'X'.

APPEND L_FIELDCAT TO P_FIELDTAB.

But I am not able to fill cell with the selected value from F4 popup box (Calender). I am not using OO program. Pls. let me know is there any sample programs (not Object Oriented) available.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi sofia,

what you did is correct here see this sample code and observe the bold lines

&----


*& Report ZALV1_14797

*&

&----


*&

*&

&----


REPORT ZALV1_14797.

TYPE-POOLS: SLIS.

DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

L_LAYOUT TYPE SLIS_LAYOUT_ALV,

X_EVENTS TYPE SLIS_ALV_EVENT,

IT_EVENTS TYPE SLIS_T_EVENT.

DATA: BEGIN OF ITAB OCCURS 0,

<b>VBELN(10) type c</b> ,

POSNR LIKE VBAP-POSNR,

CHK(1),

color(4),

END OF ITAB.

SELECT VBELN

POSNR

FROM VBAP

UP TO 20 ROWS

INTO TABLE ITAB.

X_FIELDCAT-FIELDNAME = 'CHK'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 1.

X_FIELDCAT-INPUT = 'X'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-CHECKBOX = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'VBELN'.

X_FIELDCAT-SELTEXT_L = 'VBELN'.

*X_FIELDCAT-HOTSPOT = 'X'.

x_fieldcat-edit = 'X'.

X_FIELDCAT-TABNAME = 'ITAB'.

<b>x_fieldcat-ref_fieldname = 'VBELN'.

x_fieldcat-ref_tabname = 'VBAK'.</b>

X_FIELDCAT-COL_POS = 2.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'POSNR'.

X_FIELDCAT-SELTEXT_L = 'POSNR'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 3.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_LAYOUT-info_fieldname = 'COLOR'.

*L_LAYOUT-ZEBRA = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IS_LAYOUT = L_LAYOUT

I_CALLBACK_PF_STATUS_SET = 'STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = ITAB

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.

&----


*& Form STATUS

&----


  • text

----


  • -->P_EXTAB text

----


FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.

*- Pf status

SET PF-STATUS 'STATUS'.

ENDFORM. " STATUS

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELD text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

<b> DATA: GD_REPID LIKE SY-REPID, "Exists

REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

CALL METHOD REF_GRID->CHECK_CHANGED_DATA .

ENDIF.</b>

loop at itab where chk = 'X'.

itab-color = 'C300'.

modify itab index sy-tabix transporting color.

endloop.

RS_SELFIELD-refresh = 'X'.

*reward points if useful

regards

suman

ENDFORM. "USER_COMMAND

2 REPLIES 2

Former Member
0 Kudos

Hi sofia,

what you did is correct here see this sample code and observe the bold lines

&----


*& Report ZALV1_14797

*&

&----


*&

*&

&----


REPORT ZALV1_14797.

TYPE-POOLS: SLIS.

DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

L_LAYOUT TYPE SLIS_LAYOUT_ALV,

X_EVENTS TYPE SLIS_ALV_EVENT,

IT_EVENTS TYPE SLIS_T_EVENT.

DATA: BEGIN OF ITAB OCCURS 0,

<b>VBELN(10) type c</b> ,

POSNR LIKE VBAP-POSNR,

CHK(1),

color(4),

END OF ITAB.

SELECT VBELN

POSNR

FROM VBAP

UP TO 20 ROWS

INTO TABLE ITAB.

X_FIELDCAT-FIELDNAME = 'CHK'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 1.

X_FIELDCAT-INPUT = 'X'.

X_FIELDCAT-EDIT = 'X'.

X_FIELDCAT-CHECKBOX = 'X'.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'VBELN'.

X_FIELDCAT-SELTEXT_L = 'VBELN'.

*X_FIELDCAT-HOTSPOT = 'X'.

x_fieldcat-edit = 'X'.

X_FIELDCAT-TABNAME = 'ITAB'.

<b>x_fieldcat-ref_fieldname = 'VBELN'.

x_fieldcat-ref_tabname = 'VBAK'.</b>

X_FIELDCAT-COL_POS = 2.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

X_FIELDCAT-FIELDNAME = 'POSNR'.

X_FIELDCAT-SELTEXT_L = 'POSNR'.

X_FIELDCAT-TABNAME = 'ITAB'.

X_FIELDCAT-COL_POS = 3.

APPEND X_FIELDCAT TO IT_FIELDCAT.

CLEAR X_FIELDCAT.

L_LAYOUT-info_fieldname = 'COLOR'.

*L_LAYOUT-ZEBRA = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IS_LAYOUT = L_LAYOUT

I_CALLBACK_PF_STATUS_SET = 'STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = IT_FIELDCAT

TABLES

T_OUTTAB = ITAB

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.

&----


*& Form STATUS

&----


  • text

----


  • -->P_EXTAB text

----


FORM STATUS USING P_EXTAB TYPE SLIS_T_EXTAB.

*- Pf status

SET PF-STATUS 'STATUS'.

ENDFORM. " STATUS

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELD text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD.

<b> DATA: GD_REPID LIKE SY-REPID, "Exists

REF_GRID TYPE REF TO CL_GUI_ALV_GRID.

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

CALL METHOD REF_GRID->CHECK_CHANGED_DATA .

ENDIF.</b>

loop at itab where chk = 'X'.

itab-color = 'C300'.

modify itab index sy-tabix transporting color.

endloop.

RS_SELFIELD-refresh = 'X'.

*reward points if useful

regards

suman

ENDFORM. "USER_COMMAND

Pawan_Kesari
Active Contributor
0 Kudos

Check these values

L_FIELDCAT-REF_TABNAME = 'EGERH'.

L_FIELDCAT-REF_FIELDNAME = 'AB'.

'EGERH' should be table or structure in data dictionary and 'AB' should be its field..

If you want calender F4 help put values as follows

L_FIELDCAT-REF_TABNAME = 'SYST'.

L_FIELDCAT-REF_FIELDNAME = 'DATUM'.