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

Host Variable, Literal in Open SQL

hawkvicky91
Explorer
0 Likes
2,059

Hi,

I am trying to assign data object of type Date in Select Query to field of interal table.

e.g.

Select trntry, @d_date as budat

          from z_view to z_internal_table.

where z_internal_table is internal table of strutcure : trntyp type c,

                                                                            budat type d.

   

d_date is data object of type d, which is assign date before select query.

However, when i check output of table it showing date field as empty

with two character : ' - - '.

I don't know, why it is not working, if i use host variable of other type like

char, numc, or p , its working good.

11 REPLIES 11
Read only

former_member201275
Active Contributor
0 Likes
1,695

please post all your code here

Read only

0 Likes
1,695

TABLES: zer2_dv_vt_011.

SELECT-OPTIONS: s_date FOR zer2_dv_vt_011-budat.

TYPES: BEGIN OF lty_final,

              trantyp TYPE c LENGTH 1,

              budat   TYPE d,

             END OF lty_final.

DATA : d_date TYPE d.

            d_date =  s_date-low.

DATA: lt_final TYPE STANDARD TABLE OF lty_final.

START-OF-SELECTION.

SELECT trantyp, @d_date AS budat

             FROM zer2_dv_vt_011

             INTO CORRESPONDING FIELDS OF TABLE @lt_final

             WHERE budat IN @s_date.

Its just a sample code i have created, TRANTYP in ZER2_DV_VT_011 is of Char type with Length 1

after Query lt_final contain the data for TRANTYP, but showing empty for BUDAT.

Read only

0 Likes
1,695

Where are you writing this code, i don't see how this will even compile?

Read only

0 Likes
1,695

In SE38, and why it will not compile?

I have not mention REPORT Statement at top for obvious reason.

Read only

0 Likes
1,695

Are you able to activate this in your system?

Read only

0 Likes
1,695

YES, JUST include the REPROT Statement (as it is executable Prog) at top, i don't think there is anything wrong there.

for displaying the data i have use CL_DEMO_OUTPUT=>DISPLAY( LT_FINAL ).

??

Read only

0 Likes
1,695

but my main concern is of select query, why it is not assign the date to internal table field.

Read only

0 Likes
1,695

My concern is the code.

SELECT trantyp, @d_date AS budat

             FROM zer2_dv_vt_011

             INTO CORRESPONDING FIELDS OF TABLE @lt_final

             WHERE budat IN @s_date

maybe should be:

SELECT trantyp budat

             FROM zer2_dv_vt_011

             INTO CORRESPONDING FIELDS OF TABLE lt_final

             WHERE budat IN s_date

Then the next question is why are you:

d_date =  s_date-low.

i.e. only using the date-low value, what happens if person running this has no value here?

Probably your table doesn't have this value? What value are you entering on your selection screen?

Please post a copy of your table here i.e. the table definition and also the table contents.

Read only

0 Likes
1,695

we used , and @ from ABAP 7.4 , maybe before that and

its just sample code, not representing any actual Senior( actual code is bit complex and big).

you can write the code like.

REPORT ztemp1.

TABLES: zer2_dv_vt_011.

SELECT-OPTIONS: s_date FOR zer2_dv_vt_011-budat OBLIGATORY NO-EXTENSION.

TYPES: BEGIN OF lty_final,

              trantyp TYPE c LENGTH 1,

              MODIFIED_DATE   TYPE d,

            END OF lty_final.

DATA: lt_final TYPE STANDARD TABLE OF lty_final.

START-OF-SELECTION.

SELECT trantyp, @s_date-low AS MODIFIED_DATE

                 FROM zer2_dv_vt_011

                 INTO CORRESPONDING FIELDS OF TABLE @lt_final where budat in @s_date..

  cl_demo_output=>display( lt_final ).

hope it make sense now.

Here Modified_date is just another field in ZER2_DV_VT_011 of type date.

Read only

0 Likes
1,695

Table has value for data entering in selection scree

Read only

0 Likes
1,695

Yes it has value for data entered on selection screen, even i removes where clause, data is not showing for field of type date.