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: 

Table Control Sort doesnt work , plz check my code

Former Member
0 Kudos

Hello

Flag is defined thr in TCL1 attribute list(checked) w/selColumn & value is FLAG ,also defined as char in prog

But syntax error is "No component exist with the name FLAg "

Plz correct me .

REPORT ZSD_REP_ORDER_BANK_CHANGE NO STANDARD PAGE HEADING LINE-SIZE 255.

TABLES: VBAK,VBAP,VBRK,ZSD_TABL_ORDBANK,MARA,KONV.

CONTROLS: TCL1 TYPE TABLEVIEW USING SCREEN 0200.

DATA: ITAB LIKE ZSD_TABL_ORDBANK OCCURS 0 WITH HEADER LINE,

WA_ITAB LIKE ZSD_TABL_ORDBANK,

OK_CODE LIKE SY-UCOMM,

SAVE_OK_CODE LIKE SY-UCOMM,

ANSWER TYPE C,

I LIKE SY-LOOPC ,

J LIKE SY-LOOPC,

V_LINES LIKE SY-LOOPC,

LINE_COUNT LIKE SY-LOOPC,

STS TYPE N,

FLAG,

EMGRP LIKE MARA-EXTWG,

QTY LIKE ZSD_TABL_ORDBANK-QTY,

UPRICE LIKE ZSD_TABL_ORDBANK-UPRICE,

TOT LIKE ZSD_TABL_ORDBANK-TOT,

INO LIKE VBAP-POSNR.

FIELD-SYMBOLS:

<FS_ITAB> LIKE LINE OF ITAB,

<FS_TCL1> LIKE LINE OF TCL1-COLS.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.

SELECT-OPTIONS: S_CCODE FOR ZSD_TABL_ORDBANK-CCODE

NO INTERVALS NO-EXTENSION OBLIGATORY,

S_SORG FOR ZSD_TABL_ORDBANK-SORG

NO INTERVALS NO-EXTENSION OBLIGATORY,

S_DCHAN FOR ZSD_TABL_ORDBANK-DISTCHAN,

S_DIV FOR ZSD_TABL_ORDBANK-DIV,

S_MATNO FOR ZSD_TABL_ORDBANK-MATNO,

S_CUSTNO FOR ZSD_TABL_ORDBANK-CUSTNO ,

S_QTNO FOR ZSD_TABL_ORDBANK-QTNO,

S_QTDAT FOR ZSD_TABL_ORDBANK-QTDAT,

S_QTVDAT FOR ZSD_TABL_ORDBANK-QTVALDAT,

S_SONO FOR ZSD_TABL_ORDBANK-SONO.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN.

SELECT * FROM ZSD_TABL_ORDBANK

INTO TABLE ITAB

WHERE CCODE IN S_CCODE

AND SORG IN S_SORG

AND DISTCHAN IN S_DCHAN

AND DIV IN S_DIV

AND MATNO IN S_MATNO

AND CUSTNO IN S_CUSTNO

AND QTNO IN S_QTNO

AND QTDAT IN S_QTDAT

AND QTVALDAT IN S_QTVDAT

AND SONO IN S_SONO .

IF SY-SUBRC EQ 0.

REFRESH ITAB.

CALL SCREEN 0200.

ELSE.

MESSAGE E012(ZQOTBANK) .

ENDIF.

&----


*& Module SET_STATUS OUTPUT

&----


  • text

----


MODULE SET_STATUS OUTPUT.

SET PF-STATUS '0200'.

SET TITLEBAR '0200'.

SELECT * FROM ZSD_TABL_ORDBANK

INTO TABLE ITAB

WHERE CCODE IN S_CCODE

AND SORG IN S_SORG

AND DISTCHAN IN S_DCHAN

AND DIV IN S_DIV

AND MATNO IN S_MATNO

AND CUSTNO IN S_CUSTNO

AND QTNO IN S_QTNO

AND QTDAT IN S_QTDAT

AND QTVALDAT IN S_QTVDAT

AND SONO IN S_SONO .

IF SY-SUBRC EQ 0.

DESCRIBE TABLE ITAB LINES V_LINES.

TCL1-LINES = V_LINES.

ENDIF.

