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

module pool - table control - update ztable

edgar_almonte
Participant
0 Likes
2,457

hello , i doing a module pool that will have few screens , now i have one screen with a table control that fetch the data from a ztable when screen is call the table control is showing the data and is in grey and no editable i add a pf-status for change that mode i can delete the row from the table control but i don't figure out how update to the ztable when i press save , i wan't too another button for add a new row ( and remain the already in grey ) for add new entrie in the table and update the ztable

pd: sorry for my bad english

this is my code:

TOP:

PROGRAM  z_pp_lote_etiquetas MESSAGE-ID zz.

TABLES:zc2p_lote_etique,
       zc2p_lider_modul.

DATA: ok_code LIKE sy-ucomm.
DATA save_ok LIKE sy-ucomm.

* internal table
DATA: it_zc2p_lote_etique LIKE STANDARD TABLE OF zc2p_lote_etique.
DATA: it_zc2p_lider_modul TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
DATA: it_zc2p_lider_modul_del TYPE STANDARD TABLE OF zc2p_lider_modul WITH HEADER LINE.
******************************************************************************
**************Workarea
DATA: wa_c2p_lote_etique TYPE zc2p_lote_etique.
DATA: wa_c2p_lider_modul TYPE zc2p_lider_modul.
DATA: wa_c2p_lider_modul_del TYPE zc2p_lider_modul.
****************************************************

DATA: sel.
DATA: MARK.
DATA: init.
DATA:  col TYPE scxtab_column.
DATA: lines TYPE i.
***********************************************************************
* Variable Declaration
***********************************************************************
DATA : flg, "Flag to set the change mode
ln TYPE i. "No. of records

* Table Control Declartion.
CONTROLS: zc2p_lider_crtl TYPE TABLEVIEW USING SCREEN '101'.

**PROCESS BEFORE OUTPUT INCLUDE **

&---------------------------------------------------------------------*
*&  Include           Z_PP_LOTE_ETIQUETAS_O01
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*& Module set_status OUTPUT
*&---------------------------------------------------------------------*
* Setting the GUI status
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'Z_PP_LOT_ETIQ_MENU'.
  SET TITLEBAR 'Z_PP_LOT_ETIQ'.
ENDMODULE. " set_status OUTPUT screen 100

*----------------------------------------------------------------------*
*  MODULE status_0101 OUTPUT
*----------------------------------------------------------------------*
* Setting the GUI status
*----------------------------------------------------------------------*
MODULE status_0101 OUTPUT.
  SET PF-STATUS 'Z_PP_LOT_ETIQ_ME_101'.
  SET TITLEBAR 'Z_PP_LOT_ETIQ'.
* Data retreving
  if init is INITIAL.
  select * from zc2p_lider_modul into CORRESPONDING FIELDS OF TABLE it_zc2p_lider_modul.
    DESCRIBE TABLE it_zc2p_lider_modul LINES ln.
    zc2p_lider_crtl-lines = ln + 10.
    init = 'X'.
endif.
ENDMODULE.                    "status_0101 OUTPUT

module change_sdyn_conn output.
* you can change the content of current table control line via
* sdyn_conn
  READ TABLE it_zc2p_lider_modul INTO zc2p_lider_modul INDEX zc2p_lider_crtl-current_line.

endmodule.                             " FILL_TABLE_CONTROL  OUTPUT


MODULE set_screen_fields OUTPUT.
LOOP AT SCREEN.
IF flg IS INITIAL.
screen-input = 0.
ELSE.
screen-input = 1.
ENDIF.
*ENDIF.
* Modifying the screen after making changes
MODIFY SCREEN.
ENDLOOP.
ENDMODULE. " set_screen_fields OUTPUT

PROCESS AFTER INPUT INCLUDE.

*----------------------------------------------------------------------*
*  MODULE USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  CASE ok_code.
    WHEN 'LIDM'.
      CALL SCREEN 101.
    WHEN 'CANC'.
      LEAVE PROGRAM.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                    "USER_COMMAND_0100 INPUT

*----------------------------------------------------------------------*
*  MODULE USER_COMMAND_0101 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_0101 INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'SORT'.
      DATA: fldname(100),help(100).
      READ TABLE zc2p_lider_crtl-cols INTO col WITH KEY selected = 'X'.
      SPLIT col-screen-name AT '-' INTO help fldname.
      SORT it_zc2p_lider_modul BY (fldname).
    WHEN 'CHANGE'.
