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

Urgent Table control

Former Member
0 Likes
703

hi all,

i m making table control without wizard, but problem is that i dont know how would i display the data in table control?

can anybody please tell me step by step?

regards saurabh.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
667

Hi,

Follow the steps,you can get some idea regarding Table control

Follow the steps to update the database table records.

1.TOP INCLUDE code

TABLES: EKKO.

DATA: OK_CODE TYPE SY-UCOMM.

CONTROLS: TC100 TYPE TABLEVIEW USING SCREEN 100.

DATA: IT_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.

DATA: CUR TYPE I.

DATA: I_EKKO2 LIKE EKKO OCCURS 0 WITH HEADER LINE.

DATA: V_FNAM TYPE I,V_FVAL(10) TYPE N.

2.Create screen with number(e.g 123) and click on layout tab

Give the table control name as TC100.

SELECT THE FIELDS FROM INTERNAL TABLE (IT_EKKO). DRAG THE TEXT FIELDS INTO THE TABLE CONTROL FOR FIELD HEADINGS.

Create 4 pushbuttons(insert,fetch,delete and exit)

CLICK ON “Element list” TAB AND ENTER THE “OK_CODE”.

CLICK ON FLOWLOGIC TAB.

3.Flowlogic code

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT IT_EKKO CURSOR CUR WITH CONTROL TC100.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT IT_EKKO.

MODULE MODIFY_ITAB.

ENDLOOP.

MODULE USER_COMMAND_0100.

4.Double click on MODIFY_ITAB and write as

module MODIFY_ITAB input.

APPEND IT_EKKO TO I_EKKO2.

endmodule. " MODIFY_ITAB INPUT

5.Activate PAI and double click on it and write the code as

module USER_COMMAND_0100 input.

CASE OK_CODE.

WHEN 'INS'.

LOOP AT I_EKKO2.

MODIFY EKKO FROM I_EKKO2.

ENDLOOP.

SELECT * FROM EKKO INTO TABLE IT_EKKO.

IF SY-SUBRC = 0.

MESSAGE S003(ZCSMSG).

ENDIF.

WHEN 'FETCH'.

SELECT * FROM EKKO INTO TABLE IT_EKKO UP TO 2000 ROWS.

TC100-LINES = SY-DBCNT.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

6.Create Transaction code and execute it.

tell me ur id,i can forward screen shots if u could not able to get the solution.

Reward,if useful.

Thanks,

Chandu

hi all,

i m making table control without wizard, but problem is that i dont know how would i display the data in table control?

can anybody please tell me step by step?

regards saurabh.

4 REPLIES 4
Read only

Former Member
0 Likes
668

Hi,

Follow the steps,you can get some idea regarding Table control

Follow the steps to update the database table records.

1.TOP INCLUDE code

TABLES: EKKO.

DATA: OK_CODE TYPE SY-UCOMM.

CONTROLS: TC100 TYPE TABLEVIEW USING SCREEN 100.

DATA: IT_EKKO LIKE EKKO OCCURS 0 WITH HEADER LINE.

DATA: CUR TYPE I.

DATA: I_EKKO2 LIKE EKKO OCCURS 0 WITH HEADER LINE.

DATA: V_FNAM TYPE I,V_FVAL(10) TYPE N.

2.Create screen with number(e.g 123) and click on layout tab

Give the table control name as TC100.

SELECT THE FIELDS FROM INTERNAL TABLE (IT_EKKO). DRAG THE TEXT FIELDS INTO THE TABLE CONTROL FOR FIELD HEADINGS.

Create 4 pushbuttons(insert,fetch,delete and exit)

CLICK ON “Element list” TAB AND ENTER THE “OK_CODE”.

CLICK ON FLOWLOGIC TAB.

3.Flowlogic code

PROCESS BEFORE OUTPUT.

MODULE STATUS_0100.

LOOP AT IT_EKKO CURSOR CUR WITH CONTROL TC100.

ENDLOOP.

*

PROCESS AFTER INPUT.

LOOP AT IT_EKKO.

MODULE MODIFY_ITAB.

ENDLOOP.

MODULE USER_COMMAND_0100.

4.Double click on MODIFY_ITAB and write as

module MODIFY_ITAB input.

APPEND IT_EKKO TO I_EKKO2.

endmodule. " MODIFY_ITAB INPUT

5.Activate PAI and double click on it and write the code as

module USER_COMMAND_0100 input.

CASE OK_CODE.

WHEN 'INS'.

LOOP AT I_EKKO2.

MODIFY EKKO FROM I_EKKO2.

ENDLOOP.

SELECT * FROM EKKO INTO TABLE IT_EKKO.

IF SY-SUBRC = 0.

MESSAGE S003(ZCSMSG).

ENDIF.

WHEN 'FETCH'.

SELECT * FROM EKKO INTO TABLE IT_EKKO UP TO 2000 ROWS.

TC100-LINES = SY-DBCNT.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

6.Create Transaction code and execute it.

tell me ur id,i can forward screen shots if u could not able to get the solution.

Reward,if useful.

Thanks,

Chandu

Read only

Former Member
0 Likes
667

You need to display the data in PBO event of the transaction.

you need to pass line by line of data from internal table to to the table control,

u can check the sample code in ABAPDOCU transaction.

Regards,

SR

Read only

Former Member
0 Likes
667

Hi Saurabh,

Follow the steps,

1.Declare an internal table in the program ( with columns u want to display in tavle control).

2.create a screen and go to its layout.

3.press F6 or dictionary/program fields icon in the SAP menu.

4.select the internal table fields and drop it inside the table control.

5.In the flow logic declare one loop in PBO and one in the PAI.

Eg

In the program declare

