Since you want to take a value from one line item and place it on another line item, you'll need a substitution for callup point 3 -- which uses the whole FI document. This will allow you to loop through all the line items, capturing the vendor number from the relevant line item and adding it to the line item 2. We used similar logic to populate the business area field - see our sample logic below. You'll need to change the logic up a bit in order to populate the vendor on line item 2, but this code should give you an idea of how to manipulate the data within your substitution userexit.
One thing to note: At callup point 3, no BSEG field has currently been released for substitution, since substitution is not possible for all transactions by means of which documents are posted. Refer to OSS Note 42615 for more information - if you choose to substitute BSEG fields, you'll need to follow the instructions in this OSS note to update the GB01 table. I've done this for several clients, so please let me know if you have any questions.
Also, if you switch over to using a callup point 3 substitution, you'll need to remove your account prerequisite and just handle all checks and validations within your userexit logic.
Sample userexit code:
------------------------
form u900 changing bool_data type gb002_015.
data: hold_gsber like bseg-gsber.
clear hold_gsber.
* Check all line item business areas. Keep the first
* business area found, for use on the discount line item.
loop at bool_data-bseg into bseg.
if not bseg-gsber is initial and
hold_gsber is initial.
move bseg-gsber to hold_gsber.
endif.
if bseg-gsber is initial.
move hold_gsber to bseg-gsber.
modify bool_data-bseg index sy-tabix from bseg.
endif.
endloop.
endform. "U900
To see other answers submitted to the Answer Wiki
View Answer History.