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

The exact scenario is that a user selects a record(row) from an alv dispaly.now each field value should be stored in an internal table.....HOW WILL I DO THIS.please reply asap.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Have a look on the following code, this will display the selected records in secondary list from basic list.

TABLES:

spfli.

TYPE-POOLS:

slis.

DATA:

BEGIN OF t_spfli OCCURS 0,

checkbox.

INCLUDE STRUCTURE spfli.

DATA: END OF t_spfli.

DATA:

t_sspfli LIKE STANDARD TABLE OF t_spfli .

DATA:

fs_spfli LIKE LINE OF t_sspfli.

DATA:

fs_layout TYPE slis_layout_alv,

w_program TYPE sy-repid.

SELECT *

FROM spfli

INTO CORRESPONDING FIELDS OF TABLE t_spfli.

*fs_layout-info_fieldname = 'COLOR'.

fs_layout-box_fieldname = 'CHECKBOX'.

w_program = sy-repid.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = w_program

i_callback_pf_status_set = 'FLIGHT'

i_callback_user_command = 'SPFLI_INFO'

i_structure_name = 'SPFLI'

is_layout = fs_layout

TABLES

t_outtab = t_spfli

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 FLIGHT

&----


  • text

----


  • -->RT_EXTAB text

----


FORM flight USING rt_extab TYPE slis_t_extab..

SET PF-STATUS 'FLIGHT' EXCLUDING rt_extab.

ENDFORM. "FLIGHT

&----


*& Form SPFLI_INFO

&----


  • text

----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM spfli_info USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

selfield-refresh = 'X'.

CASE ucomm.

WHEN 'FLIGHT'.

LOOP AT t_spfli.

IF t_spfli-checkbox = 'X'.

t_spfli-checkbox = ' '.

    • t_spfli-color = 'C51'.*

MODIFY t_spfli TRANSPORTING checkbox.

fs_spfli = t_spfli.

APPEND fs_spfli TO t_sspfli.

ENDIF.

ENDLOOP.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE. CLEAR fs_spfli.

fs_layout-info_fieldname = 'COLOR'.

  • fs_layout-confirmation_prompt = 'X'.

fs_layout-key_hotspot = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = w_program

i_structure_name = 'SFLIGHT'

is_layout = fs_layout

TABLES

t_outtab = t_sspfli

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.

REFRESH t_sspfli.

ENDFORM. "SPFLI_INFO

Create the one more internal code of same type.

Write the code to store in highlated block in above

Regards,

Chandu

1 REPLY 1

Former Member
0 Kudos

Hi,

Have a look on the following code, this will display the selected records in secondary list from basic list.

TABLES:

spfli.

TYPE-POOLS:

slis.

DATA:

BEGIN OF t_spfli OCCURS 0,

checkbox.

INCLUDE STRUCTURE spfli.

DATA: END OF t_spfli.

DATA:

t_sspfli LIKE STANDARD TABLE OF t_spfli .

DATA:

fs_spfli LIKE LINE OF t_sspfli.

DATA:

fs_layout TYPE slis_layout_alv,

w_program TYPE sy-repid.

SELECT *

FROM spfli

INTO CORRESPONDING FIELDS OF TABLE t_spfli.

*fs_layout-info_fieldname = 'COLOR'.

fs_layout-box_fieldname = 'CHECKBOX'.

w_program = sy-repid.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = w_program

i_callback_pf_status_set = 'FLIGHT'

i_callback_user_command = 'SPFLI_INFO'

i_structure_name = 'SPFLI'

is_layout = fs_layout

TABLES

t_outtab = t_spfli

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 FLIGHT

&----


  • text

----


  • -->RT_EXTAB text

----


FORM flight USING rt_extab TYPE slis_t_extab..

SET PF-STATUS 'FLIGHT' EXCLUDING rt_extab.

ENDFORM. "FLIGHT

&----


*& Form SPFLI_INFO

&----


  • text

----


  • -->UCOMM text

  • -->SELFIELD text

----


FORM spfli_info USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

selfield-refresh = 'X'.

CASE ucomm.

WHEN 'FLIGHT'.

LOOP AT t_spfli.

IF t_spfli-checkbox = 'X'.

t_spfli-checkbox = ' '.

    • t_spfli-color = 'C51'.*

MODIFY t_spfli TRANSPORTING checkbox.

fs_spfli = t_spfli.

APPEND fs_spfli TO t_sspfli.

ENDIF.

ENDLOOP.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE. CLEAR fs_spfli.

fs_layout-info_fieldname = 'COLOR'.

  • fs_layout-confirmation_prompt = 'X'.

fs_layout-key_hotspot = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

i_callback_program = w_program

i_structure_name = 'SFLIGHT'

is_layout = fs_layout

TABLES

t_outtab = t_sspfli

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.

REFRESH t_sspfli.

ENDFORM. "SPFLI_INFO

Create the one more internal code of same type.

Write the code to store in highlated block in above

Regards,

Chandu