*data : begin of it_vbap occurs 0,

  • sel type c,

  • posnr like vbap-posnr,

  • matnr like vbap-matnr,

  • arktx like vbap-arktx,

  • kwmeng like vbap-kwmeng,

  • vrkme like vbap-vrkme,

  • kwert like konv-kwert,

  • netwr like vbap-netwr,

  • end of it_vbap.

MODULE get_det INPUT

select posnr matnr arktx kwmeng vrkme netwr from vbap

into corresponding fields of table it_vbap

where vbeln eq it_vbak-vbeln.

End module .

Flow logic

PROCESS BEFORE OUTPUT.

MODULE STATUS_3000.

loop at it_vbap with control tab1 cursor tab1-current_line.

MODULE FILL_TABLE_CONTROL.

endloop.

*

PROCESS AFTER INPUT.

field it_vbak-vbeln module get_det.

*FIELD IT_vbak-VBELN MODULE READ_TABLE_CONTROL.

loop at it_vbap.

module read_table_control.

endloop.

MODULE USER_COMMAND_3000.

When u fill the internal table with data , u will find the table control getting filled with values.

Regards,

Charumathi.B

Read only

Former Member
0 Likes
667

hi see this sample code , its really simple.....

first create three includes using se80..

INCLUDE ZTCTOP . " Global Data

INCLUDE ZTCO01 . " PBO-Modules

INCLUDE ZTCI01 . " PAI-Modules

in globle data include do the following.

TABLES: LIKP,LIPS.

----


  • D E C L A R A T I O N O F I N T E R N A L T A B L E S

----


DATA: BEGIN OF IT_LIKP OCCURS 0,

VBELN LIKE LIKP-VBELN,

ERNAM LIKE LIKP-ERNAM,

ERZET LIKE LIKP-ERZET,

ERDAT LIKE LIKP-ERDAT,

END OF IT_LIKP.

DATA: BEGIN OF IT_LIPS OCCURS 0,

VBELN LIKE LIPS-VBELN,

POSNR LIKE LIPS-POSNR,

WERKS LIKE LIPS-WERKS,

LGORT LIKE LIPS-LGORT,

END OF IT_LIPS.

----


  • D E C L A R A T I O N O F G L O B A L V A R I A B L E S

----


DATA: MARK TYPE C VALUE 'X',

FILL TYPE I.

DATA: OK_CODE(4).

----


  • C O N T R O L S

----


CONTROLS: LIKP_DATA TYPE TABLEVIEW USING SCREEN 101,

LIPS_DATA TYPE TABLEVIEW USING SCREEN 102.

DATA: PCOL LIKE LINE OF LIKP_DATA-COLS,

SCOL LIKE LINE OF LIPS_DATA-COLS.

in PBO USE FOLLOWING SAMPLE CODE:

module STATUS_0100 output.

SET PF-STATUS 'CHANDU'.

SET TITLEBAR 'TABLECONTROL'.

endmodule. " STATUS_0100 OUTPUT

&----


*& Include ZTCO01

&----


&----


*& Module STATUS_0101 OUTPUT

&----


  • text

----


module STATUS_0101 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

DESCRIBE TABLE IT_LIKP LINES FILL.

LIKP_DATA-LINES = FILL.

endmodule. " STATUS_0101 OUTPUT

&----


*& Module ASSIGN_DATA OUTPUT

&----


  • text

----


module ASSIGN_DATA output.

MOVE-CORRESPONDING IT_LIKP TO LIKP.

endmodule. " ASSIGN_DATA OUTPUT

&----


*& Module STATUS_0102 OUTPUT

&----


  • text

----


module STATUS_0102 output.

  • SET PF-STATUS 'xxxxxxxx'.

  • SET TITLEBAR 'xxx'.

DESCRIBE TABLE IT_LIPS LINES FILL.

LIPS_DATA-LINES = FILL.

endmodule. " STATUS_0102 OUTPUT

&----


*& Module ASSIGN_DATA_LIPS OUTPUT

&----


  • text

----


module ASSIGN_DATA_LIPS output.

MOVE-CORRESPONDING IT_LIPS TO LIPS.

endmodule. " ASSIGN_DATA_LIPS OUTPUT

IN PAI SAMPLE CODE:

module USER_COMMAND_0100 input.

CASE OK_CODE.

WHEN 'LIKP'.

IF LIKP-VBELN IS INITIAL.

MESSAGE 'PLZ ENTER NUMBER' TYPE 'I'.

SET SCREEN 100.

ELSEIF LIKP-VBELN EQ 0.

MESSAGE 'PLZ ENTER VALID NUMBER' TYPE 'I'.

SET SCREEN 100.

ELSE.

SELECT VBELN

ERNAM

ERZET

ERDAT FROM LIKP

INTO TABLE IT_LIKP.

ENDIF.

IF NOT IT_LIKP[] IS INITIAL.

CALL SCREEN 101.

ENDIF.

CLEAR LIKP_DATA.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Module USER_COMMAND_0101 INPUT

&----


  • text

----


module USER_COMMAND_0101 input.

CASE OK_CODE.

WHEN 'LIPS'.

READ TABLE IT_LIKP.

SELECT VBELN

POSNR

WERKS

LGORT

FROM LIPS

INTO TABLE IT_LIPS

WHERE VBELN = IT_LIKP-VBELN.

IF SY-SUBRC = 0.

call screen 102.

ENDIF.

WHEN 'BACK'.

SET SCREEN 100.

ENDCASE.

endmodule. " USER_COMMAND_0101 INPUT

&----


*& Module USER_COMMAND_0102 INPUT

&----


  • text

----


module USER_COMMAND_0102 input.

CASE OK_CODE.

WHEN 'BACK'.

LEAVE TO SCREEN 101.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

REWARD IF USEFUL

MANO