Hi to all,
i wanted to add select-options for the below coding, i failed in try to add the select-options {for exp vbeln and matnr}...so plese tell me to what are the changes and how to do...
&----
*& Module pool SAPMZ123 *
*& *
&----
*& *
*& *
&----
PROGRAM SAPMZ123 .
*&SPWizard: Data incl. inserted by SP Wizard. DO NOT CHANGE THIS LINE!
&----
*& Include MZ123TOP *
&----
***&spwizard: data declaration for tablecontrol 'ITAB'
*&spwizard: definition of ddic-table
tables: VBAP.
*&spwizard: declaration of tablecontrol 'ITAB' itself
controls: ITAB type tableview using screen 0100.
*&spwizard: type for the data of tablecontrol 'ITAB'
types: begin of t_ITAB,
VBELN like VBAP-VBELN,
POSNR like VBAP-POSNR,
MATNR like VBAP-MATNR,
MATWA like VBAP-MATWA,
end of t_ITAB.
*&spwizard: internal table for tablecontrol 'ITAB'
data: g_ITAB_itab type t_ITAB occurs 0,
g_ITAB_wa type t_ITAB. "work area
data: g_ITAB_copied. "copy flag
*&spwizard: lines of tablecontrol 'ITAB'
data: g_ITAB_lines like sy-loopc.
DATA: OKCODE LIKE SY-UCOMM.
*&SPWizard: Include inserted by SP Wizard. DO NOT CHANGE THIS LINE!
&----
*& module ITAB_init output *
&----
*&spwizard: output module for tc 'ITAB'. do not change this line!
*&spwizard: copy ddic-table to itab
module ITAB_init output.
if g_ITAB_copied is initial.
*&spwizard: copy ddic-table 'VBAP'
*&spwizard: into internal table 'g_ITAB_itab'
select * from VBAP
into corresponding fields
of table g_ITAB_itab.
g_ITAB_copied = 'X'.
refresh control 'ITAB' from screen '0100'.
endif.
endmodule.
*&spwizard: output module for tc 'ITAB'. do not change this line!
*&spwizard: move itab to dynpro
module ITAB_move output.
move-corresponding g_ITAB_wa to VBAP.
endmodule.
*&spwizard: output module for tc 'ITAB'. do not change this line!
*&spwizard: get lines of tablecontrol
module ITAB_get_lines output.
g_ITAB_lines = sy-loopc.
endmodule.
&----
*& module ITAB_user_command input *
&----
*&spwizard: input module for tc 'ITAB'. do not change this line!
*&spwizard: process user command
module ITAB_user_command input.
OKCODE = sy-ucomm.
perform user_ok_tc using 'ITAB'
'G_ITAB_ITAB'
'FLAG'
changing OKCODE.
sy-ucomm = OKCODE.
endmodule.
&----
*& MZ123F01 *
&----
----
TABLECONTROL_FORMS *
----
&----
*& Form USER_OK_TC *
&----
FORM USER_OK_TC USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME
CHANGING P_OK LIKE SY-UCOMM.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA: L_OK TYPE SY-UCOMM,
L_OFFSET TYPE I.
&SPWIZARD: END OF LOCAL DATA----
*&SPWIZARD: Table control specific operations *
*&SPWIZARD: evaluate TC name and operations *
SEARCH P_OK FOR P_TC_NAME.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
L_OFFSET = STRLEN( P_TC_NAME ) + 1.
L_OK = P_OK+L_OFFSET.
*&SPWIZARD: execute general and TC specific operations *
CASE L_OK.
WHEN 'INSR'. "insert row
PERFORM FCODE_INSERT_ROW USING P_TC_NAME
P_TABLE_NAME.
CLEAR P_OK.
WHEN 'DELE'. "delete row
PERFORM FCODE_DELETE_ROW USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
CLEAR P_OK.
WHEN 'P--' OR "top of list
'P-' OR "previous page
'P+' OR "next page
'P++'. "bottom of list
PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
L_OK.
CLEAR P_OK.
WHEN 'L--'. "total left
PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME.
*
WHEN 'L-'. "column left
PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME.
*
WHEN 'R+'. "column right
PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME.
*
WHEN 'R++'. "total right
PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME.
*
WHEN 'MARK'. "mark all filled lines
PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'DMRK'. "demark all filled lines
PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
CLEAR P_OK.
WHEN 'SASCEND' OR
'SDESCEND'. "sort column
PERFORM FCODE_SORT_TC USING P_TC_NAME
l_ok.
ENDCASE.
ENDFORM. " USER_OK_TC
&----
*& Form FCODE_INSERT_ROW *
&----
FORM fcode_insert_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_LINES_NAME LIKE FELD-NAME.
DATA L_SELLINE LIKE SY-STEPL.
DATA L_LASTLINE TYPE I.
DATA L_LINE TYPE I.
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE CXTAB_CONTROL.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME.
ASSIGN (L_LINES_NAME) TO <LINES>.
*&SPWIZARD: get current line *
GET CURSOR LINE L_SELLINE.
if sy-subrc <> 0. " append line to table
l_selline = <tc>-lines + 1.
*&SPWIZARD: set top line *
if l_selline > <lines>.
<tc>-top_line = l_selline - <lines> + 1 .
else.
<tc>-top_line = 1.
endif.
else. " insert line into table
l_selline = <tc>-top_line + l_selline - 1.
l_lastline = <tc>-top_line + <lines> - 1.
endif.
*&SPWIZARD: set new cursor line *
l_line = l_selline - <tc>-top_line + 1.
*&SPWIZARD: insert initial line *
INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE.
<TC>-LINES = <TC>-LINES + 1.
*&SPWIZARD: set cursor *
SET CURSOR LINE L_LINE.
ENDFORM. " FCODE_INSERT_ROW
&----
*& Form FCODE_DELETE_ROW *
&----
FORM fcode_delete_row
USING P_TC_NAME TYPE DYNFNAM
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: delete marked lines *
DESCRIBE TABLE <TABLE> LINES <TC>-LINES.
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
IF <MARK_FIELD> = 'X'.
DELETE <TABLE> INDEX SYST-TABIX.
IF SY-SUBRC = 0.
<TC>-LINES = <TC>-LINES - 1.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FCODE_DELETE_ROW
&----
*& Form COMPUTE_SCROLLING_IN_TC
&----
text
----
-->P_TC_NAME name of tablecontrol
-->P_OK ok code
----
FORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME
P_OK.
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TC_NEW_TOP_LINE TYPE I.
DATA L_TC_NAME LIKE FELD-NAME.
DATA L_TC_LINES_NAME LIKE FELD-NAME.
DATA L_TC_FIELD_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <LINES> TYPE I.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get looplines of TableControl *
CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME.
ASSIGN (L_TC_LINES_NAME) TO <LINES>.
*&SPWIZARD: is no line filled? *
IF <TC>-LINES = 0.
*&SPWIZARD: yes, ... *
L_TC_NEW_TOP_LINE = 1.
ELSE.
*&SPWIZARD: no, ... *
CALL FUNCTION 'SCROLLING_IN_TABLE'
EXPORTING
ENTRY_ACT = <TC>-TOP_LINE
ENTRY_FROM = 1
ENTRY_TO = <TC>-LINES
LAST_PAGE_FULL = 'X'
LOOPS = <LINES>
OK_CODE = P_OK
OVERLAPPING = 'X'
IMPORTING
ENTRY_NEW = L_TC_NEW_TOP_LINE
EXCEPTIONS
NO_ENTRY_OR_PAGE_ACT = 01
NO_ENTRY_TO = 02
NO_OK_CODE_OR_PAGE_GO = 03
OTHERS = 0.
ENDIF.
*&SPWIZARD: get actual tc and column *
GET CURSOR FIELD L_TC_FIELD_NAME
AREA L_TC_NAME.
IF SYST-SUBRC = 0.
IF L_TC_NAME = P_TC_NAME.
*&SPWIZARD: et actual column *
SET CURSOR FIELD L_TC_FIELD_NAME LINE 1.
ENDIF.
ENDIF.
*&SPWIZARD: set the new top line *
<TC>-TOP_LINE = L_TC_NEW_TOP_LINE.
ENDFORM. " COMPUTE_SCROLLING_IN_TC
&----
*& Form FCODE_TC_MARK_LINES
&----
marks all TableControl lines
----
-->P_TC_NAME name of tablecontrol
----
FORM FCODE_TC_MARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME.
&SPWIZARD: EGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: mark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = 'X'.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
&----
*& Form FCODE_TC_DEMARK_LINES
&----
demarks all TableControl lines
----
-->P_TC_NAME name of tablecontrol
----
FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME
P_TABLE_NAME
P_MARK_NAME .
&SPWIZARD: BEGIN OF LOCAL DATA----
DATA L_TABLE_NAME LIKE FELD-NAME.
FIELD-SYMBOLS <TC> TYPE cxtab_control.
FIELD-SYMBOLS <TABLE> TYPE STANDARD TABLE.
FIELD-SYMBOLS <WA>.
FIELD-SYMBOLS <MARK_FIELD>.
&SPWIZARD: END OF LOCAL DATA----
ASSIGN (P_TC_NAME) TO <TC>.
*&SPWIZARD: get the table, which belongs to the tc *
CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body
ASSIGN (L_TABLE_NAME) TO <TABLE>. "not headerline
*&SPWIZARD: demark all filled lines *
LOOP AT <TABLE> ASSIGNING <WA>.
*&SPWIZARD: access to the component 'FLAG' of the table header *
ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>.
<MARK_FIELD> = SPACE.
ENDLOOP.
ENDFORM. "fcode_tc_mark_lines
----
***INCLUDE MZ123_USER_COMMAND_0100I01 .
----
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
OKCODE = SY-UCOMM.
CLEAR SY-UCOMM.
CASE OKCODE.
WHEN 'BACK'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
************************PBO and PAI*****
process before output.
*&spwizard: pbo flow logic for tablecontrol 'ITAB'
test2(10) TYPE c MODIF ID sc2,
test3(10) TYPE c MODIF ID sc1,
test4(10) TYPE c MODIF ID sc2.
module itab_init.
*&spwizard: module ITAB_change_tc_attr.
*&spwizard: module ITAB_change_col_attr.
loop at g_itab_itab
into g_itab_wa
with control itab
cursor itab-current_line.
*&spwizard: module ITAB_change_field_attr
module itab_move.
module itab_get_lines.
endloop.
MODULE STATUS_0100.
*
process after input.
*&spwizard: pai flow logic for tablecontrol 'ITAB'
loop at g_itab_itab.
chain.
field vbap-vbeln.
field vbap-posnr.
field vbap-matnr.
field vbap-matwa.
endchain.
endloop.
module itab_user_command.
*&spwizard: module ITAB_change_tc_attr.
*&spwizard: module ITAB_change_col_attr.
module user_command_0100.
THANKS IN ADVANCE....
RAJU...
Message was edited by: mpr raju