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

Table control

Former Member
0 Likes
999

Hi

I have a i/o text and table control in a screen.

I want to enter details in table control and then

store it in table. I don't have problem in that process,

but I am facing problem in one user requirement.

My users says that they will add data in one cell in table

control and press ENTER and then the cursor should move

to the NEXT CELL. And when it comes to last cell and he

presses enter then cursor should move to the next row in

the table control.

Is it possible to manipulate table control and cursor

movement like this.

Regards

Prajwal.k

8 REPLIES 8
Read only

Former Member
0 Likes
697

Hi Prajwal

i have one table control program i think it may u help help.

REPORT zsiva_bdctable .

*include bdcrecx1.

TYPES : BEGIN OF ty_head,

auart(4),

vkorg(4), "Sales Organization

vtweg(2), "Distribution Channel

spart(2), "Division

kunnr(10), "sold-to-party

bstkd(10), "Customer purchase order number

END OF ty_head.

TYPES: BEGIN OF ty_item,

matnr(18) TYPE c, "Material

kwmeng(13) TYPE c, "Quantity

END OF ty_item.

DATA: it_head TYPE TABLE OF ty_head.

DATA: wa_head LIKE LINE OF it_head.

DATA: it_item TYPE TABLE OF ty_item.

DATA: wa_item LIKE LINE OF it_item.

DATA :bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA:v_kwmeng(30) TYPE c,

v_mabnr(30) TYPE c.

DATA: val(2) TYPE n VALUE 01.

DATA : w_file2 TYPE string,

w_file1 TYPE string.

PARAMETERS: filename LIKE rlgrap-filename.

PARAMETERS: filenam1 LIKE rlgrap-filename.

****************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = filename.

******************************************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filenam1.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = filenam1.

*******************************************************

START-OF-SELECTION.

w_file2 = filename.

w_file1 = filenam1.

                              • HEADER ************************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file2

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_head.

                              • ITEM *******************

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_file1

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_item.

**********CREATE SESSION***************

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = 'TABLECONT'

keep = 'X'

user = sy-uname.

******POPULATE BDCDATABLE***************

  • PERFORM open_group.

LOOP AT it_head INTO wa_head.

PERFORM bdc_dynpro USING 'SAPMV45A' '0101'.

PERFORM bdc_field USING 'BDC_CURSOR'

'VBAK-AUART'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'VBAK-AUART'

wa_head-auart.

PERFORM bdc_field USING 'VBAK-VKORG'

wa_head-vkorg.

PERFORM bdc_field USING 'VBAK-VTWEG'

wa_head-vtweg.

PERFORM bdc_field USING 'VBAK-SPART'

wa_head-spart.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'VBKD-BSTKD'

wa_head-bstkd.

PERFORM bdc_field USING 'VBKD-BSTDK'

'30.01.2006'.

PERFORM bdc_field USING 'KUAGV-KUNNR'

wa_head-kunnr.

PERFORM bdc_field USING 'RV45A-KETDAT'

'30.01.2006'.

PERFORM bdc_field USING 'RV45A-KPRGBZ'

'D'.

PERFORM bdc_field USING 'VBKD-ZTERM'

'0001'.

PERFORM bdc_field USING 'VBKD-INCO1'

'CIF'.

PERFORM bdc_field USING 'VBKD-INCO2'

' COST INSUSRABCE FRIEGHT'.

LOOP AT it_item INTO wa_item .

CONCATENATE 'RV45A-MABNR(' '0' val ')' INTO v_mabnr.

CONCATENATE 'RV45A-KWMENG(' '0' val ')' INTO v_kwmeng.

  • PERFORM bdc_field USING 'BDC_CURSOR'

  • v_kwmeng.

PERFORM bdc_field USING v_mabnr

wa_item-matnr.

PERFORM bdc_field USING v_kwmeng

wa_item-kwmeng.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

val = val + 1.

IF val > 5.

val = 5.

ENDIF.

ENDLOOP.

val = 01.

PERFORM bdc_dynpro USING 'SAPMV45A' '4001'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=SICH'.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = 'VA01'

TABLES

dynprotab = bdcdata.

REFRESH bdcdata.

*PERFORM bdc_transaction USING 'VA01'.

ENDLOOP.

  • PERFORM close_group.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

----


  • Start new screen *

----


FORM bdc_dynpro USING program dynpro.

CLEAR bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

APPEND bdcdata.

ENDFORM. "BDC_DYNPRO

----


  • Insert field *

----


FORM bdc_field USING fnam fval.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

ENDFORM. "BDC_FIELD

try it....

Read only

Former Member
0 Likes
697

Hi prajwal,

i think you can use GET CURSOR and SET CURSOR.

GET CURSOR - field_properties

Syntax

... [VALUE val] [LENGTH len] [OFFSET off] [LINE lin] [AREA area].

Extras:

1. ... VALUE val

2. ... LENGTH len

3. ... OFFSET off

4. ... LINE lin

5. ... AREA area

Effect

Using these additions, further information on the cursor position can be imported during PAI processing if the addition FIELD is attached to the statement GET CURSOR.

Addition 1

... VALUE val

Effect

The VALUE addition assigns the formatted content of the screen element on which the cursor is positioned to the data object val as a character string. For val, a character-type (prior to Release 6.10 flat) variable is expected.

Addition 2

... LENGTH len

Effect

The addition LENGTH assigns the length of the screen element on which the cursor is positioned to the data object len. For len, a variable of the type i is expected.