* Setting the flag to make the table control in editable mode[excluding
* primary key].
      flg = 'Y'.
    WHEN 'BACK'.
      CALL SCREEN 100.
      LEAVE SCREEN.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'SAVE'.
      MODIFY  zc2p_lider_modul FROM it_zc2p_lider_modul.
      COMMIT WORK.
  ENDCASE.
ENDMODULE.                    "USER_COMMAND_0101 INPUT

*----------------------------------------------------------------------*
*  MODULE read_table_control INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE read_table_control INPUT.
* Check input values
  IF mark = 'X' AND save_ok = 'DELETE'.
    DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
    DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
  ENDIF.
ENDMODULE.                             " READ_TABLE_CONTROL  INPUT

Screen Flow Logic 100

PROCESS BEFORE OUTPUT.
MODULE status_0100.

PROCESS AFTER INPUT.
MODULE user_command_0100.

Screen Flow Logic 101.

PROCESS BEFORE OUTPUT.
  MODULE status_0101.
  LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL
zc2p_lider_crtl.
* Dynamic screen modifications
    MODULE set_screen_fields.
    MODULE change_sdyn_conn.
  ENDLOOP.
*
PROCESS AFTER INPUT.
  MODULE user_command_0101.

  LOOP AT it_zc2p_lider_modul.
    MODULE read_table_control.
  ENDLOOP.

i hope somebody can help for what i missing here thanks

16 REPLIES 16
Read only

rahulkavuri
Active Contributor
0 Likes
1,859

hi

Just set a break point in the screen 101 to check whether 101 is called after u click SAVE...

Is the Ztable not updated ?? If it is updated then may be you are not refreshing the first table control which displays the Ztable data in PBO of Screen 100

just correct this statement and check again

MODIFY zc2p_lider_modul FROM TABLE it_zc2p_lider_modul.

Read only

0 Likes
1,859

WHEN 'SAVE'.

MODIFY zc2p_lider_modul FROM it_zc2p_lider_modul.

COMMIT WORK.

i debugg the program and it enter in this section but the ztable is not update ( i can update the ztable , i have a maintanence view with sm30 )

i only have one table control for screen 101 right known

Read only

0 Likes
1,859

Change it like this

MODIFY zc2p_lider_modul FROM TABLE it_zc2p_lider_modul.

Read only

0 Likes
1,859

i change the code but still dont get update the ztable , i debugg it and i saw it_zc2p_lider_modul get delete when i delete the rows

MODIFY zc2p_lider_modul FROM TABLE it_zc2p_lider_modul

Read only

Former Member
0 Likes
1,859

Hi,

I did the same requirement as you need,,find the below code.....

when save perform there option..

sample code

LOOP AT IT_DLR.
     IF IT_DLR-KUNNR NA SY-ABCDE.
       UNPACK IT_DLR-KUNNR TO IT_DLR-KUNNR.
     ENDIF.
     IF IT_DLR-DACNO NA SY-ABCDE.
       UNPACK IT_DLR-DACNO TO IT_DLR-DACNO.
     ENDIF.
     SELECT SINGLE * FROM ZDLRBNKDTL WHERE KUNNR = IT_DLR-KUNNR AND
                                           DACNO = IT_DLR-DACNO.
     IF SY-SUBRC EQ 0.
       MOVE-CORRESPONDING IT_DLR TO ZDLRBNKDTL.
       MODIFY ZDLRBNKDTL.CLEAR ZDLRBNKDTL.
     ELSE.
       MOVE-CORRESPONDING IT_DLR TO ZDLRBNKDTL.
       INSERT ZDLRBNKDTL.CLEAR ZDLRBNKDTL.
     ENDIF.
   ENDLOOP.

Regards,

V.Balaji

Reward if usefull

Read only

0 Likes
1,859

sorry Balaji V , i am noob i understand very well the code , but i think that code dont will work in case of new entries

Edited by: Edgar Almonte on Mar 26, 2008 3:51 PM

Read only

Former Member
0 Likes
1,859

Hello Edgar,

Problem seems to be there in the flow logic of 101



PROCESS BEFORE OUTPUT.
  MODULE status_0101.
  LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL 
