2011 Nov 03 3:15 PM
Is there a certain syntax for inserting into db tables with OO? I have no errors when I MODIFY the table from within the same method, but when I use INSERT I get an error saying the field is not recognized.
Edited by: zmwhite on Nov 3, 2011 4:15 PM
2011 Nov 11 10:01 PM
The code is as folows, the statment to MODIFY does not give me an error but the INSERT statement gives the message: zobserve is not a field group.
METHOD save_answers.
IF s1000_flg1 = 'UPDT'. "update existing record
MODIFY zobserve FROM wa_zobserve. *NO ERROR*
IF SY-SUBRC <>'0'.
message_id = 7.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
RETURN.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Updated' TYPE 'S'.
ENDIF.
ELSE. "add new record
INSERT WA_ZOBSERVE INTO ZOBSERVE. *ERROR: zobserve is not a field group*
IF SY-SUBRC <> '0'.
message_id = 8.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Saved' TYPE 'S'.
ENDIF.
ENDIF.
The code is as folows, the statment to MODIFY does not give me an error but the INSERT statement gives the message: zobserve is not a field group.
METHOD save_answers.
IF s1000_flg1 = 'UPDT'. "update existing record
MODIFY zobserve FROM wa_zobserve. *NO ERROR*
IF SY-SUBRC <>'0'.
message_id = 7.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
RETURN.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Updated' TYPE 'S'.
ENDIF.
ELSE. "add new record
INSERT WA_ZOBSERVE INTO ZOBSERVE. *ERROR: zobserve is not a field group*
IF SY-SUBRC <> '0'.
message_id = 8.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Saved' TYPE 'S'.
ENDIF.
ENDIF.
2011 Nov 04 4:08 AM
2011 Nov 05 9:04 PM
2011 Nov 05 10:08 PM
Hi zim
thank you for not posting code but asking questions regarding code.
I don't know what you expect. But you will have taken into account that you always INSERT / MODIFY / UPDATE databse FROM work area or FROM TABLE itab.
Regards
Clemens
2011 Nov 11 10:01 PM
The code is as folows, the statment to MODIFY does not give me an error but the INSERT statement gives the message: zobserve is not a field group.
METHOD save_answers.
IF s1000_flg1 = 'UPDT'. "update existing record
MODIFY zobserve FROM wa_zobserve. *NO ERROR*
IF SY-SUBRC <>'0'.
message_id = 7.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
RETURN.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Updated' TYPE 'S'.
ENDIF.
ELSE. "add new record
INSERT WA_ZOBSERVE INTO ZOBSERVE. *ERROR: zobserve is not a field group*
IF SY-SUBRC <> '0'.
message_id = 8.
lcl_message->get_message(
EXPORTING
text_id = message_id
text = ' ' ).
SET SCREEN 1000.
ELSE.
COMMIT WORK.
saved_flg = 'X'.
MESSAGE 'Record Saved' TYPE 'S'.
ENDIF.
ENDIF.
2011 Nov 11 10:18 PM
Hi,
Please go thru this link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm
Write your statement like these (below)
To insert a single line into a database table, use the following:
INSERT INTO <target> VALUES <wa> .
INSERT <target> FROM <wa >
Multiple lines
INSERT <target> FROM TABLE <itab>
Hope I helped!
Thanks,
Reetesh
2011 Nov 11 10:30 PM
Thanks, I had actually copied that line from the model my boss gave me, and he wasn't using OO. It originally gave a message that in OO the syntax needed an INTO with the INSERT formatted that way, so I changed it and it never worked after that. I must have had something else wrong that I have fixed in the process. Not sure why, but it works now.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |