Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

uploading data of few fields from one data base table to another

pashasapcha
Participant
0 Kudos
752

Hi gurus,

I am looking to update few fields of database table from another database table. I have written the code but I am getting error .

I have created internal table structures as same as database table structures. still it is saying incompatibility between datbase table and

internal tabe

The following is the comparision of types declaration and db table structures.

The following is the code


types :begin of ty_jlig, "j_1ig_invrefnum
* mandt type mandt,
bukrs type bukrs,
docno type j_1ig_docno,
doc_year type j_1ig_doc_year,
doc_type type j_1ig_doctyp,
odn type j_1ig_odn,
irn type j_1ig_irn,
version type j_1ig_version,
bupla type bupla,
odn_date type j_1ig_odn_date,
ack_no type j_1ig_ack_no,
ack_date type j_1ig_ack_date,
irn_status type j_1ig_irn_status,
cancel_date type j_1ig_canc_date,
ernam type ernam,
erdat type erdat,
* erdat type erdat,
erzet type erzet,
signed_inv type j_1ig_sign_inv,
signed_qrcode type j_1ig_sign_qrcode,
end of ty_jlig.
data: lt_jlig type table of ty_jlig. "j_1ig_invrefnum





types : begin of ty_zteinv, "ZTEINV_DETAILS
mandt type mandt,
bukrs type bukrs,
doctyp type j_1ig_doctyp,
docno type j_1ig_docno,
gjahr type gjahr,
xblnr type xblnr,
odn type j_1ig_odn,
irn type j_1ig_irn,
odn_date type j_1ig_odn_date,
ack_no type j_1ig_ack_no,
ack_date type j_1ig_ack_date,
irn_status type j_1ig_irn_status,
e_reason_code type zde_cancel_reason_irn,
e_reason type char120,
einv_error type char20,
qrcodeurl type string,
einv_pdf type string,
ernam type ernam,
erdat type erdat,
aenam type aenam,
aedat type aedat,
signedinvoice type string,
signedqrcode type string,

end of ty_zteinv.

data : lt_zteinv type table of ty_zteinv, "ZTEINV_DETAILS
ls_zteinv type ty_zteinv.

select * from j_1ig_invrefnum into CORRESPONDING FIELDS OF table lt_jlig.

if sy-subrc = 0.
loop at lt_jlig assigning field-symbol(<fs_invref>).
ls_zteinv-bukrs = <fs_invref>-bukrs.
ls_zteinv-doctyp = <fs_invref>-doc_type.
ls_zteinv-docno = <fs_invref>-docno.
* ls_zteinv-gjahr = <fs_invref>-gjahr.
ls_zteinv-odn = <fs_invref>-odn.
ls_zteinv-irn = <fs_invref>-irn.
ls_zteinv-odn_date = <fs_invref>-odn_date.
ls_zteinv-ack_no = <fs_invref>-ack_no.
ls_zteinv-ack_date = <fs_invref>-ack_date.
ls_zteinv-irn_status = <fs_invref>-irn_status.
append ls_zteinv to lt_zteinv.
endloop.
* lt_zteinv to lt
endif.
BREAK-POINT.
MODIFY zteinv_details1 from table lt_zteinv.
if sy-subrc = 0.
* messsage : 'DATA UPLOADED SUCCESSFULLY' type 'I' .
endif.

ERROR: The types for the database table and work area (or internal table) "LT_ZTEINV" are not compatible. compatible.

Can someone tell me how to update records in zteinvdetails from lt_zteinv though the structures are same.?

5 REPLIES 5

xiswanto
Active Participant
665

First of all, your field einv_error is different from the database field type.
Second, why are you declaring each fields in the type, is there any reason you could not directly declare such as below example?

TYPES: BEGIN OF ty_example.
  INCLUDE STRUCTURE zteinv_details.
TYPES: END OF ty_example.

pashasapcha
Participant
0 Kudos
665

zteinv_details is not structure it is transparent table. Just tried with the above one and it is showing this error

Anyhow what you have said is correct w.r.to einv_error and the issue is resolved.
I would be glad if someone helps me to achieve the same using new syntax 7.4 and 7.5.

FredericGirod
Active Contributor
0 Kudos
665

create an internal table with the structure of the database table :

types my_type_table type standard table of zteinv_details1 with non-unique default key.
my_table = corresponding my_type_table( lt_zteinv ).
modify zblabla from table my_table.

xiswanto
Active Participant
665

pashasapcha not exactly sure how you write the syntax, but include structure can be used to refer to transparent table too. If you want to pursue this matter further, you can do so by pasting your code.

*my bad, in your case, the include structure syntax won't work since you have string field(s).

Not sure for the new syntax 7.4 and 7.5, but you can refer to some blogs here.

ozgur_demir
Newcomer
0 Kudos
665
try this

DATA : lt_zteinv TYPE TABLE OF ZTEINV_DETAILS, "ZTEINV_DETAILS
ls_zteinv TYPE ZTEINV_DETAILS.