Skip to Content
avatar image
Former Member

BADI AC_DOCUMENT

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Apr 06, 2009 at 03: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.
    

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 06, 2009 at 03: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.
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 17, 2009 at 11:24 PM

    answered

    Add comment
    10|10000 characters needed characters exceeded