We have added search box. Key in SAP issue keyword to search
TopBottom

Announcement: wanna exchange links? contact me at sapchatroom@gmail.com.

RE: RE:[sap-dev] BAPI_SALESORDER_CREATEFROMDAT2 and Configuration for 1 line item

Posted by Admin at
Share this post:
Ma.gnolia DiggIt! Del.icio.us Yahoo Furl Technorati Reddit

Posted by Mario PIGNOLO
on May 28 at 2:45 AM
Mark this reply as helpfulMark as helpful
Hi H Leo,

take a look at these snippets ...
One thing more: this example creates a position 100 that will be priced
... fill_order_itemsin_ldv
All the other position are referring to this position ...
fill_order_itemsin_wagon with wa_items-hg_lv_item =
item_number_old.(which is UEPOS
This means that wa_items-itm_number will be 100 and 0, 101 and 100, 102
and 100, 103 and 100 aso.
If you dont need this, dont fill the attribut wa_items-hg_lv_item and
just give a sequence to wa_items-itm_number

Hope this helps

One more thing: Once you created the order, and even after the commit
work, pricing is not done. Therefore
I used 'BAPI_SALESORDER_CHANGE' with update flag set to x. Now pricing
should be OK





PERFORM fill_order_headerin.
PERFORM fill_order_partners.

IF fcode = adv_orders.
* If more than one ldv are selected and if the the sales orders
* are created one by one then the first item number need to be 100
* for each sales orders
item_number_old = 100.
ENDIF.

* Fill first order line with LdV data (posnr and uepos = 0)
item_number = item_number_old.
PERFORM fill_order_itemsin_ldv.

* Fill next positions wit waggon data gons
LOOP AT tt9txw
INTO tt9txw_wa
WHERE entfer = tt9txk_wa-entfer
AND resexp = tt9txk_wa-resexp
AND garexp = tt9txk_wa-garexp
AND numexp = tt9txk_wa-numexp
AND datexp = tt9txk_wa-datexp.

PERFORM fill_order_itemsin_wagon.

ENDLOOP.

* Execute the BAPI ?
CLEAR vbeln.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
order_header_in = order_header
IMPORTING
salesdocument = vbeln
TABLES
return = return
order_items_in = order_items
order_partners = order_partners
order_schedules_in = order_schedules
order_conditions_in = order_conditions.


* Append protocol to the result table for the BAPI
IF vbeln IS INITIAL.
* Error procedure
ELSE.
* Commit work & update table ALV-grid and TT9TXK
CLEAR wa_return2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = xsigne
IMPORTING
return = wa_return2.

* Update order 'cause pricing not yet done
CLEAR order_headerx.
order_headerx-updateflag = update.

REFRESH return.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = vbeln
order_header_inx = order_headerx
TABLES
return = return.

CLEAR wa_return2.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = xsigne
IMPORTING
return = wa_return2.

ENDIF.






FORM fill_order_itemsin_ldv.

* Process the order items (Positions & subpositions)
CLEAR wa_items.
wa_items-itm_number = item_number.
wa_items-material = matnr_ldv.
wa_items-purch_no_c = tt9txk_wa-ldv_sd_ref.
wa_items-purch_no_s = tt9txk_wa-refexp.
wa_items-short_text = wa_items-purch_no_c.
wa_items-target_qty = 1.
wa_items-ref_doc = tt9txk_wa-contract.
wa_items-ref_doc_it = tt9txk_wa-contract_pos.
wa_items-ref_doc_ca = 'G'.
wa_items-trg_qty_no = 1.
wa_items-trgqty_den = 1.
APPEND wa_items TO order_items.

* Scheduling the position
CLEAR wa_schedules.
wa_schedules-itm_number = item_number.
wa_schedules-sched_line = 1.
wa_schedules-req_date = tt9txk_wa-datexp.
wa_schedules-req_qty = p_req_qty.
APPEND wa_schedules TO order_schedules.

item_number = item_number + 1.

ENDFORM. " FILL_ORDER_ITEMSIN_LDV




FORM fill_order_itemsin_wagon.

* Process the order items (Positions & subpositions)
CLEAR wa_items.
wa_items-itm_number = item_number.
wa_items-hg_lv_item = item_number_old.
wa_items-material = matnr_wag.
wa_items-target_qty = 1.
wa_items-ref_doc = tt9txk_wa-contract.
wa_items-ref_doc_it = tt9txk_wa-contract_pos.
wa_items-ref_doc_ca = 'G'.
wa_items-purch_no_c = tt9txk_wa-ldv_sd_ref.
wa_items-purch_no_s = tt9txk_wa-refexp.
CONCATENATE tt9txk_wa-ldv_sd_ref
'-'
tt9txw_wa-nrwagon
INTO wa_items-short_text.
CONDENSE wa_items-short_text NO-GAPS.
wa_items-trg_qty_no = 1.
wa_items-trgqty_den = 1.
wa_items-gross_wght = tt9txw_wa-poidsbrut.
wa_items-net_weight = tt9txw_wa-poidsnet.
wa_items-untof_wght = tt9txw_wa-unit_pds.
APPEND wa_items TO order_items.

* Scheduling the position
CLEAR wa_schedules.
wa_schedules-itm_number = item_number.
wa_schedules-sched_line = 1.
wa_schedules-req_date = tt9txk_wa-datexp.
wa_schedules-req_qty = p_req_qty.
APPEND wa_schedules TO order_schedules.

item_number = item_number + 1.

ENDFORM. " FILL_ORDER_ITEMSIN_WAGON
________________________________

From: H Leo via sap-dev [mailto:sap-dev@Groups.ITtoolbox.com]
Sent: Friday, May 28, 2010 5:29 AM
To: Mario PIGNOLO
Subject: Re:RE:[sap-dev] BAPI_SALESORDER_CREATEFROMDAT2 and
Configuration for 1 line item


Posted by H Leo

on May 27 at 11:28 PM Mark this reply as helpfulMark as helpful
<http://it.toolbox.com/api/ContentVote/3535093/1/1/ >
For BAPI, I think you could debug and check the RETURN from BAPI,
usually, there will be some detailed information in the return table

?2010-05-28 00:27:03?"hnlyscq via sap-dev"
<sap-dev@Groups.ITtoolbox.com> ???

Posted by hnlyscq
on May 27 at 12:26 PMMark as helpful
Hi all,

I encounter the same problem when i create the Sales Order with
configuration data via BAPI BAPI_SALESORDER_CREATEFROMDAT2. Anyone give
me some help.Thanks.

error message.
Internal error: 000010, 000010, NOT_ALL_INPUT_DATA_PROCESSED,

---------------Original Message---------------
From: USER_1662368
Sent: Monday, December 14, 2009 4:55 AM
Subject: BAPI_SALESORDER_CREATEFROMDAT2 and Configuration for 1 line
item

> Hi All,
> I am working on a program to create the Open Sales Order with
configuration data via BAPI BAPI_SALESORDER_CREATEFROMDAT2. I am able to
generate the Sales Order with configuration (factor & individual length)
succesfully for a Sales Order with 1 line item. However, I could not
create the SO with configuration info if the sales order have > 1 line
item.
> I suspect is this part "gt_order_cfgs_ref-posex = gw_upload-posnr."
causing the program not able to crerate the charateristic for SO > 1
items.
> The error msg:
> SALES_HEADER_IN has been processed successfully
> Internal error: 000010, 000010, NOT_ALL_INPUT_DATA_PROCESSED,
> Error in SALES_ITEM_IN 000000
> Item 000010 does not exist
> Please advise!
> My coding for BAPI:
> LOOP AT gt_upload INTO gw_upload_t.
> gw_upload = gw_upload_t.
> AT NEW ihrez.
> *Assign the Header info
> gw_order_header_in-doc_type = gw_upload-auart. "Sales Doc Type
> gw_order_header_in-sales_org = gw_upload-vkorg. "Sales Org
> gw_order_header_in-distr_chan = gw_upload-vtweg. "Dist Channel
> gw_order_header_in-division = gw_upload-spart. "Division
> gw_order_header_in-req_date_h = gw_upload-edatu. "Requested Delivery
Date
> gw_order_header_in-purch_no_c = gw_upload-bstkd. "Customer PO No.
> gw_order_header_in-pmnttrms = gw_upload-zterm. "Terms of Payment
> gw_order_header_in-collect_no = gw_upload-submi. "Print
Indicator/Collective No
> gw_order_header_in-dlvschduse = gw_upload-abrvw. "Usage
> gw_order_header_in-doc_date = gw_upload-audat. "Document Date
> gw_order_header_in-currency = gw_upload-waerk. "Doc. Currency
> gw_order_header_in-ass_number = gw_upload-zuonr. "Assignment No.
> ENDAT.
> *Assign the line item info
> gt_order_items_in-po_itm_no = gw_upload-posnr.
> gt_order_items_in-material = gw_upload-matnr.
> gt_order_items_in-ref_doc_it = gw_upload-posnr.
> gt_order_items_in-target_qty = gw_upload-kwmeng.
> APPEND gt_order_items_in.
> gt_order_schedules_in-itm_number = gw_upload-posnr.
> gt_order_schedules_in-req_date = gw_upload-edatu. "????
> gt_order_schedules_in-req_qty = gw_upload-kwmeng.
> APPEND gt_order_schedules_in.
>
> *Assign the Customer partners info
> gt_order_partners-partn_role = 'WE'.
> gt_order_partners-partn_numb = gw_upload-kunnr_sh.
> APPEND gt_order_partners.
> gt_order_partners-partn_role = 'AG'.
> gt_order_partners-partn_numb = gw_upload-kunnr_sp.
> APPEND gt_order_partners.
> *Assign the Configuration charateristic
> gt_order_cfgs_partof-parent_id = '00000001'.
> gt_order_cfgs_partof-inst_id = '00000001'.
> gt_order_cfgs_partof-class_type = '300'.
> gt_order_cfgs_partof-obj_type = 'MARA'.
> gt_order_cfgs_partof-obj_key = 'K_PC_MILLIKEN'.
> gt_order_cfgs_partof-author = '8'.
> gt_order_cfgs_partof-part_of_no = '00010'.
> *gt_order_cfgs_partof-part_of_guid =
'4AFEB56EA28C0263E1008000C0AA760F'.
> APPEND gt_order_cfgs_partof.
> gt_order_cfgs_inst-config_id = '000001'.
> gt_order_cfgs_inst-inst_id = '00000001'.
> gt_order_cfgs_inst-obj_type = 'MARA'.
> gt_order_cfgs_inst-class_type = '300'.
> gt_order_cfgs_inst-obj_key = 'K_PC_MILLIKEN'.
> gt_order_cfgs_inst-quantity = '3'.
> gt_order_cfgs_inst-complete = 'T'.
> gt_order_cfgs_inst-consistent = 'T'.
> APPEND gt_order_cfgs_inst.
> gt_order_cfgs_ref-posex = gw_upload-posnr.
> gt_order_cfgs_ref-config_id = '000001'.
> gt_order_cfgs_ref-root_id = '00000001'.
> **gt_order_cfgs_ref-kbprofile = 'PROFILE_K_PC_MILLIKEN'.
> gt_order_cfgs_ref-complete = 'T'.
> gt_order_cfgs_ref-consistent = 'T'.
> gt_order_cfgs_ref-cbase_id_type = 'G'.
> **gt_order_cfgs_ref-cbase_id = '4B1F690541D604C7E1008001C0AA760F'.
> APPEND gt_order_cfgs_ref.
> gt_order_cfgs_value-config_id = '000001'.
> gt_order_cfgs_value-inst_id = '00000001'.
> gt_order_cfgs_value-charc = 'SAP_MILLCA_LENGTH'.
> gt_order_cfgs_value-value = gw_upload-indlength.
> *gt_order_cfgs_value-author = '8'.
> gt_order_cfgs_value-value_to = gw_upload-indlength.
> APPEND gt_order_cfgs_value.
> gt_order_cfgs_value-config_id = '000001'.
> gt_order_cfgs_value-inst_id = '00000001'.
> gt_order_cfgs_value-charc = 'SAP_MILLCA_FACTOR'.
> gt_order_cfgs_value-value = gw_upload-factor.
> *gt_order_cfgs_value-author = '8'.
> gt_order_cfgs_value-value_to = gw_upload-factor.
> APPEND gt_order_cfgs_value.
> * Assign item pricing condition
> gt_order_conditions_in-itm_number = gw_upload-posnr. "Condition item
number
> gt_order_conditions_in-cond_type = 'PR00'. "Condition type
> gt_order_conditions_in-cond_value = gw_upload-sellprice. "Condition
rate
> gt_order_conditions_in-currency = gw_upload-waerk. "Currency Key
> APPEND gt_order_conditions_in.
>
> *Call BAPI to create Sales Order
> AT END OF ihrez.
> PERFORM call_function.
> ENDAT.
>
> FORM call_function .
> CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
> EXPORTING
> * salesdocumentin = p_new
> order_header_in = gw_order_header_in
> * ORDER_HEADER_INX * SENDER * BINARY_RELATIONSHIPTYPE *
INT_NUMBER_ASSIGNMENT * BEHAVE_WHEN_ERROR * LOGIC_SWITCH * TESTRUN *
CONVERT = ' '
> IMPORTING
> salesdocument = gv_salesdocument
> TABLES
> return = gt_return1
> order_items_in = gt_order_items_in
> * ORDER_ITEMS_INX order_partners = gt_order_partners
> order_schedules_in = gt_order_schedules_in
> * ORDER_SCHEDULES_INX order_conditions_in = gt_order_conditions_in
> * ORDER_CONDITIONS_INX order_cfgs_ref = gt_order_cfgs_ref
> order_cfgs_inst = gt_order_cfgs_inst
> order_cfgs_part_of = gt_order_cfgs_partof
> order_cfgs_value = gt_order_cfgs_value
> * ORDER_CFGS_BLOB * ORDER_CFGS_VK ORDER_CFGS_REFINST =
gt_order_cfgs_refinst
> * ORDER_CCARD order_text = gt_order_text.
> * ORDER_KEYS * EXTENSIONIN * PARTNERADDRESSES .
> CLEAR: gw_order_header_in, gv_salesdocument, gt_return1,
gt_order_items_in,
> gt_order_partners, gt_order_schedules_in, gt_order_conditions_in,
> gt_order_cfgs_value, gt_order_text, gt_order_cfgs_ref,
gt_order_cfgs_inst,
> gt_order_cfgs_partof, gt_order_cfgs_value, gt_order_cfgs_refinst.
> REFRESH: gt_return1, gt_order_items_in, gt_order_partners,
gt_order_schedules_in,
> gt_order_conditions_in, gt_order_cfgs_value, gt_order_text,
> gt_order_cfgs_ref, gt_order_cfgs_inst, gt_order_cfgs_partof,
> gt_order_cfgs_value, gt_order_cfgs_refinst.
> ENDFORM. " CALL_FUNCTION
> Thank you!
> soll

__.____._
Copyright © 2010 Toolbox.com and message author.

Toolbox.com 4343 N. Scottsdale Road Suite 280, Scottsdale, AZ 85251
In the Spotlight
Earn Recognition for Your Contributions at Toolbox for IT. Gain Points for Community Achievements
_.____.__

0 comments:

Post a Comment

T r a n s l a t e to your language