2013 Apr 15 12:55 PM
My requirement is :
i want to compare last time run data with present data. how?
I need a solution other than store a z table.
2013 Apr 16 6:42 AM
Hi Kalyan Kumar,
You can import and export statements.
* At initialization import the time.
INITIALIZATION.
IMPORT time FROM MEMORY ID 'BEGINTIME'.
IF time IS INITIAL.
EXPORT time TO MEMORY ID 'BEGINTIME'.
ENDIF.
My requirement is :
i want to compare last time run data with present data. how?
I need a solution other than store a z table.
2013 Apr 16 6:42 AM
Hi Kalyan Kumar,
You can import and export statements.
* At initialization import the time.
INITIALIZATION.
IMPORT time FROM MEMORY ID 'BEGINTIME'.
IF time IS INITIAL.
EXPORT time TO MEMORY ID 'BEGINTIME'.
ENDIF.
2013 Apr 29 9:12 AM
i am new one in sap. i am not understand your statements.
this is my present coding. as per coding performs.
at the first time execution pull all the data from sap and sent to oracle.same time i update this records to ztable. at second time execution onwards i compare present runtime data to z table data. please explain your coding.
select infnr
ekorg
esokz
werks
erdat
ekgrp
prdat
from eine
into table gt_eine
where ekorg = gv_low1 "'4810'
and werks = gv_low2. "'4860'.
""and esokz = '0'.
if sy-subrc = 0.
refresh gt_eina.
****Select data from eina table
select infnr
matnr
lifnr
idnlf
from eina
into table gt_eina
for all entries in gt_eine
where infnr = gt_eine-infnr.
if sy-subrc = 0.
****delete gt_eina values where matnr equal to null
delete gt_eina where matnr = ' '.
****Select data from makt table
select matnr
maktx
from makt
into table gt_makt
for all entries in gt_eina
where matnr = gt_eina-matnr.
****Select data from T024 table
if sy-subrc = 0.
select ekgrp
eknam
from t024
into table gt_t024
for all entries in gt_eine
where ekgrp = gt_eine-ekgrp.
****Select data from lfa1 table
if sy-subrc = 0.
select lifnr
adrnr
from lfa1
into table gt_lfa1
for all entries in gt_eina
where lifnr = gt_eina-lifnr.
****Select data from adr6 table
if sy-subrc = 0.
select addrnumber
smtp_addr
from adr6
into table gt_adr6
for all entries in gt_lfa1
where addrnumber = gt_lfa1-adrnr.
endif.
endif.
endif.
endif.
endif.
****Sort all the Internal Tables
sort gt_eina by infnr.
sort gt_makt by matnr.
sort gt_t024 by ekgrp.
sort gt_lfa1 by lifnr.
sort gt_adr6 by addrnumber.
****Fetch Data from customized table zmmt0043
select matnr
maktx
lifnr
ekgrp
erdat
prdat
smtp_addr
idnlf
from zmmt0043
into table gt_zmmt0043.
*Check condition if it is initial
*this condition is true at first time execution only because our requirement is pull all the record
*at first time execution
if sy-subrc ne 0.
****move all the data to gt_fin_first from gwa_fin_first
loop at gt_eine into gwa_eine.
gwa_fin_first-erdat = gwa_eine-erdat.
gwa_fin_first-prdat = gwa_eine-prdat.
gwa_zmmt0043-erdat = gwa_eine-erdat.
gwa_zmmt0043-prdat = gwa_eine-prdat.
read table gt_eina
into gwa_eina
with key infnr = gwa_eine-infnr
binary search.
if sy-subrc = 0.
gwa_fin_first-matnr = gwa_eina-matnr.
gwa_fin_first-lifnr = gwa_eina-lifnr.
gwa_fin_first-idnlf = gwa_eina-idnlf.
gwa_zmmt0043-matnr = gwa_eina-matnr.
gwa_zmmt0043-lifnr = gwa_eina-lifnr.
gwa_zmmt0043-idnlf = gwa_eina-idnlf.
endif.
read table gt_makt
into gwa_makt
with key matnr = gwa_eina-matnr
binary search.
if sy-subrc = 0.
gwa_fin_first-maktx = gwa_makt-maktx.
gwa_zmmt0043-maktx = gwa_makt-maktx.
endif.
read table gt_t024
into gwa_t024
with key ekgrp = gwa_eine-ekgrp
binary search.
if sy-subrc = 0.
gwa_fin_first-ekgrp = gwa_t024-ekgrp.
gwa_zmmt0043-ekgrp = gwa_t024-ekgrp.
endif.
read table gt_lfa1
into gwa_lfa1
with key lifnr = gwa_eina-lifnr
binary search.
if sy-subrc = 0.
read table gt_adr6 into gwa_adr6 with key addrnumber = gwa_lfa1-adrnr binary search.
if sy-subrc = 0.
gwa_fin_first-smtp_addr = gwa_adr6-smtp_addr.
gwa_zmmt0043-smtp_addr = gwa_adr6-smtp_addr.
endif.
endif.
if gwa_fin_first-matnr ne ' '.
append gwa_fin_first to gt_fin_first .
modify zmmt0043 from gwa_zmmt0043. "Modify the ztable from gwa_zmmt0043 values
endif.
clear: gwa_fin_first,
gwa_zmmt0043,
gwa_eina,
gwa_eine,
gwa_makt,
gwa_t024,
gwa_lfa1,
gwa_adr6.
endloop.
****move all the data to T_FINALIT internal table
t_finalit[] = gt_fin_first[].
****Error Handling
if gt_fin_first[] is not initial.
message text-001 type 'I'.
else.
message text-002 type 'I'.
endif.
*Check condition 'if' it is initial is false go to else part
*this condition is false at second time execution onwards because our requirement is pull changes record
*only on the concurrent execution
else.
****move all the data to gt_fin_first from gwa_fin_first
loop at gt_eine into gwa_eine.
gwa_fin_first-erdat = gwa_eine-erdat.
gwa_fin_first-prdat = gwa_eine-prdat.
read table gt_eina
into gwa_eina
with key infnr = gwa_eine-infnr
binary search.
if sy-subrc = 0.
gwa_fin_first-matnr = gwa_eina-matnr.
gwa_fin_first-lifnr = gwa_eina-lifnr.
gwa_fin_first-idnlf = gwa_eina-idnlf.
endif.
read table gt_makt
into gwa_makt
with key matnr = gwa_eina-matnr
binary search.
if sy-subrc = 0.
gwa_fin_first-maktx = gwa_makt-maktx.
endif.
read table gt_t024
into gwa_t024
with key ekgrp = gwa_eine-ekgrp
binary search.
if sy-subrc = 0.
gwa_fin_first-ekgrp = gwa_t024-ekgrp.
endif.
read table gt_lfa1
into gwa_lfa1
with key lifnr = gwa_eina-lifnr
binary search.
if sy-subrc = 0.
read table gt_adr6 into gwa_adr6 with key addrnumber = gwa_lfa1-adrnr binary search.
if sy-subrc = 0.
gwa_fin_first-smtp_addr = gwa_adr6-smtp_addr.
endif.
endif.
sort gt_zmmt0043 by matnr.
read table gt_zmmt0043 into gwa_zmmt0043 with key matnr = gwa_fin_first-matnr
maktx = gwa_fin_first-maktx
lifnr = gwa_fin_first-lifnr
ekgrp = gwa_fin_first-ekgrp
smtp_addr = gwa_fin_first-smtp_addr
idnlf = gwa_fin_first-idnlf
erdat = gwa_fin_first-erdat
prdat = gwa_fin_first-prdat .
if sy-subrc ne 0.
append gwa_fin_first to gt_final.
gwa_zmmt0043-erdat = gwa_fin_first-erdat.
gwa_zmmt0043-prdat = gwa_fin_first-prdat.
gwa_zmmt0043-matnr = gwa_fin_first-matnr.
gwa_zmmt0043-lifnr = gwa_fin_first-lifnr.
gwa_zmmt0043-idnlf = gwa_fin_first-idnlf.
gwa_zmmt0043-maktx = gwa_fin_first-maktx.
gwa_zmmt0043-ekgrp = gwa_fin_first-ekgrp.
gwa_zmmt0043-smtp_addr = gwa_fin_first-smtp_addr.
modify zmmt0043 from gwa_zmmt0043.
endif.
append gwa_fin_first to gt_fin_first.
clear: gwa_fin_first,
gwa_eina,
gwa_eine,
gwa_makt,
gwa_t024,
gwa_lfa1,
gwa_adr6,
gwa_zmmt0043.
endloop.
*Compare gt_fin_first and gt_zmmt0043.
*Compare last time execution record and present time execution record.
* sort gt_fin_first by matnr.
* loop at gt_fin_first INTO gwa_fin_first.
* READ TABLE gt_zmmt0043 INTO gwa_ZMMT0043 with key matnr = gwa_fin_first-matnr
* maktx = gwa_fin_first-maktx
* lifnr = gwa_fin_first-lifnr
* ekgrp = gwa_fin_first-ekgrp
* smtp_addr = gwa_fin_first-smtp_addr
* idnlf = gwa_fin_first-idnlf
* erdat = gwa_fin_first-erdat
* prdat = gwa_fin_first-prdat .
*If any changes in the two internal tables append that record in internal table
*and modify z table.if any changes in last time execution record that record will pull
*and will send to oracle and modify z table also.
* CLEAR: gwa_fin_first,
* gwa_ZMMT0043.
* endloop.
t_finalit[] = gt_final[].
endif.
*Message Handling
if gt_final[] is not initial.
message text-003 type 'I'.
else.
message text-004 type 'I'.
endif.
endfunction.