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

Question regarding Checkbox

Former Member
0 Likes
742

Hi,

I have declared a checkbox in an internal table and I have displayed the fields of the internal table along with checkbox as a list. Now based on the check of the checkbox value i need to do action specified by the button in the pf-status. So i want to give a message to user if no checkbox is checked asking him to check the checkboxes. How do i validate on this?

Thanks

VIcky

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
715

Vicky,

How about a pop up?

if ...

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

TITEL = 'Error: no boxes checked'

TXT1 = ' '

TXT2 = 'You must check at least 1 box.'

TXT3 = ' '

TXT4 = ' '

EXCEPTIONS

OTHERS = 1.

stop.

endif.

regards,

den

6 REPLIES 6
Read only

former_member186741
Active Contributor
0 Likes
715

is this alv or a standard report?

Read only

Former Member
0 Likes
716

Vicky,

How about a pop up?

if ...

CALL FUNCTION 'POPUP_TO_INFORM'

EXPORTING

TITEL = 'Error: no boxes checked'

TXT1 = ' '

TXT2 = 'You must check at least 1 box.'

TXT3 = ' '

TXT4 = ' '

EXCEPTIONS

OTHERS = 1.

stop.

endif.

regards,

den

Read only

0 Likes
715

There are a couple of ways to do this. Here is one.

1) move the data from the ITAB to a second one.

ITAB2[] = ITAB1[].

2) Delete all of the entries that do not have a CHECK

delete itab2 where check =  space.

3) Describe the table and get the lines

data: checked_lines type i.
describe table itab2 lines checked_lines.

4) Now give message if the check_lines = 0.


if check_lines = 0.
message e001(00) with 'Please select at least one line.
endif.

In this solution, I assume that you are modifing the internal when rows are being selected.

REgards,

Rich Heilman

Read only

Former Member
0 Likes
715

Vicky,

And if you're asking about how to check to see if any checkboxes are checked... You could either loop/endloop or read the table looking for check = 'X'.

e.g.,

read table itab with key check = 'X'.

if sy-subrc <> 0.

<insert the pop-up code here>

endif.

Read only

Former Member
0 Likes
715

Hi Vicky,

Use similar code.

data recs type C.

at user-command.

case sy-ucomm.

when 'BUTTON'.

perform check_recs.

if recs is initial.

message i000 with 'No records were selected'.

exit.

endif.

perform function.

endcase.

form check_recs.

lsind = sy-lsind - 1.

clear recs.

clear anzkr.

refresh tbkpf.

do.

read line sy-index index lsind field value xpickc.

if sy-subrc = 0.

check xpickc ne space.

rec = 'X'.

anzkr = anzkr + 1.

move-corresponding vbkpf to tbkpf.

append tbkpf.

else.

exit.

endif.

enddo.

endform.

Hope that was useful.

Cheers,

Susmitha.

Dont forget to reward points for useful answers.

Read only

Former Member
0 Likes
715

Hi,

If you are using ALV, call one event.

i dont remember the name right now.

this event automatically updates your internal table with the checked values.

then check your internal table whether your check field is populated for any line item or not.

if no line item is check, throw the error to the user.