Application Development and Automation 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: 
Read only

Problem ALV

Former Member
0 Likes
599

Hi,

I want to display the material and a checkbox in ALV display.I have an attach button.After pressing select all button,all check boxes should get selected or user should select some materials.After selecting materials and pressing 'ATTACH' button some transaction should get called.My problem is how to read the multiple records at a time.

1 ACCEPTED SOLUTION
Read only

asik_shameem
Active Contributor
0 Likes
583

Hi

go thru in this pgm.

select the record u want and double click on the screen.

report zreport.

TYPE-POOLS : slis.

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

<b>DATA : flag tyPE c,</b>

END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

SELECT * FROM t001 INTO TABLE itab.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

<b>alvly-box_fieldname = 'FLAG'.</b>

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid

i_callback_user_command = 'USER_COMMAND'

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

FORM user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

data : msg(100) type c.

LOOP AT itab.

if itab-flag = 'X'.

msg = sy-tabix.

condense msg.

concatenate 'Row Number ' msg ' ' into msg

separated by space.

message msg type 'I'.

endif.

ENDLOOP.

ENDFORM. "user_command

5 REPLIES 5
Read only

Former Member
0 Likes
583

Hi

Its very simple. just add a field called BOX in ur final internal table.

then, if u have used layout , Give the following coding in that,

data: gs_layout type slis_layout_alv.

gs_layout-box_fieldname = 'BOX'.

CLEAR gt_sortinfo.

in the output , you ll get boxes. u can select and do the interactive list.

If u have still doubt, reply me.

thanks and regards

karthik

*****************reward points if useful

Read only

0 Likes
583

Hi,

How can i read multiple records?

Read only

Former Member
0 Likes
583

pass checkbox and input parameter to fieldcatalog.

pass box parameter to layout.

and write specific code for button and checkbox.

your prob ll get solved.

Read only

asik_shameem
Active Contributor
0 Likes
584

Hi

go thru in this pgm.

select the record u want and double click on the screen.

report zreport.

TYPE-POOLS : slis.

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

<b>DATA : flag tyPE c,</b>

END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvly TYPE slis_layout_alv.

SELECT * FROM t001 INTO TABLE itab.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

<b>alvly-box_fieldname = 'FLAG'.</b>

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = sy-repid

i_callback_user_command = 'USER_COMMAND'

is_layout = alvly

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

FORM user_command USING whatcomm TYPE sy-ucomm whatrow TYPE

slis_selfield.

data : msg(100) type c.

LOOP AT itab.

if itab-flag = 'X'.

msg = sy-tabix.

condense msg.

concatenate 'Row Number ' msg ' ' into msg

separated by space.

message msg type 'I'.

endif.

ENDLOOP.

ENDFORM. "user_command

Read only

Former Member
0 Likes
583

refer to follwoing code.it also works for multiple records.

FORM ucommand USING ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.

DATA : BEGIN OF it_flag OCCURS 0,

flag(1),

END OF it_flag.

CASE ucomm.

WHEN 'SAVE'.

LOOP AT it_data INTO wa_data WHERE check EQ 'X'.

MOVE wa_data-check TO it_flag-flag.

APPEND it_flag.

ENDLOOP.

IF it_flag[] IS NOT INITIAL.

PERFORM modify_data.

ELSE.

MESSAGE e022.

ENDIF.

  • WHEN '&ALL'.

*

  • LOOP AT it_data INTO wa_data.

  • wa_data-check = 'X'.

  • MODIFY it_data from wa_data TRANSPORTING check.

  • ENDLOOP.

*

ENDCASE.

ENDFORM. " UCOMMAND