zc2p_lider_crtl. " no need to have 'INTO zc2p_lider_modul' above
* Dynamic screen modifications
    MODULE set_screen_fields.
    MODULE change_sdyn_conn.
  ENDLOOP.
*
PROCESS AFTER INPUT.
  MODULE user_command_0101. "this should be shifted after the following LOOP...ENDLOOP.
 
  LOOP AT it_zc2p_lider_modul. "need to have 'WITH CONTROL zc2p_lider_crtl' here
    MODULE read_table_control.
  ENDLOOP.

With MODULE user_command_0101 call before the LOOP calls the MODIFY statement (under case save_ok 'SAVE') first and Z-table is updated with the old values as the changes are transferred from screen into the internal table it_zc2p_lider_modul in the LOOP...ENDLOOP later.

Try these changes and I hope it will work.

Thanks

Sanjeev

Read only

0 Likes
1,859

>

> Hello Edgar,

>

> Problem seems to be there in the flow logic of 101

>


> 
> PROCESS BEFORE OUTPUT.
>   MODULE status_0101.
>   LOOP AT it_zc2p_lider_modul INTO zc2p_lider_modul WITH CONTROL 
> zc2p_lider_crtl. " no need to have 'INTO zc2p_lider_modul' above
> * Dynamic screen modifications
>     MODULE set_screen_fields.
>     MODULE change_sdyn_conn.
>   ENDLOOP.
> *
> PROCESS AFTER INPUT.
>   MODULE user_command_0101. "this should be shifted after the following LOOP...ENDLOOP.
>  
>   LOOP AT it_zc2p_lider_modul. "need to have 'WITH CONTROL zc2p_lider_crtl' here
>     MODULE read_table_control.
>   ENDLOOP.
> 
> 

>

> With MODULE user_command_0101 call before the LOOP calls the MODIFY statement (under case save_ok 'SAVE') first and Z-table is updated with the old values as the changes are transferred from screen into the internal table it_zc2p_lider_modul in the LOOP...ENDLOOP later.

>

> Try these changes and I hope it will work.

>

> Thanks

> Sanjeev

i do the firts advice but the second one i get syntax error :

my code :

PROCESS AFTER INPUT.
  LOOP  at it_zc2p_lider_modul WITH CONTROL zc2p_lider_crtl.
    MODULE read_table_control.
  ENDLOOP.
   MODULE user_command_0101.

error :

In the event PROCESS AFTER INPUT, no additions are allowed with "LOOP	
AT".

Read only

0 Likes
1,859

Hi Edgar,

Leave 'WITH CONTROL zc2p_lider_crtl' in PAI to have the correct syntax and then try.

Thanks

Sanjeev

Read only

0 Likes
1,859

>

> Hi Edgar,

>

> Leave 'WITH CONTROL zc2p_lider_crtl' in PAI to have the correct syntax and then try.

>

> Thanks

> Sanjeev

my code:

PROCESS BEFORE OUTPUT.
  MODULE status_0101.
  LOOP AT it_zc2p_lider_modul  WITH CONTROL zc2p_lider_crtl.
* Dynamic screen modifications
    MODULE set_screen_fields.
    MODULE change_sdyn_conn.
  ENDLOOP.
*
PROCESS AFTER INPUT.
  LOOP  AT it_zc2p_lider_modul WITH CONTROL zc2p_lider_crtl .
    MODULE read_table_control.
  ENDLOOP.
   MODULE user_command_0101.

i get the same error

Read only

0 Likes
1,859

No, you did not remove the Control from LOOP in PAI. See below:


PROCESS BEFORE OUTPUT.
  MODULE status_0101.
  LOOP AT it_zc2p_lider_modul  WITH CONTROL zc2p_lider_crtl.
* Dynamic screen modifications
    MODULE set_screen_fields.
    MODULE change_sdyn_conn.
  ENDLOOP.
*
PROCESS AFTER INPUT.
  LOOP  AT it_zc2p_lider_modul. " WITH CONTROL zc2p_lider_crtl .
    MODULE read_table_control.
  ENDLOOP.
   MODULE user_command_0101.


Try now.

Read only

0 Likes
1,859

>

> No, you did not remove the Control from LOOP in PAI. See below:

>


