Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BADI AC_DOCUMENT

Former Member
0 Likes
8,415

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.

5 REPLIES 5
Read only

former_member194669
Active Contributor
0 Likes
4,916

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®

Read only

0 Likes
4,916

Modify causes the program to short dump.....

Read only

former_member156446
Active Contributor
0 Likes
4,916
   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.
Read only

0 Likes
4,916

w_lifnr has the required value....i think thats okay.

Read only

Former Member
0 Likes
4,916

answered