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
771

hi experts,

i ve cretaed my own Z table and i ve to insert new records as well update them when necessary..

now i ve a table control for that..so how i can insert and update my ztable with table control..

can it be directly inserted/updated or i ve to take an internal table and do it..

please elaborate..

pints will be rewarded,

thanks in advance,

sneha..

7 REPLIES 7
Read only

Former Member
0 Likes
628

Hi Sneha

Pls check the below material, it will surely help 2 u.

Pls reward pts if help.

Deepanker

syntax:

CONTROLS .

if you only want to determine the row of the table control. SY´-SUBRC allows you to check if the cursor is placed in a row of a table control.

u need to comment the performs of table control fields and write ur own perform statements. And u have to declare the table control fields as separate internal tables.

Go through this urls.

www.saptechnical.com

www.sap-img.com

Check the below links.

just refer to the link below

http://www.sapmaterial.com/tablecontrol_sap.html

step by step procedure with screen shots

http://www.planetsap.com/howdo_a.htm

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm

http://sap.niraj.tripod.com/id25.html

Also you can see the below examples...

Go to se38 and give demodynpro and press F4.

YOu will get a list of demo module pool programs.

One more T-Code is ABAPDOCU.

YOu can find more examples there.

See the prgrams:

DEMO_DYNPRO_TABLE_CONTROL_1 Table Control with LOOP Statement

DEMO_DYNPRO_TABLE_CONTROL_2 Table Control with LOOP AT ITAB

http://www.geocities.com/ZSAPcHAT

http://www.allsaplinks.com/files/using_table_in_screen.pdf

Pls reward pts if help.

Read only

Former Member
0 Likes
628

Hi Sneha,

I will send a sample code for ur problem check it once.That will clear ur problem ok...

In SET PF-STATUS 'AAA' :

We have to activate SAVE button and create one new push button INSERT in the application toolbar after then follow the below logic ok..

For Insert:

when 'INSE'.

*NO.OF Recors in the Internal Table

describe table gt_item lines gv_lines.

read table gt_item index my_table-current_line.

gv_temp = gv_temp + 1.

if gv_temp gt gv_lines.

*Insert Record into Internal Table

insert table gt_item.

*Insert Record into Database Table

insert into yvbap values gt_item.

endif.

For Update:

*Modify Data in the Internal Table

modify gt_item index my_table-current_line.

if sy-subrc eq 0.

*Modify Data in the Database Table

modify yvbap from table gt_item.

endif.

Award Points If Helpful.

Kiran Kumar.G

Have a Nice Day..

Read only

0 Likes
628

hi,

but i am not getting exactly hoe to populate the ztable from my screen (module pool)?

please let me know?

do i ve to tek another internal table and if yes how do i populate it from my screen..

it will be like populatinf the table from my screen again from that internal table tof inal ztable..

im confused!!

Read only

0 Likes
628

Hi,

Populate data in that ZTABLE, its an internal table and populate it the same way you populate an internal table. It containd all the fields which you have in Table Control.

Do this in PBO module .

Regards,

Mandeep

Read only

Former Member
0 Likes
628

Hi,

Check this demo program demo_dynpro_tabcont_loop_at

Regards,

Mandeep

Read only

Former Member
0 Likes
628

Hope this helps u

TABLE CONTROL

These are the screen elements used to display tabular data they can be called

as screen tables( like STEP LOOP).To use table control we have to create it on the screen using SCREEN PAINTER(SE51) and declare a control variable of TYPE TABLEVIEW using CONTROLS statement in the ABAP program. We have to use LOOP .. ENDLOOP statement in both PBO and PAI with or without AT int_table parameter. IF AT int_table parameter is not used than we have to place a MODULE call between the LOOP...ENDLOOP statement to fill the screen table rows from the ABAP program in PBO and program our own scrolling functions

using OK_CODE field.

Having a parallel loop(at screen table rows & int table rows) by using parameter

AT int_table makes the ABAP code simple.

A special structure of type CXTAB_CONTROL is used to set/get various

attributes of table control at runtime like CURRENT_LINE ,TOP_LINE.

ABAP declaration

CONTROLS: tab_con TYPE TABLEVIEW USING SCREEN nnnn

Here tab_con is the same name we used in screen for the table control.

This ABAP statement will declare a control variable that will be used to access

the table control , and set it's various attributes like number of fixed columns(tab_con-FIXED_COLS) ,total number of records it will display(tab_con-LINES).It is of type CXTAB_CONTROL and is a deep structure(structure containing structures).

REFRESH CONTROL tab_con FROM SCREEN nnnn

This ABAP statement will initialize the table control on the screen nnnn to its initial values.

PBO processing

In PBO we have to use the screen LOOP ...ENDLOOP statement , with or without

intenal table.

LOOP WITH CONTROL tab_con.

MODULE fill_tab_con.

ENDLOOP.

Here a module should be called between the loop endloop statement to transfer

data from th ABAP program to the screen table through a structure.This module

should use the CURRENT_LINE attribute of the table control variable to get the

current screen table record index to read the data from the internal table into a work area.

e.g.

READ TABLE int_table INDEX tab_con-CURRENT_LINE

The record read will be placed in the header line of the internal table and will be available to the similarly named screen fields or if these are different it can be written explicitly. e.g.

screen_field_name = int_table-field_name

...

.

LOOP AT int_table INTO workarea WITH CONTROL tab_con CURSOR i FROM

n1 TO n2.

ENDLOOP.

Here the module call is not required to fill the screen table.The CURSOR parameter is a integer of type I indicating which absolute internal table line

should be the first to display on the table control .FROM n1 TO n2 can be used

to restrict the starting line and ending line number of the internal table , they are of type SY-TABIX.

In both cases before the LOOP statement a module should be called which

is generally for setting of status ,in which we should fill the LINES attribute

(tab_con-LINES ) of the control with the total number of internal table records,doing this ensures correct and automatic scrolling.

The ABAP statement DESCRIBE TABLE int_table LINES lines can be used

to get the total lines in an int table.

PAI Processing

We have to use LOOP ... ENDLOOP in PAI so that data can transfer fro table control to ABAP program. If we want to write changes to the data we should

call a module between the LOOP ... ENDLOOP. The MODULE call to process user commands (SY-UCOM) should be called after the ENDLOOP statement.

e.g.

PROCESS AFTER INPUT

MODULE mod AT EXIT-COMMAND.

LOOP AT itab_table or LOOP "depending on whether we are using AT int_table

MODULE modify_int_table.

ENDLOOP.

MODULE user_command.

In the MODULE call modify_int_table we can use

MODIFY int_table FROM workarea INDEX tab_con-CURRENT_LINE

or we can use

int_table-field_name = screen_field_name.

Read only

Former Member
0 Likes
628

sneha

separate internal table is not needed at all.

While creating screen fields mark them as data dictionary fields and put their names as there in data base table(Z table).

that means the names should be like lfa1-lifnr.

Then you can insert data into database table with out any internal table.

We can use the statements :

insert ztablename.

So that the whole data in the table control will be inserted.

If useful award me points.