LOOP AT ITAB.

QTY = ITAB-QTY.

UPRICE = ITAB-UPRICE.

TOT = QTY * UPRICE .

ITAB-TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-CGL_QTY.

UPRICE = ITAB-CGL_UPRICE.

TOT = QTY * UPRICE .

ITAB-CGL_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-BHEL_QTY.

UPRICE = ITAB-BHEL_UPRICE.

TOT = QTY * UPRICE .

ITAB-BHEL_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-ALSTOM_QTY.

UPRICE = ITAB-ALSTOM_UPRICE.

TOT = QTY * UPRICE .

ITAB-ALSTOM_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-SIEMENS_QTY.

UPRICE = ITAB-SIEMENS_UPRICE.

TOT = QTY * UPRICE .

ITAB-SIEMENS_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-TELK_QTY.

UPRICE = ITAB-TELK_UPRICE.

TOT = QTY * UPRICE .

ITAB-TELK_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

QTY = ITAB-OTH_QTY.

UPRICE = ITAB-OTH_UPRICE.

TOT = QTY * UPRICE .

ITAB-OTH_TOT = TOT .

CLEAR: QTY, UPRICE, TOT.

MODIFY ITAB.

ENDLOOP.

ENDMODULE. " SET_STATUS OUTPUT

&----


*& Module SET_LINE_COUNT INPUT

&----


  • text

----


MODULE SET_LINE_COUNT OUTPUT.

LINE_COUNT = SY-LOOPC.

ENDMODULE. " SET_LINE_COUNT INPUT

&----


*& Module SCROLL INPUT

&----


  • text

----


MODULE SCROLL_SORT INPUT.

SAVE_OK_CODE = OK_CODE.

CLEAR OK_CODE.

CASE SAVE_OK_CODE.

WHEN 'P--'.

TCL1-TOP_LINE = 1.

WHEN 'P-'.

TCL1-TOP_LINE = TCL1-TOP_LINE - LINE_COUNT.

IF TCL1-TOP_LINE LE 0.

TCL1-TOP_LINE = 1.

ENDIF.

WHEN 'P+'.

I = TCL1-TOP_LINE + LINE_COUNT.

J = TCL1-LINES - LINE_COUNT + 1.

IF J LE 0.

J = 1.

ENDIF.

IF I LE J.

TCL1-TOP_LINE = I.

ELSE.

TCL1-TOP_LINE = J.

ENDIF.

WHEN 'P++'.

TCL1-TOP_LINE = TCL1-LINES - LINE_COUNT + 1.

IF TCL1-TOP_LINE LE 0.

TCL1-TOP_LINE = 1.

ENDIF.

WHEN 'SORTUP'.

READ TABLE TCL1-COLS ASSIGNING <FS_TCL1> WITH KEY FLAG = 'X'.

IF SY-SUBRC = 0.

SORT ITAB ASCENDING BY (<FS_TCL1>-screen-name+5).

ENDIF.

WHEN 'SORTDN'.

READ TABLE TCL1-COLS ASSIGNING <FS_TCL1> WITH KEY FLAG = 'X'.

IF SY-SUBRC = 0.

SORT ITAB DESCENDING BY (<FS_TCL1>-screen-name+5).

ENDIF.

ENDCASE.

ENDMODULE. " USER_COMMAND INPUT

&----


*& Module UPDATE_MOD INPUT

&----


  • text

----


MODULE UPDATE_MOD INPUT.

CASE OK_CODE.

WHEN 'SAVE'.

UPDATE ZSD_TABL_ORDBANK FROM ITAB .

STS = SY-SUBRC .

IF STS NE 0.

MESSAGE E003(ZQOTBANK) .

ENDIF.

ENDCASE.

ENDMODULE. " UPDATE_MOD INPUT

&----


*& Module EXIT_COMAND INPUT

&----


  • text

----


MODULE EXIT_COMAND INPUT.

CASE OK_CODE.

WHEN 'BACK'.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = 'Order Bank Entry'

TEXT_QUESTION = 'Do you want to Go BacK ?'

TEXT_BUTTON_1 = 'Yes'

TEXT_BUTTON_2 = 'No'

DEFAULT_BUTTON = '2'

