2016 Jan 08 5:31 PM
Hello Experts,
I'm trying to do a simple INSERT on 2 custom tables using the following two SELECT's. One works, however, the last one throws ABAP dump.
"Works for table zotb_screen_hdr
select single * from zotb_screen_hdr
into lw_zotb_hdr
where filenet_id = zotb_header-filenet_id.
if sy-subrc <> 0 and lw_zotb_hdr is initial.
insert into zotb_screen_hdr values gw_zotb_screen_hdr.
endif.
"Throws ABAP dump
select single * from zotb_screen_dtl
into lw_zotb_dtl
where filenet_id = zotb_header-filenet_id
and posnr = zotb_detail-posnr.
if sy-subrc <> 0 and lw_zotb_dtl is initial.
insert into zotb_screen_dtl values gw_zotb_screen_dtl. "ST22 points this line as cause of error. (Both filenet_id and posnr fields have values)
endif.
All I'm trying to do is to check if record already exist in the table. If not, then do INSERT using workarea gw_zotb_screen_dtl. What's puzzling is that SAP doesn't throw error on first INSERT but does on second one.
Can anybody see what mistake I'm making here and how to rectify it?
Many thanks in advance.
Message was edited by: Matthew Billingham - tidied code formatting
Hello Experts,
I'm trying to do a simple INSERT on 2 custom tables using the following two SELECT's. One works, however, the last one throws ABAP dump.
"Works for table zotb_screen_hdr
select single * from zotb_screen_hdr
into lw_zotb_hdr
where filenet_id = zotb_header-filenet_id.
if sy-subrc <> 0 and lw_zotb_hdr is initial.
insert into zotb_screen_hdr values gw_zotb_screen_hdr.
endif.
"Throws ABAP dump
select single * from zotb_screen_dtl
into lw_zotb_dtl
where filenet_id = zotb_header-filenet_id
and posnr = zotb_detail-posnr.
if sy-subrc <> 0 and lw_zotb_dtl is initial.
insert into zotb_screen_dtl values gw_zotb_screen_dtl. "ST22 points this line as cause of error. (Both filenet_id and posnr fields have values)
endif.
All I'm trying to do is to check if record already exist in the table. If not, then do INSERT using workarea gw_zotb_screen_dtl. What's puzzling is that SAP doesn't throw error on first INSERT but does on second one.
Can anybody see what mistake I'm making here and how to rectify it?
Many thanks in advance.
Message was edited by: Matthew Billingham - tidied code formatting
2016 Jan 08 7:43 PM
are you passing all field values with correct format(may be you are passing wrong data type)
2016 Jan 09 7:08 AM
Since the first table is a different table to the second, it's not necessarily that puzzling. Obviously something is wrong with your second insert.
What is the type of gw_zotb_screen_dtl? Are you sure it is the same as the table? Have you checked the contents of this variable in debug? Does it actually contain valid values (.e.g you might have passed it a character numeric value when it was expecting a packed decimal).
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |