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

bdc for XK02 getting problem in table control?????

Former Member
0 Likes
663

hello i want to migrate data for vendor.i want to update VAT date and VAT number. but i m not getting how to handle index of table control? coz when we scroll down index get changed......

pls guide me......

hello i want to migrate data for vendor.i want to update VAT date and VAT number. but i m not getting how to handle index of table control? coz when we scroll down index get changed......

pls guide me......

2 REPLIES 2
Read only

Former Member
0 Likes
538

hi ashu loya,

Table Controls

ABAP offers two mechanisms for displaying and using table data in a screen. These mechanisms are table controls and step

loops. Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter. For example,

the following screen contains a table control at the bottom:

This chapter describes how to program the screen flow logic and ABAP code that let you use screen tables. For information

on using screen tables, see:

Table Controls in the Flow Logic

Looping Through an Internal Table

Systemfelder

Datentransports

The following statement loops through an internal table and a screen table in parallel.

LOOP AT <internal table>.

In particular, LOOP AT loops through the portion of the internal table that is currently visible in the screen. You can use this form of

the LOOP statement for both table controls and step loops.

The complete syntax for this form of the LOOP statement is:

LOOP AT <internal table> CURSOR <scroll-var>

[WITH CONTROL <table-control> ]

[FROM <line1> ] [TO <line2> ].

...<actions>...

ENDLOOP.

This form of LOOP loops through the internal table, performing <actions> for each row. For each internal table row, the system

transfers the relevant program fields to or from the corresponding screen table row.

When using step loops, omit the CURSOR parameter in the PAI event. The FROM and TO parameters are only possible with step loops.

(For further information, refer to Using Step Loops.) The WITH CONTROL parameter is only for use with table controls.

For further information, refer to the following sections:

How the System Transfers Data Values

Scrolling and the Scroll Variables

Table Controls: Example with Browser

Table Controls: Examples with Scrolling

The following example processes a table control with LOOP without parallel loop using an internal table. In addition to the scroll bar,

the user can also carry out program-controlled scrolling with function codes.

REPORT demo_dynpro_tabcont_loop.

CONTROLS flights TYPE TABLEVIEW USING SCREEN 100.

DATA: ok_code TYPE sy-ucomm,

save_ok TYPE sy-ucomm.

DATA: itab TYPE TABLE OF demo_conn,

fill TYPE i.

TABLES demo_conn.

DATA: lines TYPE i,

limit TYPE i.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE itab.

CALL SCREEN 100.

MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

DESCRIBE TABLE itab LINES fill.

flights-lines = fill.

ENDMODULE.

MODULE fill_table_control OUTPUT.

READ TABLE itab INTO demo_conn INDEX flights-current_line.

ENDMODULE.

MODULE cancel INPUT.

LEAVE PROGRAM.

ENDMODULE.

MODULE read_table_control INPUT.

lines = sy-loopc.

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 'NEXT_LINE'.

flights-top_line = flights-top_line + 1.

limit = fill - lines + 1.

IF flights-top_line > limit.

flights-top_line = limit.

ENDIF.

WHEN 'PREV_LINE'.

flights-top_line = flights-top_line - 1.

IF flights-top_line < 0.

flights-top_line = 0.

ENDIF.

WHEN 'NEXT_PAGE'.

flights-top_line = flights-top_line + lines.

limit = fill - lines + 1.

IF flights-top_line > limit.

flights-top_line = limit.

ENDIF.

WHEN 'PREV_PAGE'.

flights-top_line = flights-top_line - lines.

IF flights-top_line < 0.

flights-top_line = 0.

ENDIF.

WHEN 'LAST_PAGE'.

flights-top_line = fill - lines + 1.

WHEN 'FIRST_PAGE'.

flights-top_line = 0.

ENDCASE.

ENDMODULE.

Table Controls: Example with Modifications

Table Controls: Examples with Modifications

The following example processes a table control with LOOP with parallel loop using an internal table. By using function codes you can

sort columns and delete rows from the internal table. The ready for input status of the table control fields is controlled using a

function code.

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.

A resizable table control called FLIGHTS is defined. The fields of the table control are transferred from the structure DEMO_CONN in

the ABAP Dictionary. The first two columns are lead columns. The corresponding fields are output fields. A title bar, columns headers,

and a selection column are created. The component MARK of type character with length 1 from structure DEMO_CONN is assigned to

the selection column. You can select one column and several lines.

It has the following flow logic:

PROCESS BEFORE OUTPUT.

MODULE status_0100.

LOOP AT itab INTO demo_conn WITH CONTROL flights.

ENDLOOP.

PROCESS AFTER INPUT.

MODULE cancel AT EXIT-COMMAND.

LOOP AT itab.

MODULE read_table_control.

ENDLOOP.

MODULE user_command_0100.

A loop is executed at PBO and PAI using the table control FLIGHTS and is also executed using the internal table ITAB of the ABAP

program. During the PBO loop, no module is called to fill the table control from table ITAB of the ABAP program. However, during the

PAI loop, a module is called to modify table ITAB.

At PBO the component LINES of control structure FLIGHTS is filled explicitly with the current number of rows of the internal table

before the PBO loop to install the scroll bar of the table control.

During the PBO loop, in the module FILL_TABLE_CONTROL the work area DEMO_CONN is filled with values from the internal table,

where the row index corresponds to the current row of the table control.

During the PAI loop, the rows of the internal table, whose row index corresponds to the current row of the table control, are

overwritten with the contents of the work area DEMO_CONN. User input is transferred from the input fields of the control to the

internal table. In particular, the internal table also contains a flag in the column MARK to indicate whether the row of the table control

is selected or not.

After the PAI loop, user input is processed in the module USER_COMMAND. The GUI status SCREEN_100 provides the appropriate

function codes.

When the program is called not all of the fields in the table control are ready for input. The static specifications of the table control in

the Screen Painter are modified before CALL SCREEN in the program. The system uses the table COLS in control structure FLIGHTS.

All columns with a column position larger than two are set to not ready for input status in a loop using the table FLIGHT-COLS. By

choosing the function code TOGGLE, you can change the ready for input status of the columns.

The function codes SORT_UP and SORT_DOWN allow you to sort selected columns of the internal table ITAB ascending or

descending. The static settings of the table control allow you to select only a single column. The selected column is derived from the

internal table FLIGHT-COLS. The name of the sort criteria in the SORT statement is determined dynamically from the component

COLS-SCREEN-NAME. The prefix DEMO_CONN- must be removed using an offset specification. After sort the selection is undone, and

the component SELECTED in table FLIGHT-COLS is assigned a blank character.

You can delete selected rows from the internal table ITAB using the function code DELETE. First the system checks whether the fields

of the table control are ready for input. Then all selected rows are deleted in a loop using the internal table ITAB. Since the table

control is read again from the internal table in the PBO loop, the rows on the screen are deleted.

thanks abdul

Read only

Former Member
0 Likes
538

Hi

Table Control in BDC, Go through following Links :

http://www.sap-img.com/abap/bdc-example-using-table-control-in-bdc.htm

Rewards Points if useful

Ranjith.