‎2009 Apr 06 4:02 PM
Hi guys: Please help me....
i am trying to substitute the internal order on a line item if a vendor master has the internal order stored in a special field. the BADI doesnt seem to substitue it...here is my code
method IF_EX_AC_DOCUMENT~CHANGE_AFTER_CHECK.
break bdaniells.
DATA: ex_item type ACCIT,
wa_ex_item type ACCIT_SUB,
w_KONZS type lfa1-KONZS,
w_lifnr type lfa1-lifnr.
LOOP AT im_document-item INTO ex_item.
if ex_item-koart eq 'K'.
move ex_item-lifnr to w_lifnr.
endif.
if ex_item-koart eq 'S'.
select single KONZS into w_KONZS from lfa1
WHERE lifnr eq w_lifnr.
wa_ex_item-aufnr = w_KONZS.
APPEND wa_ex_item to ex_document-item.
endif.
endloop.
endmethod.
‎2009 Apr 06 4:12 PM
Try this way
method IF_EX_AC_DOCUMENT~CHANGE_AFTER_CHECK.
break bdaniells.
DATA: ex_item type ACCIT,
wa_ex_item type ACCIT_SUB,
w_KONZS type lfa1-KONZS,
w_lifnr type lfa1-lifnr.
LOOP AT im_document-item INTO ex_item.
if ex_item-koart eq 'K'.
move ex_item-lifnr to w_lifnr.
endif.
if ex_item-koart eq 'S'.
select single KONZS into w_KONZS from lfa1
WHERE lifnr eq w_lifnr.
wa_ex_item-aufnr = w_KONZS.
"APPEND wa_ex_item to ex_document-item. <<< Comment this line >>>
modify ex_document from wa_ex_item. " <<< Use modify instead of Append >>>
endif.
endloop.
endmethod.
a®
‎2009 Apr 06 4:27 PM
‎2009 Apr 06 4:15 PM
DATA: ex_item type ACCIT,
wa_ex_item type ACCIT_SUB,
w_KONZS type lfa1-KONZS,
w_lifnr type lfa1-lifnr.
LOOP AT im_document-item INTO ex_item.
if ex_item-koart eq 'K'.
move ex_item-lifnr to w_lifnr.
endif.
if ex_item-koart eq 'S'. " this its S here by that time w_lifnr doesnt have a value as above move cannot be done..
select single KONZS into w_KONZS from lfa1
WHERE lifnr eq w_lifnr.
if sy-subrc eq 0. "change..
wa_ex_item-aufnr = w_KONZS.
APPEND wa_ex_item to ex_document-item. " try modify too..
endif.
endif. "change.
endloop.
endmethod.
‎2009 Apr 06 4:28 PM
‎2009 Jul 18 12:24 AM