2014 Jan 26 11:19 PM
Hello All,
I have table control & I added sort button with code ..
in top program ..
data: fld_list LIKE TBL_CTRL-cols,
wa_fld_list LIKE LINE OF fld_list.
in PAI..
when 'SORTU'.
READ TABLE TBL_CTRL-cols INTO wa_fld_list WITH KEY selected = 'X'.
IF sy-subrc = 0.
SORT IT_ZPRODUCT_T STABLE BY (wa_fld_list-SCREEN-name+14) ASCENDING. "
wa_fld_list-selected = ' '.
MODIFY TBL_CTRL-cols FROM wa_fld_list INDEX sy-tabix.
ENDIF.
I am facing this problem :
when i select any column and click on sort button nothing happen..... why ?!
regards ,
zakyaih
2014 Feb 03 5:19 PM
I use if statement ...because after sort execute the program execute STATUS_3000 again
if it_ZPRODUCTS_T is INITIAL.
SELECT * FROM ZPRODUCTS_T
INTO CORRESPONDING FIELDS OF TABLE it_ZPRODUCTS_T up to 100 rows .
ENDif.
2014 Jan 27 2:51 AM
Hello Zakyiah Tuwaylib.
Code seems to be correct.
Check if the data is already sorted or not?
Try with DESCENDING sort option.
Regards.
2014 Jan 27 2:07 PM
thanks for response
i tried both way DESCENDING and ASCENDING
same issue
2014 Jan 28 3:06 AM
Zakyiah Tuwaylib,
Just debug and see.
TYPE /h in the command prompt and then click SORT button.
It will help you understand how program execution takes place.
Regards.
2014 Jan 28 4:24 PM
2014 Jan 28 5:52 PM
2014 Jan 29 3:20 AM
Have you mentioned the correct table control name?
READ TABLE TBL_CTRL-cols INTO wa_fld_list WITH KEY selected = 'X'.
MODIFY TBL_CTRL-cols FROM wa_fld_list INDEX sy-tabix.
What is the sy-tabix value before this statement gets executed?
What is the sy-subrc value after this statement's execution?
2014 Jan 29 6:06 PM
yes,
before
0
8
after
0
8
I will print screen what i did from the scratch .
2014 Jan 27 3:09 AM
Hi,
Just try like standard way!
when 'SORTU'.
data: fldname(100),help(100).
READ TABLE TBL_CTRL-cols INTO wa_fld_list WITH KEY selected = 'X'. if sy-subrc = 0. read table table_control-cols into col with key selected = 'X'. | |||
wa_cols-selected = ' '.
| |||
2014 Jan 27 2:21 PM
thanks for response
i tried standard way same issue
regards,
zakyiah
2014 Jan 27 3:36 PM
Hi
If you put a break point at sort statement do you see your internal table getting sorted in debugging if yes then check in debugging whether ypu are doing some data selection again which may be overwritting this sort. Please paste your PBO sample code
Nabheet
2014 Jan 27 4:38 PM
HI,
i am not friendly with breakpoints
where i should but it ?
2014 Jan 27 4:48 PM
Being an ABAPER if you want to you should be. Put a break point in PAI on sort and then in PBO
2014 Jan 27 5:08 PM
yes i am beginner .. i am working with ABAP just from 1 month
where is it exactly ?
2014 Jan 28 5:14 AM
Hi zakyiah Tuwaylib
Then see this demo program DEMO_DYNPRO_TABCONT_LOOP_AT.
report demo_dynpro_tabcont_loop_at.
controls flights type tableview using screen 100.
data: cols like line of flights-cols,
lines type i.
data: ok_code type sy-ucomm,
save_ok type sy-ucomm.
data: itab type table of demo_conn.
tables demo_conn.
select * from spfli into corresponding fields of table itab.
loop at flights-cols into cols where index gt 2.
cols-screen-input = '0'.
modify flights-cols from cols index sy-tabix.
endloop.
call screen 100.
module status_0100 output.
set pf-status 'SCREEN_100'.
describe table itab lines lines.
flights-lines = lines.
endmodule.
module cancel input.
leave program.
endmodule.
module read_table_control input.
modify itab from demo_conn index flights-current_line.
endmodule.
module user_command_0100 input.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'TOGGLE'.
loop at flights-cols into cols where index gt 2.
if cols-screen-input = '0'.
cols-screen-input = '1'.
elseif cols-screen-input = '1'.
cols-screen-input = '0'.
endif.
modify flights-cols from cols index sy-tabix.
endloop.
when 'SORT_UP'.
read table flights-cols into cols with key selected = 'X'.
if sy-subrc = 0.
sort itab stable by (cols-screen-name+10) ascending.
cols-selected = ' '.
modify flights-cols from cols index sy-tabix.
endif.
when 'SORT_DOWN'.
read table flights-cols into cols with key selected = 'X'.
if sy-subrc = 0.
sort itab stable by (cols-screen-name+10) descending.
cols-selected = ' '.
modify flights-cols from cols index sy-tabix.
endif.
when 'DELETE'.
read table flights-cols into cols with key screen-input = '1'.
if sy-subrc = 0.
loop at itab into demo_conn where mark = 'X'.
delete itab.
endloop.
endif.
endcase.
endmodule.
2014 Jan 28 4:36 PM
2014 Jan 28 5:57 PM
2014 Jan 29 4:29 AM
Hi,
Can you pls let me know how you arrived at offset - 14 in your below code ?
SORT IT_ZPRODUCT_T STABLE BY (wa_fld_list-SCREEN-name+14) ASCENDING.
This should be dependent of your screen field. Just double click in screen painter on any of the field of table control and check the name .Lets us say your 1st screen field name is WA_PRODUCT-PRODUCT_ID. Then if you want to sort it via PRODUCT_ID then you should choose offset 11 (count number of chars till '-', count characters in string WA_PRODUCT-, which is 11 ) and write as follows:
SORT IT_ZPRODUCT_T STABLE BY (wa_fld_list-SCREEN-name+11) ASCENDING. I hope it helps.
So, just find correct offset.
Regards
Nishant
2014 Jan 29 6:14 PM
hi ,
thanks for helping me
yea ,, my internal table is IT_ZPRODUCT_T (13)+ ( - ) = 14
AMMMMM
EVEN WHEN I USE THIS CODE SAME RESULT
data: fldname(100),help(100).
READ TABLE TBL_CTRL-cols INTO wa_fld_list WITH KEY selected = 'X'.
if sy-subrc = 0.
read table TBL_CTRL-cols INTO wa_fld_list with key selected = 'X'.
split wa_fld_list-screen-name at '-' into help fldname.
sort IT_ZPRODUCT_T by (fldname) ASCENDING .
wa_fld_list-selected = ' '.
MODIFY TBL_CTRL-cols FROM wa_fld_list INDEX sy-tabix.
endif.
I will print screen what i did from the scratch .
2014 Jan 28 4:49 PM
Hi,
You can seach SAP examples on table control in SE38. Search with DEMO*DYNPRO*TAB* and press F4. There is one demo program by SAP which explain sorting functionality as well. Also you may find example in ABAPDOCU transaction.
Regards
Nishant.
2014 Jan 29 4:43 AM
Hi Zakiyah,
I am sure you must have gone through this link.
Table Controls: Examples with Modifications (SAP Library - ABAP Programming (BC-ABA))
The screen field name seems to be the issue.Can you share the screen shot of the flow logic of the screen?Also just check whether the number of characters before the screen field name are correct, in your case they are '14'.
Regards,
AB
2014 Jan 29 6:16 PM
2014 Jan 29 8:12 PM
hi ,
my code
At Top Include :
tables : ZPRODUCTS_T
TYPES :BEGIN OF itab,
mark TYPE c .
INCLUDE STRUCTURE ZPRODUCTS_T.
TYPES: END OF itab .
DATA: wa_ZPRODUCTS_T TYPE itab,
it_ZPRODUCTS_T TYPE STANDARD TABLE OF itab WITH HEADER LINE .
CONTROLS: TBL_CTRL_PRODUCT TYPE tableview USING screen 100.
DATAT: cols LIKE LINE OF TBL_CTRL_PRODUCT-cols,
PROCESS BEFORE OUTPUT.
MODULE STATUS_1007.
LOOP AT it_ZPRODUCT_T into wa_ZPRODUCT_T with control TBL_CTRL_PRODUCT
CURSOR TBL_CTRL_PRODUCT-CURRENT_LINE.
ENDLOOP.
MODULE STATUS_1007 OUTPUT.
SELECT * FROM ZPRODUCTS_T INTO CORRESPONDING FIELDS OF TABLE it_ZPRODUCTS_T up to 100 rows .
END MODULE.
PROCESS AFTER INPUT.
LOOP AT it_ZPRODUCTS_T .
ENDLOOP.
MODULE USER_COMMAND_1007.
MODULE USER_COMMAND_1007 INPUT.
READ TABLE it_ZPRODUCTS_T INTO wa_ZPRODUCTS_T.
CASE SY-UCOMM .
when 'SORTD'.
read table TBL_CTRL_PRODUCT -cols into cols with key selected = 'X'.
if sy-subrc = 0.
sort IT_ZPRODUCTS_T stable by (cols-screen-name+15) descending.
cols-selected = ' '.
modify TBL_CTRL_PRODUCT -cols from cols index sy-tabix.
endif.
ENDCASE.
ENDMODULE. " USER_COMMAND_1007 INPUT
?! what is the problem
2014 Jan 30 4:53 AM
Hi Zakiyah,
Thanks for the screen shots.
I can see that you have used two Table controls and i can see from the flow logic that you have not used the first one in the PBO i.e. you have not Looped it, may be that is the issue...what you can do is declare the first table control followed by your second table control. Same should be the case when you are in PAI i.e. for example
PROCESS BEFORE OUTPUT.
Loop at Tcontol1.
Endloop.
Loop at Tcontol2.(Table control which is giving issues)
Endloop.
PROCESS AFTER INPUT.
Loop at Tcontol1.
Endloop.
Loop at Tcontol2.(Table control which is giving issues)
Endloop.
The flow of the table control processing is Top Left to Bottom Right, this might be affecting the flow.
Regards,
AB.
2014 Jan 30 7:27 AM
many thanks
oh no .. I already deleted the table control 1
i just rewrite my steps again with another table control and another master table to make sure
everything is ok ..
but I faced same issue
when I printed screen maybe before I delete it
"The flow of the table control processing is Top Left to Bottom Right, this might be affecting the flow."
?!
Message was edited by: zakyiah Tuwaylib
2014 Jan 30 10:47 AM
Hi Zakiyah,
I was referring to the case when there are multiple table controls on the same screen then "The flow of the table control processing is Top Left to Bottom Right".
From here i would say you should try the following:
Put a break point just after the sort statement in the PAI and check in the debugger whether the table is sorting or not.
If it is getting sorted then i can also see from your code that there is a module 'MODULE STATUS_1007' in the PBO where you are fetching data from the database into the internal table which is used in the table control, so every time after the PAI call the data you are sorting is getting overwritten.
I would suggest to put some condition in the PBO Module like if the Internal Table is initial then only fill it.
Regards,
AB
2014 Feb 02 5:22 AM
yea in debugging mode internal table is sort ...but how can i do that with table control
2014 Feb 02 9:00 PM
2014 Feb 03 4:48 AM
Hi Zakyiah
Since eveyone has contributed to this thread it will be good if you can share how were you able to solve the issue.
Nabheet
2014 Feb 03 5:19 PM
I use if statement ...because after sort execute the program execute STATUS_3000 again
if it_ZPRODUCTS_T is INITIAL.
SELECT * FROM ZPRODUCTS_T
INTO CORRESPONDING FIELDS OF TABLE it_ZPRODUCTS_T up to 100 rows .
ENDif.