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
682

Hi Experts,

I have designed one table control in screen painter and now i need to transfer values to the database table by inputting the values in table control .

Can anybody tell me how do i imlement this.

Thanks, Izaz.

7 REPLIES 7
Read only

Former Member
0 Likes
652

hi...

when u enetr values and trigger some event the record will be there in internal table (used for table control)

u can directly insert record from that table to DB table.

regards

vivek

Read only

0 Likes
652

Can you please give me one example

Read only

0 Likes
652

example for ???

u can have save button and put a case ..endcase in PAI and check for the save buttons ok_code.

and there u can check the values in ur internal table

regards

vivek

Read only

0 Likes
652

Hi,

Vivek.

Check out the below example

I just updated the kna1 table by entering the values from table control

FLOW LOGIC



PROCESS BEFORE OUTPUT.
  LOOP AT it_kna1 WITH CONTROL table.
  ENDLOOP. 
  MODULE status_0343.                               " Check the module placement in PBO
*
PROCESS AFTER INPUT.
  LOOP.                     
    MODULE user_command_0343.              " Check the module placement in PAI
  ENDLOOP.

SOURCE CODE



PROGRAM  zp_modulepool_tabstrip.

TABLES : kna1.

DATA : it_kna1 TYPE TABLE OF kna1 WITH HEADER LINE.

CONTROLS : table TYPE TABLEVIEW USING SCREEN '343'.

*&---------------------------------------------------------------------*
*&      Module  user_command_0343  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0343 INPUT.

  CASE sy-ucomm.

    WHEN 'MODIFY'.

      MODIFY kna1.
      IF sy-subrc  EQ 0.
        MESSAGE 'SUCCESFULLY UPDATED INTO DATABASE' TYPE 'S'.
      ENDIF.

    WHEN 'EXIT'.
      LEAVE PROGRAM.

  ENDCASE.

ENDMODULE.   

regards

Prasanth

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
652

Hi Ahmed,

To update your database table from the table control on the screen, follow this code.

Its working.

***********************AT SCREEN 8004 FLOW LOGIC*************************************


PROCESS BEFORE OUTPUT.
  MODULE STATUS_8004.

  LOOP WITH CONTROL TAB.

  ENDLOOP.


PROCESS AFTER INPUT.

  MODULE EXIT AT EXIT-COMMAND.

  LOOP WITH CONTROL TAB.
    MODULE USER_COMMAND_8004.
  ENDLOOP.

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

**************************MODULE USER_COMMAND_8004********************************


MODULE USER_COMMAND_8004 INPUT.

  DATA B TYPE I.

  OK_CODE = SY-UCOMM.

  CASE OK_CODE.

    WHEN 'SAVE'.

      WA1-REL_YEAR = MOVIE_TAB2-REL_YEAR.
      WA1-CATEGORY = MOVIE_TAB2-CATEGORY.
      WA1-WINNER = MOVIE_TAB2-WINNER.
      WA1-NOMINEE1 = MOVIE_TAB2-NOMINEE1.
      WA1-NOMINEE2 = MOVIE_TAB2-NOMINEE2.
      WA1-NOMINEE3 = MOVIE_TAB2-NOMINEE3.
      WA1-NOMINEE4 = MOVIE_TAB2-NOMINEE4.
      WA1-NOMINEE5 = MOVIE_TAB2-NOMINEE5.
      WA1-NOTES = MOVIE_TAB2-NOTES.

      INSERT INTO Y00MOVIES VALUES WA1.

      IF SY-SUBRC = 0.
        B = B + 1.
        MESSAGE S009 WITH B.
      ELSE.
        MESSAGE I008 WITH MOVIE_TAB2-REL_YEAR MOVIE_TAB2-CATEGORY.
      ENDIF.

  ENDCASE.

ENDMODULE.

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

WA1 is a workarea TYPE Y00MOVIES (database Z table.)

and MOVIE_TAB2 is a internal table.

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


DATA : BEGIN OF MOVIE_TAB2 OCCURS 0.
        INCLUDE STRUCTURE Y00MOVIES.
DATA : END OF MOVIE_TAB2.

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


DATA : WA1 TYPE Y00MOVIES.

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

The input/output fields of the table have same name as that of internal table-field name.

For eg. MOVIE_TAB2-CATEGORY.

and so on.....

