‎2008 Mar 26 2:26 PM
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 OUTPUTPROCESS 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 INPUTScreen 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
‎2008 Mar 26 2:35 PM
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.
‎2008 Mar 26 2:41 PM
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
‎2008 Mar 26 2:43 PM
Change it like this
MODIFY zc2p_lider_modul FROM TABLE it_zc2p_lider_modul.
‎2008 Mar 26 2:50 PM
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
‎2008 Mar 26 2:44 PM
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
‎2008 Mar 26 2:51 PM
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
‎2008 Mar 26 3:07 PM
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
‎2008 Mar 26 3:14 PM
>
> 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".
‎2008 Mar 26 3:24 PM
Hi Edgar,
Leave 'WITH CONTROL zc2p_lider_crtl' in PAI to have the correct syntax and then try.
Thanks
Sanjeev
‎2008 Mar 26 3:28 PM
>
> 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
‎2008 Mar 26 3:35 PM
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.
‎2008 Mar 26 3:42 PM
>
> 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
‎2008 Mar 27 1:58 PM
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.
‎2008 Mar 27 2:35 PM
>
> 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
‎2008 Mar 27 2:50 PM
"..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
‎2008 Mar 27 2:56 PM
>
> "..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 INPUTand the debugg value of save_ok and the itab:
SAVE_OK SAVE
IT_ZC2P_LIDER_MODUL[] Standard Table[0x9(94)]