> PROCESS BEFORE OUTPUT.
>   MODULE status_0101.
>   LOOP AT it_zc2p_lider_modul  WITH CONTROL zc2p_lider_crtl.
> * Dynamic screen modifications
>     MODULE set_screen_fields.
>     MODULE change_sdyn_conn.
>   ENDLOOP.
> *
> PROCESS AFTER INPUT.
>   LOOP  AT it_zc2p_lider_modul. " WITH CONTROL zc2p_lider_crtl .
>     MODULE read_table_control.
>   ENDLOOP.
>    MODULE user_command_0101.
> 
> 
> 

> Try now.

ah ok , yes i try that in the first time bu i dont get the ztable update nor

i try with

process before output.
  module status_0101.
  loop at it_zc2p_lider_modul with control
zc2p_lider_crtl.
* Dynamic screen modifications
    module set_screen_fields.
    module change_sdyn_conn.
  endloop.
*
process after input.
  loop  at it_zc2p_lider_modul .
    module read_table_control.
  endloop.
   module user_command_0101.

and with

process before output.
  module status_0101.
  loop at it_zc2p_lider_modul into zc2p_lider_modul with control
zc2p_lider_crtl.
* Dynamic screen modifications
    module set_screen_fields.
    module change_sdyn_conn.
  endloop.
*
process after input.
  loop  at it_zc2p_lider_modul .
    module read_table_control.
  endloop.
   module user_command_0101.

none get me the ztable update

Read only

0 Likes
1,859

In the module module read_table_control include a statement like below as the first statement:


MODULE read_table_control INPUT.
"include the following statement as this updates the itab from the screen table  
MODIFY it_zc2p_lider_modul FROM zc2p_lider_modul INDEX flights-current_line.

* Check input values
  IF mark = 'X' AND save_ok = 'DELETE'.
    DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
    DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
  ENDIF.
ENDMODULE.                             " READ_TABLE_CONTROL  INPUT

Try this and revert.

Read only

0 Likes
1,859

>

> In the module module read_table_control include a statement like below as the first statement:

>

>


> MODULE read_table_control INPUT.
> "include the following statement as this updates the itab from the screen table  
> MODIFY it_zc2p_lider_modul FROM zc2p_lider_modul INDEX flights-current_line.
> 
> * Check input values
>   IF mark = 'X' AND save_ok = 'DELETE'.
>     DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
>     DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
>   ENDIF.
> ENDMODULE.                             " READ_TABLE_CONTROL  INPUT
> 
> 

>

> Try this and revert.

thanks , i try this but dont work , i change flights-current_line with zc2p_lider_crtl-current_line.

my code :

MODULE read_table_control INPUT.
MODIFY it_zc2p_lider_modul FROM zc2p_lider_modul INDEX zc2p_lider_crtl-current_line.

* Check input values
  IF mark = 'X' AND save_ok = 'DELETE'.
    DELETE TABLE it_zc2p_lider_modul FROM zc2p_lider_modul.
    DESCRIBE TABLE it_zc2p_lider_modul LINES zc2p_lider_crtl-lines.
  ENDIF.
ENDMODULE.

what do you mean with "..and revert" ?

thansk again

Edited by: Edgar Almonte on Mar 27, 2008 3:36 PM

Read only

0 Likes
1,859

"..and revert" meant "reply back".

It still doesn't work, this is strange. Put a breakpoint at the CASE statement and check the contetnts of the internal table before the MODIFY statement. Are you getting the modified content up to that point or not?

Thanks

Sanjeev

Read only

0 Likes
1,859

>

> "..and revert" meant "reply back".

>

> It still doesn't work, this is strange. Put a breakpoint at the CASE statement and check the contetnts of the internal table before the MODIFY statement. Are you getting the modified content up to that point or not?

>

> Thanks

> Sanjeev

yes is strange , i was started think is something about how i create the ztable check :

my code:

WHEN 'SAVE'.
      MODIFY zc2p_lider_modul FROM TABLE it_zc2p_lider_modul.
      BREAK-POINT.
      COMMIT WORK.
  ENDCASE.
ENDMODULE.                    "USER_COMMAND_0101 INPUT

and the debugg value of save_ok and the itab:

SAVE_OK	                                   	SAVE
IT_ZC2P_LIDER_MODUL[]	                                   	Standard Table[0x9(94)]