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
553

hi friends,

am working on modulepool,in table control i have 3 screen ,create and change screen and Display,

in create i can create a new record ,in change want to chage the existing record,dispaly want to display all the records in this i have done all the thing but the problem is in create there is no possibility to change ,in change no possibility of creating the new record ,but save is for create mode whilw creating a new record,in change case also save will available for saving the changes ,could any please provide the code how can i restrict the create ,change, display.

thanks in advance,

sasai.

5 REPLIES 5
Read only

Former Member
0 Likes
532

This message was moderated.

Read only

0 Likes
532

hi jayanthi,

in my program i have created 3 screens 1 is for create 2 nd is for change 3rd is for display,

in create mode i will eneter some data and when i press save a new record will be created will be saved in data base.In change screen i will change the same record and when press save chaged data has been saved to data base. but "save" is used in both create and change modes initially while creating a new record or changing the existing record but the problem how can i do the seggregation .In create after entering some data in table control press save and in change doing some changes to existing record then press save how can i do this seggregation.if possible could u provide some sample code.

Thanks in advance,

sasi.

Read only

0 Likes
532

u can do the segregation by applying following logic. in create once u enter record that particular row shud be made read only while in change rows should be writable so u can change values of any record.

кu03B1ятu03B9к

Read only

0 Likes
532

Hi

Your segregation is basically: SAVE in Create and Edit in Change.

Actually in first screen Create when you save, you are creating a record. The flow logic is:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_9000.
 loop with control TWRITE.
 endloop.
*
PROCESS AFTER INPUT.

 MODULE USER_COMMAND_9000.
 loop with control TWRITE.
   MODULE WRITE_TO_DB.
 endloop.

Code:

REPORT  YJAN9_TBL_CTRL2.

*Tables: YSTUDENT.

controls: TWRITE type tableview using screen 9000.

data: itab type standard table of YSTUDENT with header line initial size 0.

data: ok_code(4),
      ID like YSTUDENT-ID,
      NAME like YSTUDENT-NAME,
      MARK1 like YSTUDENT-MARK1.

CALL SCREEN 9000.

*&---------------------------------------------------------------------*
*&      Module  STATUS_9000  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9000 OUTPUT.
  SET PF-STATUS 'MENU1'.
  SET TITLEBAR '900'.

ENDMODULE.                 " STATUS_9000  OUTPUT

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

  itab-ID = ID.
  itab-NAME = NAME.
  itab-MARK1 = MARK1.

  insert into YSTUDENT values itab.

ENDMODULE.                 " WRITE_TO_DB  INPUT

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

ok_code = sy-ucomm.

case ok_code.

when 'BACK' or 'EXIT' or 'CANCEL'.
  leave program.
when 'DON'.
  Message I008(ZRAJ203).

endcase.

ENDMODULE.                 " USER_COMMAND_9000  INPUT

In second screen, when you are Saving you are doing: EDIT operation. The flow logic is:

PROCESS BEFORE OUTPUT.
 MODULE STATUS_2209.
 module GET_DATA.
 loop at itab with control TBL1.
     module POPULATE_TBL.
 endloop.
*
PROCESS AFTER INPUT.

 MODULE USER_COMMAND_2209.
loop at itab.
   module UPDATE.
 endloop.

Code :

REPORT  YFEB2_SCREEN_TBL                                            .
                                    .
TABLES: YSTUDENT.

CONTROLS TBL1 TYPE TABLEVIEW USING SCREEN 2209.

DATA: OK_CODE LIKE SY-UCOMM,
      itab TYPE TABLE OF YSTUDENT WITH HEADER LINE,
      WA LIKE LINE OF ITAB,
      cols like line of TBL1-COLS,
      FLAG TYPE I.

FLAG = 1.

CALL SCREEN 2209.

*&---------------------------------------------------------------------*
*&      Module  GET_DATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_DATA OUTPUT.

  select * from ystudent into table itab.

ENDMODULE.                 " GET_DATA  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  POPULATE_TBL  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE POPULATE_TBL OUTPUT.

    MOVE ITAB TO YSTUDENT.

ENDMODULE.                 " POPULATE_TBL  OUTPUT


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

WA-ID = YSTUDENT-ID.
WA-NAME = YSTUDENT-NAME.
    INSERT YSTUDENT FROM WA.

ENDMODULE.                 " UPDATE  INPUT

*&---------------------------------------------------------------------*
*&      Module  STATUS_2209  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_2209 OUTPUT.
 SET PF-STATUS 'BACK'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_2209  OUTPUT

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

OK_CODE = SY-UCOMM.

CASE OK_CODE.
  WHEN 'BACK'.
    LEAVE PROGRAM.
  
ENDCASE.


ENDMODULE.                 " USER_COMMAND_2209  INPUT

For third screen Display alone. Flow Logic is:

PROCESS BEFORE OUTPUT.

 MODULE STATUS_3001.
 MODULE GET_DATA.
 loop at it_flight into wa_flight with control T_TBL1.
   MODULE POPULATE.
 endloop.
*
PROCESS AFTER INPUT.
loop at it_flight.
endloop.
 MODULE USER_COMMAND_3001.

Code:

REPORT  YDEC24_SCREEN3.

DATA: I_NAME(15),
      R_1, R_2,
      OK_CODE(4).


Tables: sflight.

controls: T_TBL1 type tableview using screen 3001.

data: it_flight type standard table of sflight initial size 0,

        wa_flight type sflight.



CALL SCREEN 3001.

*&---------------------------------------------------------------------*
*&      Module  STATUS_3001  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_3001 OUTPUT.
  SET PF-STATUS 'MENU3'.
  SET TITLEBAR '000'.

ENDMODULE.                 " STATUS_3001  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  GET_DATA  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE GET_DATA OUTPUT.

select carrid connid fldate price currency from sflight into corresponding fields of table it_flight.

ENDMODULE.                 " GET_DATA  OUTPUT


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

OK_CODE = SY-UCOMM.

CASE OK_CODE.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
    LEAVE PROGRAM.
ENDCASE.

ENDMODULE.                 " USER_COMMAND_3001  INPUT


*&---------------------------------------------------------------------*
*&      Module  POPULATE  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE POPULATE OUTPUT.

DATA: ld_line TYPE i.



*   Set which line of table is a top of displayed table control

    IF sy-stepl = 1.

      T_TBL1-lines =

        T_TBL1-top_line + sy-loopc - 1.

    ENDIF.



*   move fields from work area to scrren fields

    MOVE-CORRESPONDING wa_flight TO sflight.


ENDMODULE.                 " POPULATE  OUTPUT

Hope this helps

Regards,

Jayanthi.K

Read only

Former Member
0 Likes
532

hi,

u can go to transaction abapdocu for this.there dem programs and code available