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.