2014 Mar 12 5:38 AM
Hi All,
I have two internal tables, it_cdhdr and it_cdpos. Data as follows:
it_cdhdr:
Objectclass ObjectId Changenr Udate Change_ind
EINKBELEG 4500057161 0003273002 20131129 U
EINKBELEG 4500057161 0003273001 20131129 U
EINKBELEG 4500057161 0003272995 20131129 U
EINKBELEG 4500057161 0003178904 20131030 U
EINKBELEG 4500057161 0003178903 20131030 U
it_cdpos
Objectclas ObjectId Changenr Tabname Fname Value_new Value_old
EINKBELEG 4500057161 0003178903 EKKO FRGKE A B
EINKBELEG 4500057161 0003178903 EKKO FRGZU X
EINKBELEG 4500057161 0003178903 EKKO PROCSTAT 05 03
EINKBELEG 4500057161 0003178903 EKKO RLWRT 800.00 0.00
EINKBELEG 4500057161 0003178904 EKET MENGE 1000.000 800.000
EINKBELEG 4500057161 0003178904 EKKN MENGE 500.000 400.000
EINKBELEG 4500057161 0003178904 EKKN NETWR 500.00 400.00
EINKBELEG 4500057161 0003178904 EKKO FRGKE B A
EINKBELEG 4500057161 0003178904 EKKO FRGZU X
EINKBELEG 4500057161 0003178904 EKKO PROCSTAT 03 05
EINKBELEG 4500057161 0003178904 EKKO RLWRT 1000.00 800.00
EINKBELEG 4500057161 0003178904 EKPO BRTWR 1000.00 800.00
EINKBELEG 4500057161 0003178904 EKPO MENGE 1000.000 800.000
EINKBELEG 4500057161 0003178904 EKPO NETWR 1000.00 800.00
EINKBELEG 4500057161 0003272995 EKKO FRGKE A B
EINKBELEG 4500057161 0003272995 EKKO FRGZU X
EINKBELEG 4500057161 0003272995 EKKO PROCSTAT 05 03
EINKBELEG 4500057161 0003273001 EKET MENGE 2000.000 1000.000
EINKBELEG 4500057161 0003273001 EKKN MENGE 1000.000 500.000
EINKBELEG 4500057161 0003273001 EKKN NETWR 1000.00 500.00
EINKBELEG 4500057161 0003273001 EKKO FRGKE B A
EINKBELEG 4500057161 0003273001 EKKO FRGZU X
EINKBELEG 4500057161 0003273001 EKKO PROCSTAT 03 05
EINKBELEG 4500057161 0003273001 EKKO RLWRT 2000.00 1000.00
EINKBELEG 4500057161 0003273001 EKPO AEDAT 20131129 20131030
EINKBELEG 4500057161 0003273001 EKPO BRTWR 2000.00 1000.00
EINKBELEG 4500057161 0003273001 EKPO MENGE 2000.000 1000.000
EINKBELEG 4500057161 0003273001 EKPO NETWR 2000.00 1000.00
EINKBELEG 4500057161 0003273002 EKKO FRGKE A B
EINKBELEG 4500057161 0003273002 EKKO FRGZU X
EINKBELEG 4500057161 0003273002 EKKO PROCSTAT 05 03
As per requirement, the main focus is on Changes to EKKN and EKPO tables and I have to get the latest changes.
If you observe in above it_cdpos internal table data, it has two records,
EINKBELEG 4500057161 0003178904 EKKN NETWR 500.00 400.00
EINKBELEG 4500057161 0003178904 EKPO NETWR 1000.00 800.00
EINKBELEG 4500057161 0003273001 EKKN NETWR 1000.00 500.00
EINKBELEG 4500057161 0003273001 EKPO NETWR 2000.00 1000.00
Now I have read only the latest changenr data. Say 0003273001 , in this case.
My question is how do I know, the latest changenr has EKKN table changes, if you look at it_cdpos data above, the latest one is 0003273002, which doesnt have EKKN changes.
Kindly let me know how to read latest EKKN or EKPO data from IT_CDPOS table.
Thanks in advance,
Rgs,
Priya
2014 Mar 12 6:11 AM
Hi Priya,
As per my understanding, you can build below mentioned logic:
1. You can sort on it_cdhdr table BY date time based on field date time Changenr ObjectId in descending order.
2. Pick the 1st record object id and changenr from it_chdr and further read table it_cdpos based on changenr,objectid & tabname = EKKN and similary for EKPO.
If you have any query, please let me know.
Regards,
Sudeesh Soni
2014 Mar 12 6:25 AM
Hi Priya,
Sort it_cdhdr BY UDate Descending
changenr Ascending .
"THis is for Binary search
sort it_cdpos by objectclass objectid changenr .
Loop it_cdhdr
INTO wa_cdhdr .
Read table it_cdpos
INTO wa_cdpos
with key objectclass = wa_cdhrd-objectclass objectid = wa_cdhdr-objectid changenr = wa_cdhdr-changenr tabname = EKKN .
If sy-subrc = 0
"You will get EKKN recrord.
ENDIF.
clear wa_cdpos .
Read table it_cdpos
INTO wa_cdpos
with key objectclass = wa_cdhrd-objectclass objectid = wa_cdhdr-objectid changenr = wa_cdhdr-changenr tabname = EKPO .
If sy-subrc = 0
"You will get EKPO recrord.
ENDIF.
Endlloop
2014 Mar 28 5:45 AM
Hi Priya,
Please close the thread if your question is clarified Priya, if no, do continue your query. We all will be happy to help you out.
PS:- If the thread is closed and resolved it can be viewed by others for their reference purpose. Please do let people know whether their answer was useful or not because " SCNians are always their to help their fellow SCNian."
2014 Mar 28 6:13 AM
Hi Priya ,
I guess your requirement is to find the latest change number ,that has got change in both ekkn and ekkpo .
1- Sort it_cdhdr descending .
Loop at it_chdr into w_cdhdr
read table it_cdpos into w_cdpos with key changenr = w_cdhdr Tabname = ekkn .
if sy-subrc=0 .
read table it_cdpos into w_cdpos with key changenr = w_cdhdr Tabname = ekkpo .
if sy-subrc=0 .
"use convenient way to return change number (using varaiable)"
exit .
endif .
endif.
endloop .
By this way change number send will be the latest having both ekkn and ekkpo . If what i assumed is wrong ,then sorry for that .