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: 

Select All & Deselect All Option in Table Control ...??

sagar_ranasingh
Participant
0 Kudos

HI helping Minds ,

I have a screen 9000 where i have two Text boxes (kna1-kunnr & kna1-regio ) and a Tablecontrol ( TB1 - name1,land1,ort01) .

Kna1-kunnr field is for input & Kna1-regio is for display, Depending on the KUNNR , Regio is displayed

and also Name1, Land1 & Ort01 field is fetched to tablecontrol display.

My Req. is (1) -- if i enter a customer no say 001 , it will display the details in TB1 , and next i enter another customer no 002 it will display the details of 002 customer below to 001 customer..like dis....

(2) finally i will have two buttons SELECTALL & DESELECT ALL ,like in standard screens... for save to Ztable.

so my point is - in (1) -- if i displayed 001 cutomers details and after some more customers ,Again i choosed to display 001 customer,

so dat time hw to stop duplicacy in Tablecontrol as it is already displayin 001 details. ( Shd throw a

error message that customer is already displayed).

(2) -- One Click SELECTALL & also a DESELECTALL Buttons ....

i am able to display the detials of different customers..but confused to stop duplicay of those customers who r already displayed.

Pls Suggest some Logic...?

10 REPLIES 10

Former Member
0 Kudos

Hi,

1) For your first requirement, I would suggest you to populate your internal table every time you try to get the details of a list of customers (even if it means you are asking for the customer details that is already displayed).

What you can do is clear your internal table so that every time there is an event or a user action, the PAI is triggered where you would have cleared the internal table and populate it with values based on the inputs afresh.



PROCESS AFTER INPUT.
MODULE clear_internal_table.  <- Clear your internal table here
LOOP AT gt_itab.
 MODULE fetch_data.
ENDLOOP.

MODULE clear_internal_table INPUT.
  clear gt_itab[].
  clear gt_itab.
ENDMODULE.

2) For your second requirement, you have to include the w/sel column for the table control. You will find that in the Attributes of the table control in the Screen layout. Check the w/sel column, and it will ask you for a name. Give a name like 'MARK' and save and activate. You will find a column in the table control.

Because your table control is in synch with the internal table that is being used to operated on it, you will have to add another field corresponding to MARK, say CHECK.


   DATA: BEGIN OF gt_itab,
               check(1) type c,
              .........
              END OF gt_itab.

In the PBO of the module inside the LOOP...ENDLOOP....


PROCESS BEFORE OUTPUT.
 LOOP AT gt_itab WITH CONTROL tabcontrol.
   MODULE check_control.
ENDLOOP.

PROCESS AFTER INPUT.
MODULE clear_internal_table.  <- Clear your internal table here
LOOP AT gt_itab.
 MODULE fetch_data.
ENDLOOP.

MODULE check_control OUTPUT.
   mark = gt_itab-check.    "Assign the status of the check (space or 'X') to MARK on the table control
ENDMODULE.

MODULE fetch_data OUTPUT.
 IF sy-ucomm eq 'SELECTALL'.   "You would have had buttons for SELECTALL and DESELECTALL. Assign Fcodes to them
  gt_itab2-check = 'X'.
  MODIFY gt_itab INDEX tabcontrol-current_line.  "Modify the internal table transporting CHECK.
ELSEIF sy-ucomm eq 'DESELECTALL'.
  gt_itab2-check = ''.
  MODIFY gt_itab INDEX tabcontrol-current_line.
endif.
ENDMODULE.

0 Kudos

Thnks for ur Reply...

I had done like urs...But the problem was if i click 'SALL', all rows are selected into ITAB but none of the fields are highlighted,

So the user might confused weather all fields r selected or not..

I jus changed in my code, In LAYOUT choosed MUltiple Row & Multiple Column selection, which inreturn gives d option to selectall like Standard screen. Nw when u click Selectall , all i rows are selected in tablecontrol..But none of the rows are MARKed as X. so jus changed the code..

when "save' , save all dat are in the internal table.

dats it...

But my 1st req is still there .

i have datas in internal tables , where eachrow of data is dupliacted once..means each row data is Stored Multiple times in ITAB.

I want to sort them and delete the dupliacte datas.

My code is here ..

