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: 
Read only

Open SQL access to DAYDATE field

alexey_tarasov
Explorer
0 Likes
2,022

Hi !

I have some table in HANA with DAYDATE field

create table zbseg2 (f1 daydate,f2 integer);

insert into zbseg2 values ('2012-03-01', 100);

insert into zbseg2 values ('2012-03-02', 200);

I have secondary connection from ABAP application server to HANA named hb1_test. In application server table ZBSEG2 described in data dictionary like this

Field nameType
F1DATS
F2INT4

The next code works correct:

REPORT zhana_zbseg2_conn.

DATA l_str LIKE zbseg2.

SELECT SINGLE * INTO CORRESPONDING FIELDS OF l_str FROM zbseg2 CONNECTION hb1_test.

MESSAGE s000(00).

I receive first record from HANA table with correct field F1.

But next code has dump as a result

REPORT zhana_zbseg2_conn.

DATA l_str LIKE zbseg2 OCCURS 0.

SELECT * INTO CORRESPONDING FIELDS OF TABLE l_str FROM zbseg2 CONNECTION hb1_test.

MESSAGE s000(00).


Dump is "Database error text: "SQL message: DB type (14) of selected column (0) and ABAP type TYPDATE (1) of target field (0) are not compatible"


Is there a workaround for this case? May be I need to use another type in data dictionary description? I try different types but no result.

1 ACCEPTED SOLUTION
Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
1,316

Hi Alexey,
as the dump mentions, the DB type and the ABAP type are not compatible. Daydate like '2015-01-01' is not compatible to DATS '20150101'.

So you would have to convert daydate (or to be more precise, the type CS_DAYDATE) to a compatible type for ABAP DATS. As this is hardly possible within Open SQL (at least in the current version), the question is, whether you can already modify the date at DB level, before reading it from the database.

My question is, why you got a DAYDATE type in zbseg2 (not a copy of BSEG, right?). Because in BSEG I know the DATS are persisted to NVARCHAR(8) fields. You might want to model it the same way.

Cheers,
  Jasmin

Hi !

I have some table in HANA with DAYDATE field

create table zbseg2 (f1 daydate,f2 integer);

insert into zbseg2 values ('2012-03-01', 100);

insert into zbseg2 values ('2012-03-02', 200);

I have secondary connection from ABAP application server to HANA named hb1_test. In application server table ZBSEG2 described in data dictionary like this

Field nameType
F1DATS
F2INT4

The next code works correct:

REPORT zhana_zbseg2_conn.

DATA l_str LIKE zbseg2.

SELECT SINGLE * INTO CORRESPONDING FIELDS OF l_str FROM zbseg2 CONNECTION hb1_test.

MESSAGE s000(00).

I receive first record from HANA table with correct field F1.

But next code has dump as a result

REPORT zhana_zbseg2_conn.

DATA l_str LIKE zbseg2 OCCURS 0.

SELECT * INTO CORRESPONDING FIELDS OF TABLE l_str FROM zbseg2 CONNECTION hb1_test.

MESSAGE s000(00).


Dump is "Database error text: "SQL message: DB type (14) of selected column (0) and ABAP type TYPDATE (1) of target field (0) are not compatible"


Is there a workaround for this case? May be I need to use another type in data dictionary description? I try different types but no result.

3 REPLIES 3
Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
1,317

Hi Alexey,
as the dump mentions, the DB type and the ABAP type are not compatible. Daydate like '2015-01-01' is not compatible to DATS '20150101'.

So you would have to convert daydate (or to be more precise, the type CS_DAYDATE) to a compatible type for ABAP DATS. As this is hardly possible within Open SQL (at least in the current version), the question is, whether you can already modify the date at DB level, before reading it from the database.

My question is, why you got a DAYDATE type in zbseg2 (not a copy of BSEG, right?). Because in BSEG I know the DATS are persisted to NVARCHAR(8) fields. You might want to model it the same way.

Cheers,
  Jasmin

Read only

0 Likes
1,316

Hi Jasmin,

thank you for your reply.

In our system we have all date field for all replicated tables converted to this format DAYDATE (and BSEG too). It is a fait accompli, that I can not do anything.

Can you talk me in which version of ABAP it will be possible? Or may be you know release date for this version?

Best regards, Alexey.

Read only

0 Likes
1,316

Hi Alexey,
I don't know about such a requirement (but that doesn't mean it does not exists... I just don't know about it), so I don't have any release information when such a feature will / might be available.

My question is, why have BSEG fields been converted to that data type??

Cheers,
  Jasmin