Hope this solves your problem.

Thanks & Regards.

Tarun Gambhir.

Read only

Former Member
0 Likes
652

Hi,

try this code in your module pool..

Select PBO module status & click on that.

Just you write a code after normal code as:

tablecontrolname-LINES = SY-DBCNT.(this will enable the table control vertical scroll bar.)

Normal code before above statement is(for eg.),

MOVE WA-EBELN TO EKKO-EBELN.

MOVE WA-AEDAT TO EKKO-AEDAT.

Regards,

BBR.

Read only

Former Member
0 Likes
652

Hi...

Use the below flowlogic and code...

FlowLogic

PROCESS BEFORE OUTPUT.

MODULE STATUS_1000.

CALL SUBSCREEN: SUB INCLUDING sy-repid '1001'.

LOOP AT it_all WITH CONTROL table_control.

ENDLOOP.

PROCESS AFTER INPUT.

LOOP.

CHAIN.

FIELD: it_all-empid,

it_all-address1,

it_all-address2,

it_all-city,

it_all-state,

it_all-dob,

it_all-firstname,

it_all-lastname,

it_all-namedisplay.

MODULE MODIFY.

ENDCHAIN.

ENDLOOP.

MODULE scroll_bar.

MODULE USER_COMMAND_1000.

ABAP Program

module USER_COMMAND_1000 input.

ok_code = sy-ucomm.

CASE ok_code.

when 'ADD'.

PERFORM CLEAR.

SELECT max( empid ) into ii FROM zempmaster.

ii = ii + 1.

txtemplid = ii.

when 'SUBMIT'.

zempmaster-empid = txtemplid.

zempmaster-address1 = zempmaster-address1.

zempmaster-address2 = zempmaster-address2.

zempmaster-city = zempmaster-city.

zempmaster-state = zempmaster-state.

zempmaster-dob = zempmaster-dob.

zempmaster-firstname = zempmaster-firstname.

zempmaster-lastname = zempmaster-lastname.

zempmaster-namedisplay = zempmaster-namedisplay.

SELECT SINGLE * FROM ZEMPMASTER where empid = txtemplid.

if sy-subrc = 0.

MESSAGE e000 with 'Record Already Present'.

ELSE.

INSERT zempmaster.

MESSAGE s001 with 'Racord Saved'.

ENDIF.

WHEN 'RESET'.

PERFORM CLEAR.

WHEN 'SEARCH'.

SELECT * INTO TABLE tab FROM zempmaster WHERE empid = zempmaster-empid.

loop at tab.

txtemplid = tab-empid.

zempmaster-address1 = tab-address1.

zempmaster-address2 = tab-address2.

zempmaster-city = tab-city.

zempmaster-state = tab-state.

zempmaster-dob = tab-dob.

zempmaster-firstname = tab-firstname.

zempmaster-lastname = tab-lastname.

zempmaster-namedisplay = tab-namedisplay.

ENDLOOP.

WHEN 'DELETE'.

PERFORM Confirm_Delete.

If ans = '1'.

delete from zempmaster where empid = zempmaster-empid.

MESSAGE s002 WITH txtemplid 'Deleted'.

ELSEIF ans = '2'.

MESSAGE s002 WITH txtemplid 'Not Deleted'.

ELSEIF ans = 'A'.

MESSAGE s002 WITH 'Operation Cancelled'.

ENDIF.

PERFORM CLEAR.

WHEN 'EXIT'.

LEAVE PROGRAM.

WHEN 'VIEW'.

SELECT * from zempmaster INTO TABLE it_all order by empid.

WHEN 'DELETEROW'.

GET CURSOR LINE line.

DELETE it_all INDEX line.

MESSAGE s002 WITH line.

WHEN 'EDIT'.

CLEAR line.

GET CURSOR LINE line.

READ TABLE it_mail INTO wa_mail INDEX line.

SELECT SINGLE * FROM zempmaster WHERE empid = wa_mail-empid.

if sy-subrc <> 0.

INSERT zempmaster from wa_mail.

else.

UPDATE zempmaster FROM wa_mail.

endif.

ENDCASE.

endmodule. " USER_COMMAND_1000 INPUT

module MODIFY input.

    • FREE it_all.*

APPEND it_all to it_mail.

    • table_control-current_line.*

endmodule. " MODIFY INPUT