SELECT regio kunnr name1 ort01 from kna1
                             into CORRESPONDING FIELDS OF  it_cust
                             where regio = zstr_bonus_qnty-regio.

                   APPEND it_cust .
            ENDSELECT .

       sort it_cust by regio dcode .
       DELETE adjacent duplicates from it_cust comparing regio kunnr name1 ort01 .
       endif .

But its not deleting the fields ? any solution

0 Kudos

Hi,

Firstly, using SELECT...ENDSELECT is a bad practise. So you could probably rewrite your query like this



SELECT regio kunnr name1 ort01 from kna1
                             into CORRESPONDING FIELDS OF TABLE it_cust  <- Addition of keyword 'TABLE'
                             where regio = zstr_bonus_qnty-regio.
sort it_cust by regio dcode .
 DELETE adjacent duplicates from it_cust comparing regio kunnr name1 ort01 .

The above should work.

A good workaround is to cler your internal table as I previously mentioned. When you clear your internal table, everytime the PAI is triggered, the internal table is populated with new values based on your inputs. So you will not have the problem of data duplicating in the internal table.

0 Kudos

i Am using SELECT &APPEND , cos when i enter a different customer, his details shd be append with the previous customers details.

If i don use Append , the previous details will be overwritten by the new ones .

Let me Clear.

If i enterd customer no 100 first , it will display 100's details in tablecontol.

Then i entered customer 200, so here my need is to see 200's details , at end of 100's details.

I guess u understood the scenario .

Anywys thanks a lot..

0 Kudos

Ok....Then your logic should work.

If it still does not work, try debugging. That should throw some light.

0 Kudos

HEY Nit....

dat waas solved... By sorting the internal table & Deleting the internal table.

But one more issue..

In tablecontrol 1 field is editable and the rest two are display mode.

After displaying The data, i want to modify the Editable field...?

But hw ? Cos am using select firlds from tbale to the iNtenal tbale...

??

Any idea...

Former Member
0 Kudos

{

***select/deselect all logic in module pool

*Global Data Declarations.

TYPES:

BEGIN OF ty_tczgmmekgrsupste,

linesel TYPE char1, "this field is used to select'deselect fields in table control

ekgrp TYPE ekgrp, "Purchasing Group

tragr TYPE tragr,

end of ty_tczgmmekgrsupste.

data: i_tczgmmekgrsupste TYPE STANDARD TABLE OF ty_tczgmmekgrsupste,

field-symbols: <fs_tczgmmekgrsupste> TYPE ty_tczgmmekgrsupste.

constants: c_x type char1 value 'X'.

MODULE user_command_9001 INPUT.

okcode = sy-ucomm.

CLEAR sy-ucomm.

CASE okcode.

WHEN 'MARK'.----


>select all function code

PERFORM f_select_all_records.

WHEN 'DMRK'.----


.->deselect all function code

PERFORM f_deselect_all_records.

endcase.

endmodule.

FORM f_select_all_records .

LOOP AT i_tczgmmekgrsupste ASSIGNING <fs_tczgmmekgrsupste>.

<fs_tczgmmekgrsupste>-linesel = c_x.

ENDLOOP.

ENDFORM.

FORM f_deselect_all_records .

LOOP AT i_tczgmmekgrsupste ASSIGNING <fs_tczgmmekgrsupste>.

<fs_tczgmmekgrsupste>-linesel = ' '.

ENDLOOP.

ENDFORM.

Former Member
0 Kudos

*To avoid duplicates

{

  • u can validate the table control data in PAI module insdie chain endcahin before appending to avoid the duplicate entries appended.

PROCESS AFTER INPUT.

loop at <table control >.

CHAIN.

MODULE validate_data_9001..

endchain.

MODULE validate_data_9001 INPUT.

read table it_cust with key kunnr = <table control>-kunnr.

if sy-subrc is not initial.

message e001. "Data already available in table control.

endif.

ENDMODULE.

MODULE user_command_9001.

***In ths module u write u r select query to append ,delete , sort it should work fine.

Former Member
0 Kudos

use default table control fields is in display mode

when edit u need to modify perticular field iam i right

for this initiall all fields are in display mode now

when 'edit'

in pbo loop

loop ai screen.

if screen-name = itab-field1.

screen-input = 1.

modify screen.

endif.

endloop.

end loop

sagar_ranasingh
Participant
0 Kudos

i got the way...

thanks to all for your valuable time....