Application Development 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: 

select statement question...

aris_hidalgo
Contributor
0 Kudos

Hello experts,

I need to get records from table anlc that is not deactivated so I joined it with table anla because that is where the field deakt is located. I need to get records where its deakt is initial but how can I declare it to my select statement since the word INITIAL cannot be included in a select statement. So here's what I did:

So, is the word NULL the same as initial?

SELECT SINGLE abukrs aanln1 agjahr aafabe a~knafa

akansw aanswl akaafa anafal

aaafav aaafag

nafap aafap nafav nafag

FROM anlc as a

inner join anla as b

on aanln1 = banln1

INTO (it_anlc-bukrs, it_anlc-anln1, it_anlc-gjahr,

it_anlc-afabe, it_anlc-knafa, it_anlc-kansw,

it_anlc-answl, it_anlc-kaafa, it_anlc-nafal,

it_anlc-aafav, it_anlc-aafag, it_anlc-nafap,

it_anlc-aafap, it_anlc-nafav, it_anlc-nafag)

WHERE a~anln1 EQ it_finaltab-asset

AND a~bukrs IN r_iwerk

AND a~gjahr EQ gv_year

AND a~afabe EQ '01'

and b~deakt is null.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Use b~deakt EQ lv_deakt.

data type of lv_deakt should besame has b~deakt.

whenever u declare the variable of any type.

ABAP automatically gives its initial value to the field.

eg:-

when

lv_date type dats,

lv_time type tims.

LV_date----->'00000000'

lv_time----->'000000'.

Dont worry it works.

Regards

7 REPLIES 7

former_member927251
Active Contributor
0 Kudos

Use this

<b>b~deakt EQ space.</b>

<b>

Reward points and close the thread.</b>

0 Kudos

Hi,

I noticed that its initial value is 00/00/0000. will space work?

Former Member
0 Kudos

I am not sure on this

NULL -->space

INITIAL --> can be 0 or space

Former Member
0 Kudos

HI Viray,

Use <b>b~deakt <> '00000000'</b> as in your select statement.

Thanks,

Vinay

Former Member
0 Kudos

I would rather suggest you to :

SELECT SINGLE abukrs aanln1 agjahr aafabe a~knafa

akansw aanswl akaafa anafal

aaafav aaafag

nafap aafap nafav nafag

FROM anlc as a

inner join anla as b

on aanln1 = banln1

INTO (it_anlc-bukrs, it_anlc-anln1, it_anlc-gjahr,

it_anlc-afabe, it_anlc-knafa, it_anlc-kansw,

it_anlc-answl, it_anlc-kaafa, it_anlc-nafal,

it_anlc-aafav, it_anlc-aafag, it_anlc-nafap,

it_anlc-aafap, it_anlc-nafav, it_anlc-nafag)

WHERE a~anln1 EQ it_finaltab-asset

AND a~bukrs IN r_iwerk

AND a~gjahr EQ gv_year

AND a~afabe EQ '01'.

delete it_anlc where deakt is initial.

IS NULL, IS NOT NULL is going to cost a lot in terms of database usage. Better to delete the entries from internal table after the select is done.

Former Member
0 Kudos

Hi,

Use b~deakt EQ lv_deakt.

data type of lv_deakt should besame has b~deakt.

whenever u declare the variable of any type.

ABAP automatically gives its initial value to the field.

eg:-

when

lv_date type dats,

lv_time type tims.

LV_date----->'00000000'

lv_time----->'000000'.

Dont worry it works.

Regards

Former Member

Hi viraylab,

u can try this way:

select anln1 from anla into table it_anln1

where deakt = '00000000'.

select bukrs anln1 gjahr afabe knafa kansw answl kaafa nafal aafav aafag nafap aafap nafav nafag from anlc into table it_anlc for all entries in it_anln1 where anln1 = it_anla-anln1.

And also for all entries is better performance wise than innerjoins.

Award points if helpful.

regards,

keerthi.