IMPORTING

ANSWER = ANSWER.

IF ANSWER = '1'.

LEAVE TO SCREEN 0.

ELSE.

ENDIF.

WHEN '%EX'.

CALL FUNCTION 'POPUP_TO_CONFIRM'

EXPORTING

TITLEBAR = 'Order Bank Entry'

TEXT_QUESTION = 'Do you want to Exit ?'

TEXT_BUTTON_1 = 'Yes'

TEXT_BUTTON_2 = 'No'

DEFAULT_BUTTON = '2'

IMPORTING

ANSWER = ANSWER.

IF ANSWER = '1'.

LEAVE TO SCREEN 0.

ELSE.

ENDIF.

ENDCASE.

ENDMODULE. " EXIT_COMAND INPUT

Tnx advance

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't think that FLAG is one of the fields in the Table control structure.

Instead of FLAG, use the field SELECTED.

SELECTED is one of the fields in the structure of the table control

Regards,

Rich Heilman

Message was edited by: Rich Heilman

Message was edited by: Rich Heilman

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't think that FLAG is one of the fields in the Table control structure.

Instead of FLAG, use the field SELECTED.

SELECTED is one of the fields in the structure of the table control

Regards,

Rich Heilman

Message was edited by: Rich Heilman

Message was edited by: Rich Heilman

0 Kudos

Thnx John in sharing your views

thnx a lot Rich , it has solved my problem .

i m grateful to u all , Really u people r helpful.

bye , have great time .

0 Kudos

Rich , John , Poornanad & all

Actually it removed my error but the records are not getting sorted based on the coloumn selected .

Please throw some light on this issue kindly.

Thnx

0 Kudos

Hi Moni,

In general, when you use Field-Symbols, either the program works or you get a dump :-). So are you getting a dump in this case ? I hope not....

Anyways, here's what you should try out:

1. Put a breakpoint at the SORT statements.

2. Execute the program and see if the control is coming to the SORT statement.

3. If not, then revisit the previous logic.

4. If yes, then see what is the value of <FS>.

5. Please get back with results and rewards...Just kidding..:-)

Regards,

Anand Mandalika.

Regards,

Former Member
0 Kudos

Hi md,

With the definition:

CONTROLS: TCL1 TYPE TABLEVIEW USING SCREEN 0200.

you will define a complex data type of type 'CXTAB_COLUMN'. One of the elements of this structure is COLS which in turn is a standard table of CXTAB_COLUMN (take a look a type pool CXTAB!),

The structure CXTAB_COLUMN however doesn't contain an element FLAG; this is the reason why you get an error message.

Regards,

John.

andreas_mann3
Active Contributor
0 Kudos

Hi MD,

here's a piece of code from test-abap RSDEMO_TABLE_CONTROL

READ TABLE TABLE_CONTROL-COLS INTO COL WITH KEY SELECTED = 'X'.

SPLIT COL-SCREEN-NAME AT '-' INTO HELP FLDNAME.

SORT SDYN_ITAB BY (FLDNAME).

regards Andreas

0 Kudos

> Hi MD,

>

> here's a piece of code from test-abap

> RSDEMO_TABLE_CONTROL

>

> READ TABLE TABLE_CONTROL-COLS INTO COL WITH KEY

> TH KEY SELECTED = 'X'.

> SPLIT COL-SCREEN-NAME AT '-' INTO HELP

> O HELP FLDNAME.

> SORT SDYN_ITAB BY (FLDNAME).

>

> regards Andreas

I'm not a big fan of field symbols, so if its not working, I would suggest doing something like what Andreas has suggested. This is usually the way I do it also, and it works great.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Moni,

The Problem is with the READ statement.

READ TABLE TCL1-COLS ASSIGNING <FS_TCL1> WITH KEY FLAG = 'X'.

The structure of TCL1 is different from what you think. TCL1 will be a deep structure with an internal table COLS. Now this internal table COLS will have the standard structure:

SCREEN
INDEX
SELECTED
VISLENGTH
INVISIBLE

The Read statement tries to find a field of name FLAG in the TCL1-COLS structure. Therefore you get the error.

Try to read the COLS table with a correct key.

Regards,

Anand Mandalika.