‎2010 Jun 17 4:07 PM
I am working on ME51N BADI - ME_PROCESS_REQ_CUST and the method
IF_EX_ME_PROCESS_REQ_CUST~POST while SAVE I have to duplicate the line item u2018nu201D number of times( Based on some logic) and will save with the additional line items .
INCLUDE MM_MESSAGES_MAC.
* Work Areas
DATA: WA_PR_HEADER_STRUCTURE TYPE MEREQ_HEADER,
WA_ITEM TYPE MMPUR_REQUISITION_ITEM,
WA_ITEM_IF TYPE REF TO IF_PURCHASE_REQUISITION_ITEM, WA_REQ_ITEM TYPE MEREQ_ITEM.
DATA: WA_PR_ITEM_REF TYPE MMPUR_REQUISITION_ITEM,
WA_MMPUR_ACCOUNTING_TYPE TYPE MMPUR_ACCOUNTING_TYPE,
WA_EXKN TYPE EXKN.
* Internal Tables
DATA: IT_ITEMS TYPE MMPUR_REQUISITION_ITEMS.
* Main Program
DATA: WA_ITEM_IF_CY TYPE REF TO IF_PURCHASE_REQUISITION_ITEM,
WA_REQ_ITEM_CY TYPE MEREQ_ITEM.
WA_PR_HEADER_STRUCTURE = IM_HEADER->GET_DATA( ).
IT_ITEMS = IM_HEADER->GET_ITEMS( ).
DATA: LV_LINE TYPE I,
LL_LINE TYPE I.
.
DESCRIBE TABLE IT_ITEMS LINES LV_LINE. LOOP AT IT_ITEMS INTO WA_ITEM.
WA_ITEM_IF = WA_ITEM-ITEM.
WA_REQ_ITEM = WA_ITEM_IF->GET_DATA( ).
IF WA_REQ_ITEM-MENGE > 1 AND
WA_REQ_ITEM-KNTTP = 'A'.
DO WA_REQ_ITEM-MENGE TIMES.
WA_ITEM-ITEM = IM_HEADER->CREATE_ITEM( IM_ITEM = WA_ITEM-ITEM ).
INSERT WA_ITEM INTO TABLE IT_ITEMS.
ENDDO.
ENDIF.
ENDLOOP.
DESCRIBE TABLE IT_ITEMS LINES LL_LINE.
LOOP AT IT_ITEMS INTO WA_ITEM.
WA_ITEM_IF = WA_ITEM-ITEM.
WA_REQ_ITEM = WA_ITEM_IF->GET_DATA( ).
ENDLOOP.Based on condition I am creating new item and append to the object table.
While checking what item data I appended those line items are not having data like material , plant etc.
I tried to SET_DATA method of IF_PURCHASE_REQUISITION_ITEM class even then I am not getting copied data.
Now u2018nu2019 of line items are newly creating but the structure is not having copied data.
Kindly help me how to append the new line items into the object.
I have pasted my code where and what I have change .
If any guys implemented this method kindly help me to send code details for my requirement.
Thanks in advance.
sharma
Edited by: Rob Burbank on Jun 17, 2010 11:15 AM
‎2010 Jun 17 4:17 PM
Moderator message - When closing old threads, there is no need to add a comment. Adding a pasted answer like "Thanks" only brings old threads to the top of the forum list and pushes current ones down. If you do add a comment, please indicate just how the problem was resolved. Also, if you assign po(i)nts when closing old threads rather than just marking them as answered, that will encourage people to respond to your new questions. Rob
‎2010 Jun 17 4:32 PM
Sharma - you aren't paying attention to your e-mails are you. Cross posting is not allowed in this forum.
Repeated violations of forum rules can result in the deletion of your account.
Rob
‎2010 Jun 17 4:34 PM
Hi,
Thanks. In future I will take care.
Sharma
‎2010 Jun 21 8:13 PM
‎2014 Feb 10 2:39 PM
Thanks for the code man. Was very useful for me.