Addition 3

... OFFSET off

Effect

The addition OFFSET assigns the position of the cursor within the screen element on which the cursor is positioned to the data object off />. For off, a variable of the type i is expected.

Addition 4

... LINE lin

Effect

If the screen element on which the cursor is positioned is within a table control or a step loop, the addition assigns the number of the row of the table control or the group of the step loop to the LINE data object lin. Otherwise, lin is set to 0. For lin, a variable of the type i is expected.

Addition 5

... AREA area

Effect

If the screen element on which the cursor is positiioned is within a table control, the addition AREA assigns the name of the table control to the data object area. Otherwise, area is initialized. For area, a character-type (prior to Release 6.10 flat) variable is expected.

SET CURSOR - Dynpro

Syntax

SET CURSOR { { FIELD field [LINE line] [[DISPLAY] OFFSET off] }

| { col lin } }.

Alternatives:

1. ... FIELD field [LINE line] [[DISPLAY] OFFSET off]

2. ... col lin

Effect:

During PBO processing, this statement sets the cursor in the screen layout of the current screen. The cursor can be positioned by entering a screen element after FIELD or by entering a specific position using col and lin. Outside of PBO processing, the cursor is positioned in the next list displayed on the screen.

If the SET CURSOR statement is not specified, depending on the definition of the screen, the cursor is set according to the following hierarchy:

On the cursor position determined statically in the screen properties,

On the first input field of the screen,

On the first screen element of the screen,

On the input field in the systemtoolbar.

The latter also applies if the input field in the system toolbar is not displayed.

Alternative 1

... FIELD field [LINE line] [[DISPLAY] OFFSET off]

Effect

: The cursor is positioned on the screen element whose name is contained in upper case in field. The data object field must be character-type and flat. The screen layout or a table control is scrolled in the display so that the screen element on which the cursor is positioned is visible. If the specified screen element is not found, the statement is ignored.

If the specified screen element is part of a table control or a step loop, the line of the table control or group of the step loop in which the cursor is positioned on the specified screen element must be specified using the addition LINE. For the data object line, the type i is expected. If there is no line or group for the value of line, or the addition LINE is not specified, the statement is ignored. The statement is also ignored if the addition LINE is specified and the screen element is not part of a table control or step loop.

If the addition OFFSET is not specified, the cursor is set to the first position of the screen element. Using the addition OFFSET, the cursor can be set to the position in a screen element entered in off. In this case, the counting begins at 0. The position of the cursor is only visible in input/output fields. In other screen elements, the whole element is selected. For the data object off, the type i is expected. If the value of off is greater than the length of the screen element, the addition is ignored. If the value of off is negative, the cursor is positioned at the end of the screen element. As of release 6.20, the addition DISPLAY is standard and can be omitted.

Alternative 2

... col lin

Effect:

The cursor is positioned in the column specified in col and the line specified in lin in the screen layout, if a screen element is available in this position that is not part of a table control or tabstrip control. For col and lin, data objects of type i are expected. The counting of the columns starts at 2. If the screen element is not an input/output field, the whole element is selected. If no screen element is available at the specified positions, or if the cursor is positioned in a table control or tabstrip control, or if negative values are entered in col or lin, the statement is ignored.

Thanks,

Kunjal

Read only

Former Member
0 Likes
697

Hey,

I am not sure about this method,one can try it. If you are using the Table control wizard the tc structure created by it has a field current_line which specifies the current line.

Now in PBO you can use this info and by using the abap command 'Set cursor' you can change the position of the cursor.

Also system field sy-cucol gives info about current cursor position.

Regards,

Anubhav

Read only

Former Member
0 Likes
697

hi,

here is code for moving next line by pressing enter.......

DATA: cur_lin TYPE i VALUE 1,

nxt_line TYPE i,

f TYPE i.

DATA: fld(25) TYPE c VALUE 'ITAB-MATNR'.

in PAI write like,

MODULE user_command_1000 INPUT.

ok_code = sy-ucomm.

CASE ok_code.

WHEN 'BACK' OR 'UP' OR 'CANC'.

LEAVE PROGRAM.

<b> WHEN ' '.

GET CURSOR LINE cur_lin.

f = 1.

ENDCASE.</b>

ENDMODULE. " USER_COMMAND_1000 INPUT

and in PBO write like,

MODULE tab1_change_tc_attr OUTPUT.

<b> IF sy-ucomm <> ''.

DESCRIBE TABLE itab LINES tab1-lines.

ENDIF.

IF sy-ucomm = '' AND f = 1.

nxt_line = cur_lin + 1.

SET CURSOR FIELD fld LINE nxt_line.

ENDIF.</b>

ENDMODULE. "TAB1_CHANGE_TC_ATTR OUTPUT

reward if useful

Read only

0 Likes
697

This message was moderated.

Read only

Former Member
0 Likes
697

CHECK THE STANDARD REPORT

RSDEMO_TABLE_CONTROL

DEMO_DYNPRO_TABLE_CONTROL_2

Read only

Former Member
0 Likes
697

hi

when u press enter pai gets executed.

so in pai

case sy-ucomm.

when 'ENTER'.

***write ur logic and

set cursor field f1.

endcase

Regards

Sajid

Read only

Former Member
0 Likes
697

Hi,

Use set and get cursor .......

In your PBO...

loop at t_table with control table_control

cursor t_table-current_line.

endloop.

In PAI.

Case okcode.

when 'ENTER'.

set cursor fieldname...

endcase.