10-01-2007 8:57 AM
I am using the FM ME_READ_CHANGES_EINKBELEG to read the changes done in PO. but it is not showing all the changes done in PO for a particular Date.
I am passing the PO No. and UDATE in the FM.
whereas when we see the PO thru ME23N, and see the changes thru Environment and Item Changes all the changes done in particular date are shown but when i am using th FM ME_READ_CHANGES_EINKBELEG its not showing some values....what can be the reason????
10-01-2007 9:48 AM
Hi,
I had also faced the same problem...
use the following piece of code...it will work..
TYPES: BEGIN OF ty_chg_texts,
ebeln TYPE ekpo-ebeln, "Purchase Order number
ebelp TYPE ekpo-ebelp, "Line item number
ctxnr TYPE t166t-ctxnr, "Text number for change text
chtxt TYPE t166t-chtxt, "Description of Changed Field in Printout
f_old TYPE cdshw-f_old, "Old value
f_new TYPE cdshw-f_new, "New/changed value
END OF ty_chg_texts.
TYPES: BEGIN OF ty_meein_xaend.
INCLUDE STRUCTURE cdshw.
TYPES:
ebelp LIKE ekpo-ebelp, "PO number
zekkn LIKE ekkn-zekkn, "Sequential Number of Account Assignment
etenr LIKE eket-etenr, "Delivery Schedule Line Counter
ctxnr LIKE t166c-ctxnr, "Text number for change text
rounr LIKE t166c-rounr, "Routing number
insert,
flag_adrnr,
END OF ty_meein_xaend.
TYPES ty_meein_xaend_tab
TYPE STANDARD TABLE OF ty_meein_xaend
DATA: IT_PEKPO TYPE STANDARD TABLE OF PEKPO.
DATA: is_ekko TYPE EKKO,
GT_CHG_TEXTS type standard table of TY_CHG_TEXTS.
DATA:
lt_xaend TYPE STANDARD TABLE OF ty_meein_xaend,
ls_xaend TYPE ty_meein_xaend,
ls_chg_texts TYPE ty_chg_texts.
CALL FUNCTION 'ME_READ_CHANGES_EINKBELEG'
EXPORTING
document = is_ekko
date_of_change = pass the date
time_of_change = pass the time(if needed)
print_operation = '2'
TABLES
xekpo = it_ekpo
xaend = lt_xaend.
DATA ls_ekpo TYPE ekpo.
DATA ls_pekpo TYPE pekpo.
*----
Check if this loop is needed(i dont think it is reqd...but still)--
LOOP AT it_ekpo INTO ls_ekpo.
READ TABLE it_pekpo
INTO ls_pekpo
WITH KEY ebelp = ls_ekpo-ebelp.
**********THIS PERFORM IS WRITTEN BELOW(CHECK BELOW)
PERFORM ergaenzen_xaend
USING ls_ekpo
ls_pekpo
is_ekko
CHANGING lt_xaend.
ENDLOOP.
*----
end (i dont think it is reqd...but still)----
-
ls_chg_texts-ebeln = is_ekko-ebeln.
LOOP AT lt_xaend INTO ls_xaend
WHERE ctxnr <> ' '.
IF ls_xaend-fname = 'LOEKZ' AND ls_xaend-f_new = 'L' AND
control_parameters-preview <> 'X' .
SELECT SINGLE * INTO wa_ekpo FROM ekpo
WHERE ebeln = is_ekko-ebeln AND
ebelp = ls_xaend-ebelp.
IF sy-subrc = 0.
APPEND wa_ekpo TO it_ekpo.
CLEAR wa_ekpo .
ENDIF.
ENDIF.
ls_chg_texts-ebelp = ls_xaend-ebelp.
ls_chg_texts-ctxnr = ls_xaend-ctxnr.
ls_chg_texts-f_old = ls_xaend-f_old.
ls_chg_texts-f_new = ls_xaend-f_new.
SELECT SINGLE chtxt FROM t166t INTO ls_chg_texts-chtxt
WHERE spras = gv_language AND ctxnr = ls_xaend-ctxnr.
APPEND ls_chg_texts TO gt_chg_texts.
ENDLOOP.
SORT gt_chg_texts BY ebeln ebelp chtxt.
DELETE ADJACENT DUPLICATES FROM gt_chg_texts
COMPARING ebeln ebelp chtxt.
SORT gt_chg_texts BY ebeln ebelp ctxnr.
SORT it_ekpo BY ebeln ebelp.
DELETE ADJACENT DUPLICATES FROM it_ekpo
COMPARING ebelp.
SORT it_ekpo BY ebeln ebelp.
ENDIF.
*&----
*
*& Form ERGAENZEN_XAEND
*&----
*
*----
*
FORM ergaenzen_xaend
USING is_ekpo TYPE ekpo
is_pekpo TYPE pekpo
is_ekko TYPE ekko
CHANGING ct_xaend TYPE ty_meein_xaend_tab.
DATA lv_insert.
DATA lv_h_ind LIKE sy-tabix.
DATA ls_xaend TYPE ty_meein_xaend.
LOOP AT ct_xaend INTO ls_xaend WHERE ebelp EQ is_pekpo-ebelp.
lv_h_ind = sy-tabix.
" Sonderbearbeitung -
-
" neue Position -
-
IF ls_xaend-insert NE space.
lv_insert = 'X'.
ls_xaend-text_case = 'X'.
MODIFY ct_xaend FROM ls_xaend.
EXIT.
ENDIF.
CHECK ls_xaend-rounr NE 0.
CASE ls_xaend-rounr.
" Einteilungsaenderung -
-
WHEN 1.
IF is_pekpo-eindt NE 0.
ls_xaend-ctxnr = 'S1-1'.
ELSE.
ls_xaend-ctxnr = 'S1-2'.
ENDIF.
" Zielmenge/Anfragemenge -
-
WHEN 2.
IF is_ekko-bstyp EQ 'A'.
ls_xaend-ctxnr = 'S2-A'.
ELSE.
ls_xaend-ctxnr = 'S2-R'.
ENDIF.
" Loeschkennzeichen -
-
WHEN 3.
CASE is_ekpo-loekz.
WHEN 'L'.
ls_xaend-ctxnr = 'S3-L'.
WHEN 'S'.
ls_xaend-ctxnr = 'S3-S'.
WHEN ' '.
ls_xaend-ctxnr = 'S3-X'.
ENDCASE.
ENDCASE.
MODIFY ct_xaend FROM ls_xaend INDEX lv_h_ind.
ENDLOOP.
IF sy-subrc EQ 0 AND NOT is_ekpo-uebpo IS INITIAL.
READ TABLE ct_xaend WITH KEY ebelp = is_ekpo-uebpo
BINARY SEARCH TRANSPORTING NO FIELDS.
IF sy-subrc NE 0.
CLEAR ls_xaend.
ls_xaend-ebelp = is_ekpo-uebpo.
INSERT ls_xaend INTO ct_xaend INDEX sy-tabix.
ENDIF.
ENDIF.
" bei neuer Position keine anderen Änderungen drucken --
IF lv_insert NE space.
LOOP AT ct_xaend INTO ls_xaend
WHERE ebelp EQ is_pekpo-ebelp
AND insert EQ space.
DELETE ct_xaend.
ENDLOOP.
ENDIF.
ENDFORM. "ERGAENZEN_XAEND
02-18-2014 10:10 AM
I advise to have a look at the customising first: DB Table T166C Print-Relevant Purchasing Document Changes:
TRx SPRO
Materials Management => Purchasing => Messages => Fields
Relevant to Printouts of Changes
The XAEND[ ] has than the changes for the fields customised for it.
However the returned language is NOT necesarily the one of the EKKO entry.
Especially a problem for the Old-New value Unit.