2014 Mar 11 8:31 AM
Hi All,
I'm trying to fetch data from CDHDR table for POs.
I have an internal table with all POs from selection screen. Now I have to fetch records from CDHDR for all those POs.
Here is the code:
SELECT
objectclas
objectid
changenr
udate
change_ind
FROM cdhdr
INTO TABLE it_cdhdr
FOR ALL ENTRIES IN it_data
WHERE objectclas = 'EINKBELEG'
AND objectid = it_data-ebeln
AND udate BETWEEN v_bedatep AND v_endate. "I have a condition to fetch the change records only in this period
The problem here is, the type of it_data-ebeln. Since it is not compatible to objectid, its not allowing me to get data from CDHDR.
If I change, the it_data-ebeln type to cdhdr-objectid, there are some other areas, where I need to fetch EKBE data for those it_data POs. There it shows it_data-ebeln is not compatible to EKBE-EBELN.
Kindly advise how to handle this.
Thanks in advance.
Rgs,
Priya
2014 Mar 11 8:50 AM
Just create another auxiliary internal table / range from your existing table (filling the correct type, expected in CDHDR). Isn't that enough?
2014 Mar 11 8:48 AM
Hi
Go to internal table IT_DATA, add a field OBJECTID like CDHDR-OBJECTID, populate it with a LOOP and then do the select.
I hope this helps you
Regards
Eduardo
2014 Mar 11 8:50 AM
Just create another auxiliary internal table / range from your existing table (filling the correct type, expected in CDHDR). Isn't that enough?
2014 Mar 11 8:58 AM
Hi Eduardo,
I have the same thing on my mind. But what makes me to put this here(sdn) is, why to loop the int table and just populate the another field. If the internal table get more records, it takes time right.
Is there any way to just use for all entries and get data from CDHDR?
@Jozef : I tried using another table with same structure and changing the type of ebeln .
When I try to put data of IT_DATA to temp internal table, again the same compatible issue, I'm facing.
Thanks,
Priya
2014 Mar 11 9:22 AM
Hi Priya,
I think Jozef solution is right. Just create a simple internal table with field of type cdobjectv and fill it in a loop with your data. You shouldn't bother about performance loss caused by the loop, because it's a very small execution time increase comparing to time needed for selecting from CDHDR.
Best Regards
Michal
2014 Mar 11 9:36 AM
as suggested by others, you do not need to create another table, just add another field of that type in you existing table (if you can). Once you cannot change the structure of the table (can be due to multiple reasons). Once you are looking for performance, then selecting in a loop would not be a good approach.
So - add a field to existing table, if you can't for some reason, create another table (you do not have to loop it again, you can create it at the place, where you are creating your table).
2014 Mar 11 9:12 AM
Hi Priya ,
Can you try something like this. ?
hope this works :
BEGIN OF ty_data,
mandant TYPE mandt,
objectclas TYPE cdobjectcl,
* objectid type cdobjectv,
ebeln TYPE ebeln,
changenr TYPE cdchangenr,
END OF ty_data,
BEGIN OF ty_temp_data,
mandant TYPE mandt,
objectclas TYPE cdobjectcl,
* objectid type cdobjectv,
ebeln TYPE cdobjectv, "Note a change here in the type
changenr TYPE cdchangenr,
END OF ty_temp_data.
DATA : it_cdhdr TYPE STANDARD TABLE OF cdhdr,
it_data TYPE STANDARD TABLE OF ty_data,
it_temp_data type standard table of ty_temp_data.
it_temp_data[] = it_data[]. " Transfer all the it_data contents here
SELECT
objectclas
objectid
changenr
udate
change_ind
FROM cdhdr
INTO TABLE it_cdhdr
FOR ALL ENTRIES IN it_temp_data
WHERE objectclas = 'EINKBELEG'
AND objectid = it_temp_data-ebeln " now this doesnt throw any error..!!!
2014 Mar 11 11:50 AM
Sireesha,
As quoted by you,
it_temp_data[] = it_data[]. " Transfer all the it_data contents here
This wont work, as it_data-ebeln is not compatible with it_temp_data-ebeln.
Also syntactically not correct.
Rgs,
Priya
2014 Mar 11 9:24 AM
Hi Priya ,
Follow this method.
TYPES : BEGIN OF ty_object,
objectid TYPE cdpos-objectid,
END OF ty_object.
DATA: it_object TYPE TABLE OF ty_object,
wa_object TYPE ty_object.
LOOP AT it_data INTO wa_data.
wa_object-objectid = wa_data-vbeln.
APPEND wa_object TO it_object.
ENDLOOP.
IF it_object[] IS NOT INITIAL.
DELETE ADJACENT DUPLICATES FROM it_data COMPARING vbeln.
SELECT objectclas
objectid
changenr
udate
value_new
value_old
FROM cdhdr
INTO TABLE it_cdhdr
FOR ALL ENTRIES IN it_object
WHERE objectclas = 'EINKBELEG'
AND objectid = it_object-objectid
AND udate BETWEEN v_bedatep AND v_endate.
ENDIF.
Br.
Giri
2014 Mar 11 11:35 AM
Hi All,
Thanks for your replies.
Have created another internal table with just one field(CDHDR-OBJECTID).
Looped the it_data and populated above internal table with it_data-ebeln to it_temp-objectid and appended the it_temp internal table.
Now reading, the cdhdr data based on it_temp internal table, which is working fine.
Thanks again for your replies.
Priya