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

Q: sourceField NOT IN InternalTable expression

Former Member
0 Likes
787

Hi,

I have a start routine in which I want to filter out and delete some data packages. I want to make sure to filter away all data where MAT_SALES is not in my internal table. I Have created the code below and I do not get any compilation error, but it does not seem to work.

data: i_mat_sales TYPE RANGE OF /BIC/AZBILCOPA00-MAT_SALES.

SELECT DISTINCT MAT_SALES

FROM /BI0/PMAT_SALES

INTO TABLE i_mat_sales

WHERE /BIC/ZACCASGRP IN ('a', 'b', 'c').

LOOP AT SOURCE_PACKAGE into source_wa.

IF source_wa-MAT_SALES NOT IN i_mat_sales.

DELETE SOURCE_PACKAGE.

ELSE.

....code goes on...

Does somebody know if you can use the "sourceField NOT IN InternalTable" expression like this in ABAP or do I need to re-write my code?

Thank you in advance,

Mikael

Hi,

I have a start routine in which I want to filter out and delete some data packages. I want to make sure to filter away all data where MAT_SALES is not in my internal table. I Have created the code below and I do not get any compilation error, but it does not seem to work.

data: i_mat_sales TYPE RANGE OF /BIC/AZBILCOPA00-MAT_SALES.

SELECT DISTINCT MAT_SALES

FROM /BI0/PMAT_SALES

INTO TABLE i_mat_sales

WHERE /BIC/ZACCASGRP IN ('a', 'b', 'c').

LOOP AT SOURCE_PACKAGE into source_wa.

IF source_wa-MAT_SALES NOT IN i_mat_sales.

DELETE SOURCE_PACKAGE.

ELSE.

....code goes on...

Does somebody know if you can use the "sourceField NOT IN InternalTable" expression like this in ABAP or do I need to re-write my code?

Thank you in advance,

Mikael

5 REPLIES 5
Read only

Former Member
0 Likes
746

Try this:

Do you have any relation between I_MAT_SALES and SOURCE_PACKAGE internal tables? If yes do this:

DATA: LV_TABIX LIKE SY-TABIX.

LOOP AT SOURCE_PACKAGE.

LV_TABIX = SY-TABIX.

READ TABLE I_MAT_SALES WITH KEY FIELDNAME = SOURCE_PACKAGE-FIELDNAME.

IF SY-SUBRC NE 0.

DELETE SOURCE_PACKAGE INDEX LV_TABIX.

CLEAR SOURCE

ENDLOOP.

Thanks,

SKJ

Message was edited by:

SKJ

Read only

Former Member
0 Likes
746

Hi Mikael,

There is not expression like "sourceField NOT IN InternalTable" exists but you can achieve your requirement through READ statement for the same.

Check this code in the bold.

data: i_mat_sales TYPE RANGE OF /BIC/AZBILCOPA00-MAT_SALES.

SELECT DISTINCT MAT_SALES

FROM /BI0/PMAT_SALES

INTO TABLE i_mat_sales

WHERE /BIC/ZACCASGRP IN ('a', 'b', 'c').

LOOP AT SOURCE_PACKAGE into source_wa.

<b>read table i_mat_sales with key mat_sales = source_wa-mat_sales.

if sy-subrc <> 0.

*IF source_wa-MAT_SALES NOT IN i_mat_sales.

</b>DELETE SOURCE_PACKAGE.

ELSE.

....code goes on...

Thanks,

Vinay

Read only

Former Member
0 Likes
746

Hi,

I have updated my code but I still cannot get it to work. All data packages are always deleted and nothing is loaded to my cube. I cannot debug it because when I choose to simulate update for debugging it takes an hour and then debugger is started but I do not get to the start routine.

TYPES: begin of msales_type,

msale type /BI0/PMAT_SALES,

end of msales_type.

data: i_mat_sales TYPE STANDARD TABLE OF msales_type.

data: i_mat_lines type i.

SELECT DISTINCT MAT_SALES

FROM /BI0/PMAT_SALES

INTO TABLE i_mat_sales

WHERE /BIC/ZACCASGRP IN ('a', 'b', 'c').

DESCRIBE TABLE i_mat_sales LINES i_mat_lines.

LOOP AT SOURCE_PACKAGE into source_wa.

T_INDEX = SY-TABIX.

READ TABLE I_MAT_SALES WITH KEY MSALE =

source_wa-MAT_SALES TRANSPORTING NO FIELDS.

IF ( SY-SUBRC NE 0 AND SY-SUBRC NE 2

OR source_wa-/BIC/ZCOPAIND NE '1'

OR source_wa-/BIC/ZSDIND NE '1').

DELETE SOURCE_PACKAGE INDEX T_INDEX.

ENDIF.

-


code goes on...

Any ideas?

Thanks in advance,

Mikael

Read only

0 Likes
746

sorry

Message was edited by:

SHIBA DUTTA

Read only

Former Member
0 Likes
746

Re-wrote the code, now it works.