‎2006 Dec 15 2:37 PM
hi, i am in assignment as a fresher, in that i need to code for module pool programing with table controls.
I am getting no errors, and getting the scrren after using trasaction code what the thing , if i try to insert any data, its giving not inserted message.i am sending the code can any one help me.
----
***INCLUDE ZSAINPUTSCREEN_USER_COMMANDI01 .
----
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
TABLES: ZSAORDERS.
DATA: IT_ITAB LIKE ZSAORDERS OCCURS 0 WITH HEADER LINE.
CONTROLS: VCONTROL TYPE TABLEVIEW USING SCREEN '100'.
module USER_COMMAND_0100 input.
CASE SY-UCOMM.
WHEN 'INSERT'.
MOVE ZSAORDERS TO IT_ITAB. " SCREEN FIELDS TO WORKAREA
APPEND IT_ITAB. " WORK AREA TO BODY.
INSERT INTO ZSAORDERS VALUES IT_ITAB. " INTO DATA BASE.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'INSERTED'.
ELSE.
MESSAGE I000(0) WITH 'NOT INSERTED'.
ENDIF.
WHEN 'UPDATE'.
MOVE ZSAORDERS TO IT_ITAB.
APPEND IT_ITAB.
UPDATE ZSAORDERS FROM TABLE IT_ITAB.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'INSERTED'.
ELSE.
MESSAGE I000(0) WITH 'NOT INSERTED'.
ENDIF.
ENDCASE.
endmodule. " USER_COMMAND_0100 INPUT
-
PROCESS BEFORE OUTPUT.
LOOP AT IT_ITAB WITH CONTROL VCONTROL.
MODULE STATUS_0100.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
LOOP AT IT_ITAB.
ENDLOOP .
MODULE USER_EXIT.
-
----
***INCLUDE ZSAINPUTSCREEN_STATUS_0100O01 .
----
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
module STATUS_0100 output.
MOVE-CORRESPONDING IT_ITAB TO ZSAORDERS.
SET PF-STATUS 'xxxxxxxx'.
SET TITLEBAR 'xxx'.
endmodule. " STATUS_0100 OUTPUT
-
thanks in advance.
sarath
‎2006 Dec 15 2:40 PM
The message might be displayed on the status bar at the bottom of your screen.
Jsut to make sure, repeat the MESSAGE statement one more time and you should be able to see a popup..
regards,
Ravi
‎2006 Dec 15 2:40 PM
The message might be displayed on the status bar at the bottom of your screen.
Jsut to make sure, repeat the MESSAGE statement one more time and you should be able to see a popup..
regards,
Ravi
‎2006 Dec 15 2:41 PM
thanks for u r replay
i am not able to insert the data.
giving message like not inserted.
is coding is write or wrong
‎2006 Dec 15 2:44 PM
Then you might be trying to insert a duplicate key in the table. Just make sure that the data you are not inserting duplicates. Check the table once for existing data.
Regards,
Ravi
Note - Please mark all the helpful answers
‎2006 Dec 15 2:50 PM
Hi,
try using INSERT ZSAORDERS FROM TABLE IT_ITAB.
instead of INSERT INTO ZSAORDERS VALUES IT_ITAB.
‎2006 Dec 15 2:55 PM
its giving error,
i had given data which is not there in the data base then also its giving same msg
‎2006 Dec 15 3:06 PM
Hi Sarath,
Chk the SY-SUBRC check for UPDATE , may be one of ur lines of ITAB does not match with the primary key of Database table
SY-SUBRC = 0:
All lines from itab could be used to update the database table.
SY-SUBRC = 4:
At least one line of the internal table itab in the database table had no line with the same primary key. The other lines of the database table were updated.
‎2006 Dec 15 3:16 PM
Hi,
declares these things in the top incklude . I don't how you are able to activate with declaring then in the module.
TABLES: ZSAORDERS.
DATA: IT_ITAB LIKE ZSAORDERS OCCURS 0 WITH HEADER LINE.
CONTROLS: VCONTROL TYPE TABLEVIEW USING SCREEN '100'.
go to debug and see whether you have data
change insert to modify
WHEN 'INSERT'.
MOVE ZSAORDERS TO IT_ITAB. " SCREEN FIELDS TO WORKAREA
APPEND IT_ITAB. " WORK AREA TO BODY.
modify ZSAORDERS from table IT_ITAB. " INTO DATA BASE.
IF SY-SUBRC = 0.
MESSAGE I000(0) WITH 'INSERTED'.
ELSE.
MESSAGE I000(0) WITH 'NOT INSERTED'.
ENDIF.
Hope this helps
Thanks
‎2006 Dec 15 4:15 PM
HI
ITS SHOWING AS INSERTED BUT DATA IS NOT THERE IN DATA BASE.
‎2006 Dec 15 4:19 PM
Hi sarath,
if you use the insert command and if the record with the same primary values already exist in the data it cannot insert.
so try using modify
Thanks
‎2006 Dec 15 3:58 PM
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
LOOP AT IT_ITAB.
ENDLOOP .can u just make this user command place after the endloop. like this and in debugging just chk the entries putting a breakpoint.
PROCESS AFTER INPUT.
LOOP AT IT_ITAB.
ENDLOOP .
MODULE USER_COMMAND_0100."over here
i cant make from the code but see if the user command triggering with the data .
regards,
vijay
‎2006 Dec 15 4:29 PM
Hi Sarath,
Please check demo DEMO_DYNPRO_TABCONT_LOOP_AT perhaps it may help.
To insert to custom table from table control, you can do something like this.
...
WHEN 'INSERT'.
READ TABLE TC-COLS INTO COL WITH KEY SCREEN-INPUT = '1'.
IF SY-SUBRC = 0.
LOOP AT I_BINLOC INTO ZMBINLOC WHERE ZMARK = 'X'.
CLEAR ZMBINLOC.
INSERT ZMBINLOC INTO I_BINLOC INDEX SY-TABIX.
ENDLOOP.
DESCRIBE TABLE I_BINLOC LINES TC-LINES.
ENDIF.
...
Hope this will help.
Regards,
Ferry Lianto
‎2006 Dec 15 4:42 PM
thanks to each and every one.
i will check my DB table and coding
sarath