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

Analyzing ABAP Code!

Former Member
0 Likes
810

Hi all,

can anyone please tell what this does......

SELECT AUFNR CHARG FROM AFPO

INTO TABLE I_AFPO

FOR ALL ENTRIES IN I_DATA_TEMP

WHERE AUFNR = I_DATA_TEMP-AUFNR.

AFPO is a table and has a primary key of AUFNR(order number) and POSNR(order item). My question is how is it retrieving unique records from AFPO when I am supplying only Order number in AUFNR = I_DATA_TEMP-AUFNR

I_DATA_TEMP is an internal table and has Order numbers and some other fields.

thanks,

Sabrina.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
773

Hi Sabrina,

The reason why you are seeing only unique values is that the option 'INTO TABLE' works that way. It eliminates any duplicates by default. If you want all the records, including duplicates, then you need to add POSNR to the internal table I_AFPO.

Regards,

Srinivas

6 REPLIES 6
Read only

Former Member
0 Likes
774

Hi Sabrina,

The reason why you are seeing only unique values is that the option 'INTO TABLE' works that way. It eliminates any duplicates by default. If you want all the records, including duplicates, then you need to add POSNR to the internal table I_AFPO.

Regards,

Srinivas

Read only

Former Member
0 Likes
773

Hi the select will get all entries of AUFNE for rows in I_DATA_TEMP .

It will be similar to ( just for understanding )

SELECT AUFNR CHARG FROM AFPO

INTO TABLE I_AFPO

WHEREAUFNR = I_DATA_TEMP(1)-AUFNR

or AUFNR = I_DATA_TEMP(2)-AUFNR.

or AUFNR = I_DATA_TEMP(3)-AUFNR

....

....

Upto no of rows in I_DATA_TEMP.

Cheers

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
773

In our system, there is only ever one AFPO record per production order, do you have multple?

Regards,

Rich Heilman

Read only

0 Likes
773

Rich, thanks for getting back to me.

I did check in AFPO table, the process orders are unique and all the order items have a value of one.

Read only

0 Likes
773

Hi SAbrina

Have you tried to use the statament

SELECT DISTINCT * FROM <TABLE>....?

This is a piece of SAP help:

DISTINCT

Duplicate entries in the result set are automatically deleted.

So:

SELECT DISTINCT AUFNR CHARG FROM AFPO into table I_AFPO.

Max

Message was edited by: max bianchi

Read only

Former Member
0 Likes
773

For all entries returns only the unique records use in select statement..

eg

SELECT AUFNR CHARG FROM AFPO

INTO TABLE I_AFPO

FOR ALL ENTRIES IN I_DATA_TEMP

WHERE AUFNR = I_DATA_TEMP-AUFNR.

this will give the unique records of AUFNR CHARG ..

since AUFNR and posnr are keys & u hv used only AUFNR in select stmt u will only unique records of AUFNR.

If u want to get unique records from table better u specify all the keys in select stmt whether u use or not.

SELECT AUFNR POSNR CHARG FROM AFPO

INTO CORRESPONDING FIELDS OF TABLE I_AFPO

FOR ALL ENTRIES IN I_DATA_TEMP

WHERE AUFNR = I_DATA_TEMP-AUFNR.

now this will give unique records of AUFNR POSNR .

regards

venkat